diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2020-07-22 22:08:33 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2020-07-22 22:08:33 +0000 |
commit | c0f99416047be7c3b7e5413d7a0187a21022a02b (patch) | |
tree | 4c0861aa3dc9634684a8048b855426276eebb96b | |
parent | 800da8b29095a06283380f9adb2c1202a23ee57e (diff) | |
download | poi-c0f99416047be7c3b7e5413d7a0187a21022a02b.tar.gz poi-c0f99416047be7c3b7e5413d7a0187a21022a02b.zip |
#64411 - Provide JigSaw modules
- use classpath-build for Java 8, otherwise use modulepath
- save module-info classes to source, when using Java 9+ environment
- rename example packages - otherwise package clashes occured in the tests
- move agile encryption from ooxml to main.
remove EncryptionInfo XmlBeans and schema and use custom xml marshalling
- move ooxml test classes which reside in the same package as their tested main class
- rename base test classes to "BaseTest..." - temporarily I've used a light version of the main test classes to test scratchpad / ooxml
- build.xml - fixed the Rhino javascript errors of the dependency-macros
- DrawTextParagraph - fixed StringIndexOutOfBounds when logging set to debug level
- use JigSaw provider interface (= Java ServiceLoader), i.e. it wasn't possible (without openening everything), to access ooxml factory classes from main factory stub
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1880164 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | build.xml | 1272 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/crypt/OOXMLPasswordsTry.java (renamed from src/examples/src/org/apache/poi/crypt/examples/OOXMLPasswordsTry.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hpsf/CopyCompare.java (renamed from src/examples/src/org/apache/poi/hpsf/examples/CopyCompare.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hpsf/ModifyDocumentSummaryInformation.java (renamed from src/examples/src/org/apache/poi/hpsf/examples/ModifyDocumentSummaryInformation.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hpsf/ReadCustomPropertySets.java (renamed from src/examples/src/org/apache/poi/hpsf/examples/ReadCustomPropertySets.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hpsf/ReadTitle.java (renamed from src/examples/src/org/apache/poi/hpsf/examples/ReadTitle.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hpsf/WriteAuthorAndTitle.java (renamed from src/examples/src/org/apache/poi/hpsf/examples/WriteAuthorAndTitle.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hpsf/WriteTitle.java (renamed from src/examples/src/org/apache/poi/hpsf/examples/WriteTitle.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hslf/ApacheconEU08.java (renamed from src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hslf/BulletsDemo.java (renamed from src/examples/src/org/apache/poi/hslf/examples/BulletsDemo.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hslf/CreateHyperlink.java (renamed from src/examples/src/org/apache/poi/hslf/examples/CreateHyperlink.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hslf/DataExtraction.java (renamed from src/examples/src/org/apache/poi/hslf/examples/DataExtraction.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hslf/Graphics2DDemo.java (renamed from src/examples/src/org/apache/poi/hslf/examples/Graphics2DDemo.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hslf/HeadersFootersDemo.java (renamed from src/examples/src/org/apache/poi/hslf/examples/HeadersFootersDemo.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hslf/Hyperlinks.java (renamed from src/examples/src/org/apache/poi/hslf/examples/Hyperlinks.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hslf/SoundFinder.java (renamed from src/examples/src/org/apache/poi/hslf/examples/SoundFinder.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hslf/TableDemo.java (renamed from src/examples/src/org/apache/poi/hslf/examples/TableDemo.java) | 4 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hsmf/Msg2txt.java (renamed from src/examples/src/org/apache/poi/hsmf/examples/Msg2txt.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/eventusermodel/XLS2CSVmra.java (renamed from src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/AddDimensionedImage.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java) | 4 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/Alignment.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/Alignment.java) | 4 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/BigExample.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/BigExample.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/Borders.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/Borders.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/CellComments.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/CellComments.java) | 8 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/CellTypes.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/CellTypes.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/CreateCells.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/CreateCells.java) | 12 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/CreateDateCells.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/CreateDateCells.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/EmbeddedObjects.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/EmbeddedObjects.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/EventExample.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/EventExample.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/FrillsAndFills.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/FrillsAndFills.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/HSSFReadWrite.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/HyperlinkFormula.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/HyperlinkFormula.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/Hyperlinks.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/InCellLists.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/InCellLists.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/MergedCells.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/MergedCells.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/NewLinesInCells.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/NewLinesInCells.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/NewSheet.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/NewSheet.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/NewWorkbook.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/NewWorkbook.java) | 4 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/OfficeDrawing.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawing.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/OfficeDrawingWithGraphics.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java) | 18 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/Outlines.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/Outlines.java) | 4 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/ReadWriteWorkbook.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/ReadWriteWorkbook.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/RepeatingRowsAndColumns.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/RepeatingRowsAndColumns.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/SplitAndFreezePanes.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/SplitAndFreezePanes.java) | 4 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/WorkingWithFonts.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/WorkingWithFonts.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hssf/usermodel/ZoomSheet.java (renamed from src/examples/src/org/apache/poi/hssf/usermodel/examples/ZoomSheet.java) | 10 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/hwpf/Word2Forrest.java (renamed from src/examples/src/org/apache/poi/hwpf/Word2Forrest.java) | 3 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/AddDimensionedImage.java (renamed from src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/AligningCells.java (renamed from src/examples/src/org/apache/poi/ss/examples/AligningCells.java) | 11 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/BusinessPlan.java (renamed from src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/CalendarDemo.java (renamed from src/examples/src/org/apache/poi/ss/examples/CalendarDemo.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/CellStyleDetails.java (renamed from src/examples/src/org/apache/poi/ss/examples/CellStyleDetails.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/ConditionalFormats.java (renamed from src/examples/src/org/apache/poi/ss/examples/ConditionalFormats.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/DrawingBorders.java (renamed from src/examples/src/org/apache/poi/ss/examples/DrawingBorders.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/ExcelComparator.java (renamed from src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/LinkedDropDownLists.java (renamed from src/examples/src/org/apache/poi/ss/examples/LinkedDropDownLists.java) | 16 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/LoadEmbedded.java (renamed from src/examples/src/org/apache/poi/ss/examples/LoadEmbedded.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/LoanCalculator.java (renamed from src/examples/src/org/apache/poi/ss/examples/LoanCalculator.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/SSPerformanceTest.java (renamed from src/examples/src/org/apache/poi/ss/examples/SSPerformanceTest.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/TimesheetDemo.java (renamed from src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/ToCSV.java (renamed from src/examples/src/org/apache/poi/ss/examples/ToCSV.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/formula/CalculateMortgage.java (renamed from src/examples/src/org/apache/poi/ss/examples/formula/CalculateMortgage.java) | 44 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/formula/CheckFunctionsSupported.java (renamed from src/examples/src/org/apache/poi/ss/examples/formula/CheckFunctionsSupported.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/formula/SettingExternalFunction.java (renamed from src/examples/src/org/apache/poi/ss/examples/formula/SettingExternalFunction.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/formula/UserDefinedFunctionExample.java (renamed from src/examples/src/org/apache/poi/ss/examples/formula/UserDefinedFunctionExample.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/formula/mortgage-calculation.xls (renamed from src/examples/src/org/apache/poi/ss/examples/formula/mortgage-calculation.xls) | bin | 37376 -> 37376 bytes | |||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/html/HSSFHtmlHelper.java (renamed from src/examples/src/org/apache/poi/ss/examples/html/HSSFHtmlHelper.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/html/HtmlHelper.java (renamed from src/examples/src/org/apache/poi/ss/examples/html/HtmlHelper.java) | 6 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/html/ToHtml.java (renamed from src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/html/XSSFHtmlHelper.java (renamed from src/examples/src/org/apache/poi/ss/examples/html/XSSFHtmlHelper.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/html/excelStyle.css (renamed from src/examples/src/org/apache/poi/ss/examples/html/excelStyle.css) | 0 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/ss/html/package-info.java (renamed from src/examples/src/org/apache/poi/ss/examples/html/package-info.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/util/TempFileUtils.java | 46 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/AddVideoToPptx.java.txt (renamed from src/examples/src/org/apache/poi/xslf/usermodel/AddVideoToPptx.java.txt) | 0 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/BarChartDemo.java (renamed from src/examples/src/org/apache/poi/xslf/usermodel/BarChartDemo.java) | 5 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/ChartFromScratch.java (renamed from src/examples/src/org/apache/poi/xslf/usermodel/ChartFromScratch.java) | 7 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/DataExtraction.java (renamed from src/examples/src/org/apache/poi/xslf/usermodel/DataExtraction.java) | 8 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/MergePresentations.java (renamed from src/examples/src/org/apache/poi/xslf/usermodel/MergePresentations.java) | 5 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/PPTX2SVG.txt (renamed from src/examples/src/org/apache/poi/xslf/usermodel/PPTX2SVG.txt) | 0 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/PieChartDemo.java (renamed from src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java) | 5 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/Tutorial1.java (renamed from src/examples/src/org/apache/poi/xslf/usermodel/Tutorial1.java) | 12 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/Tutorial2.java (renamed from src/examples/src/org/apache/poi/xslf/usermodel/Tutorial2.java) | 10 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/Tutorial3.java (renamed from src/examples/src/org/apache/poi/xslf/usermodel/Tutorial3.java) | 7 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/Tutorial4.java (renamed from src/examples/src/org/apache/poi/xslf/usermodel/Tutorial4.java) | 11 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/Tutorial5.java (renamed from src/examples/src/org/apache/poi/xslf/usermodel/Tutorial5.java) | 7 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/Tutorial6.java (renamed from src/examples/src/org/apache/poi/xslf/usermodel/Tutorial6.java) | 8 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/Tutorial7.java (renamed from src/examples/src/org/apache/poi/xslf/usermodel/Tutorial7.java) | 9 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/bar-chart-data.txt (renamed from src/examples/src/org/apache/poi/xslf/usermodel/bar-chart-data.txt) | 0 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/bar-chart-template.pptx (renamed from src/examples/src/org/apache/poi/xslf/usermodel/bar-chart-template.pptx) | bin | 44410 -> 44410 bytes | |||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/pie-chart-data.txt (renamed from src/examples/src/org/apache/poi/xslf/usermodel/pie-chart-data.txt) | 0 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/pie-chart-template.pptx (renamed from src/examples/src/org/apache/poi/xslf/usermodel/pie-chart-template.pptx) | bin | 55297 -> 55297 bytes | |||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/tutorial/Step1.java (renamed from src/examples/src/org/apache/poi/xslf/usermodel/tutorial/Step1.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xslf/tutorial/Step2.java (renamed from src/examples/src/org/apache/poi/xslf/usermodel/tutorial/Step2.java) | 6 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/eventusermodel/FromHowTo.java (renamed from src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java) | 7 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/eventusermodel/LoadPasswordProtectedXlsxStreaming.java (renamed from src/examples/src/org/apache/poi/xssf/eventusermodel/examples/LoadPasswordProtectedXlsxStreaming.java) | 4 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/eventusermodel/XLSX2CSV.java (renamed from src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java) | 7 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/streaming/HybridStreaming.java (renamed from src/examples/src/org/apache/poi/xssf/streaming/examples/HybridStreaming.java) | 12 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/streaming/Outlining.java (renamed from src/examples/src/org/apache/poi/xssf/streaming/examples/Outlining.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/streaming/SavePasswordProtectedXlsx.java (renamed from src/examples/src/org/apache/poi/xssf/streaming/examples/SavePasswordProtectedXlsx.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/AligningCells.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java) | 4 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/BarAndLineChart.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/BarAndLineChart.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/BarChart.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/BarChart.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/BigGridDemo.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/CalendarDemo.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java) | 23 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/CellComments.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/CellComments.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/CreateCell.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateCell.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/CreatePivotTable.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/CreatePivotTable.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/CreatePivotTable2.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/CreatePivotTable2.java) | 4 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/CreateTable.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateTable.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/CreateUserDefinedDataFormats.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateUserDefinedDataFormats.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/CustomXMLMapping.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/CustomXMLMapping.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/EmbeddedObjects.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/EmbeddedObjects.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/ExcelChartWithTargetLine.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/ExcelChartWithTargetLine.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/FillsAndColors.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/FillsAndColors.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/FitSheetToOnePage.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/FitSheetToOnePage.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/HeadersAndFooters.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/HeadersAndFooters.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/HyperlinkExample.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/IterateCells.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/IterateCells.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/LineChart.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/LineChart.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/LoadPasswordProtectedXlsx.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/LoadPasswordProtectedXlsx.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/MergingCells.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/MergingCells.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/NewLinesInCells.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/NewLinesInCells.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/Outlining.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/Outlining.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/ScatterChart.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/ScatterChart.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/SelectedSheet.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/SelectedSheet.java) | 4 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/ShiftRows.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/ShiftRows.java) | 4 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/SplitAndFreezePanes.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/SplitAndFreezePanes.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/WorkbookProperties.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkbookProperties.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/WorkingWithBorders.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithBorders.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/WorkingWithFonts.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithFonts.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/WorkingWithPageSetup.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPageSetup.java) | 4 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/WorkingWithPictures.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xssf/usermodel/WorkingWithRichText.java (renamed from src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xwpf/usermodel/BarChartExample.java (renamed from src/examples/src/org/apache/poi/xwpf/usermodel/examples/BarChartExample.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xwpf/usermodel/BetterHeaderFooterExample.java (renamed from src/examples/src/org/apache/poi/xwpf/usermodel/examples/BetterHeaderFooterExample.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xwpf/usermodel/ChartFromScratch.java (renamed from src/examples/src/org/apache/poi/xwpf/usermodel/examples/ChartFromScratch.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xwpf/usermodel/HeaderFooterTable.java (renamed from src/examples/src/org/apache/poi/xwpf/usermodel/examples/HeaderFooterTable.java) | 4 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xwpf/usermodel/SimpleDocument.java (renamed from src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleDocument.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xwpf/usermodel/SimpleDocumentWithHeader.java (renamed from src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleDocumentWithHeader.java) | 4 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xwpf/usermodel/SimpleImages.java (renamed from src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleImages.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xwpf/usermodel/SimpleTable.java (renamed from src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleTable.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xwpf/usermodel/UpdateEmbeddedDoc.java (renamed from src/examples/src/org/apache/poi/xwpf/usermodel/examples/UpdateEmbeddedDoc.java) | 2 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xwpf/usermodel/bar-chart-data.txt (renamed from src/examples/src/org/apache/poi/xwpf/usermodel/examples/bar-chart-data.txt) | 0 | ||||
-rw-r--r-- | src/examples/src/org/apache/poi/examples/xwpf/usermodel/bar-chart-template.docx (renamed from src/examples/src/org/apache/poi/xwpf/usermodel/examples/bar-chart-template.docx) | bin | 37656 -> 37656 bytes | |||
-rw-r--r-- | src/examples/src/org/apache/poi/xssf/streaming/examples/DeferredGeneration.java | 63 | ||||
-rw-r--r-- | src/excelant/testcases/org/apache/poi/ss/excelant/CalculateMortgageFunction.java (renamed from src/excelant/testcases/org/apache/poi/ss/examples/formula/CalculateMortgageFunction.java) | 44 | ||||
-rw-r--r-- | src/excelant/testcases/org/apache/poi/ss/excelant/ExcelAntUserDefinedFunctionTestHelper.java (renamed from src/excelant/testcases/org/apache/poi/ss/examples/formula/ExcelAntUserDefinedFunctionTestHelper.java) | 4 | ||||
-rw-r--r-- | src/excelant/testcases/org/apache/poi/ss/excelant/TestExcelAntUserDefinedFunction.java (renamed from src/excelant/testcases/org/apache/poi/ss/examples/formula/TestExcelAntUserDefinedFunction.java) | 2 | ||||
-rw-r--r-- | src/excelant/testcases/org/apache/poi/ss/excelant/tests.xml | 4 | ||||
-rw-r--r-- | src/excelant/testcases/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtil.java | 2 | ||||
-rw-r--r-- | src/integrationtest/org/apache/poi/stress/BaseIntegrationTest.java (renamed from src/integrationtest/org/apache/poi/BaseIntegrationTest.java) | 17 | ||||
-rw-r--r-- | src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java | 2 | ||||
-rw-r--r-- | src/integrationtest/org/apache/poi/stress/HSSFRecordsStresser.java (renamed from src/integrationtest/org/apache/poi/hssf/usermodel/RecordsStresser.java) | 5 | ||||
-rw-r--r-- | src/integrationtest/org/apache/poi/stress/HeapDump.java (renamed from src/integrationtest/org/apache/poi/HeapDump.java) | 6 | ||||
-rw-r--r-- | src/integrationtest/org/apache/poi/stress/POIFileScanner.java (renamed from src/integrationtest/org/apache/poi/POIFileScanner.java) | 30 | ||||
-rw-r--r-- | src/integrationtest/org/apache/poi/stress/TestAllFiles.java (renamed from src/integrationtest/org/apache/poi/TestAllFiles.java) | 20 | ||||
-rw-r--r-- | src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java | 26 | ||||
-rw-r--r-- | src/java/org/apache/poi/POIDocument.java | 94 | ||||
-rw-r--r-- | src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java | 3 | ||||
-rw-r--r-- | src/java/org/apache/poi/hssf/usermodel/HSSFWorkbookFactory.java | 62 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/ChainingMode.java | 20 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/EncryptionHeader.java | 18 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java | 25 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/EncryptionVerifier.java | 16 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/agile/AgileDecryptor.java (renamed from src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileDecryptor.java) | 0 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionHeader.java (renamed from src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionHeader.java) | 29 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionInfoBuilder.java (renamed from src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionInfoBuilder.java) | 30 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionVerifier.java (renamed from src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionVerifier.java) | 56 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java (renamed from src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java) | 110 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/agile/CertificateKeyEncryptor.java | 95 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/agile/DataIntegrity.java | 82 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/agile/EncryptionDocument.java | 150 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/agile/KeyData.java | 148 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/agile/KeyEncryptor.java | 81 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/agile/PasswordKeyEncryptor.java | 241 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4EncryptionVerifier.java | 6 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIEncryptionVerifier.java | 6 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptionVerifier.java | 8 | ||||
-rw-r--r-- | src/java/org/apache/poi/poifs/crypt/xor/XOREncryptionVerifier.java | 4 | ||||
-rw-r--r-- | src/java/org/apache/poi/sl/draw/DrawTextParagraph.java | 4 | ||||
-rw-r--r-- | src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java | 195 | ||||
-rw-r--r-- | src/java/org/apache/poi/ss/usermodel/WorkbookProvider.java | 39 | ||||
-rw-r--r-- | src/java/org/apache/poi/util/DefaultTempFileCreationStrategy.java | 40 | ||||
-rw-r--r-- | src/multimodule/examples/java9/module-info.class | bin | 0 -> 929 bytes | |||
-rw-r--r-- | src/multimodule/examples/java9/module-info.java | 40 | ||||
-rw-r--r-- | src/multimodule/excelant/java9/module-info.class | bin | 0 -> 293 bytes | |||
-rw-r--r-- | src/multimodule/excelant/java9/module-info.java (renamed from src/testcases/org/apache/poi/sl/TestCommonSL.java) | 26 | ||||
-rw-r--r-- | src/multimodule/excelant/test9/module-info.class | bin | 0 -> 293 bytes | |||
-rw-r--r-- | src/multimodule/excelant/test9/module-info.java (renamed from src/multimodule/ooxml-security/java9/module-info.java) | 22 | ||||
-rw-r--r-- | src/multimodule/integration/java9/module-info.java | 27 | ||||
-rw-r--r-- | src/multimodule/ooxml-lite-agent/java9/module-info.class | bin | 0 -> 188 bytes | |||
-rw-r--r-- | src/multimodule/ooxml-lite-agent/java9/module-info.java | 22 | ||||
-rw-r--r-- | src/multimodule/ooxml-lite/java9/module-info.class | bin | 0 -> 1483 bytes | |||
-rw-r--r-- | src/multimodule/ooxml-lite/java9/module-info.java | 47 | ||||
-rw-r--r-- | src/multimodule/ooxml-schemas/java9/module-info.class | bin | 1928 -> 2235 bytes | |||
-rw-r--r-- | src/multimodule/ooxml-schemas/java9/module-info.java | 12 | ||||
-rw-r--r-- | src/multimodule/ooxml-security/java9/module-info.class | bin | 660 -> 0 bytes | |||
-rw-r--r-- | src/multimodule/ooxml/java9/module-info.class | bin | 0 -> 2602 bytes | |||
-rw-r--r-- | src/multimodule/ooxml/java9/module-info.java | 87 | ||||
-rw-r--r-- | src/multimodule/ooxml/test9/module-info.class | bin | 0 -> 3471 bytes | |||
-rw-r--r-- | src/multimodule/ooxml/test9/module-info.java | 114 | ||||
-rw-r--r-- | src/multimodule/poi/java9/module-info.class | bin | 0 -> 3035 bytes | |||
-rw-r--r-- | src/multimodule/poi/java9/module-info.java | 9 | ||||
-rw-r--r-- | src/multimodule/poi/test9/module-info.class | bin | 0 -> 3162 bytes | |||
-rw-r--r-- | src/multimodule/poi/test9/module-info.java | 101 | ||||
-rw-r--r-- | src/multimodule/scratchpad/java9/module-info.class | bin | 0 -> 2099 bytes | |||
-rw-r--r-- | src/multimodule/scratchpad/java9/module-info.java | 79 | ||||
-rw-r--r-- | src/multimodule/scratchpad/test9/module-info.class | bin | 0 -> 2273 bytes | |||
-rw-r--r-- | src/multimodule/scratchpad/test9/module-info.java | 84 | ||||
-rw-r--r-- | src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbookFactory.java | 122 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ooxml/TestDetectAsOOXML.java (renamed from src/ooxml/testcases/org/apache/poi/TestDetectAsOOXML.java) | 12 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ooxml/TestEmbedded.java (renamed from src/ooxml/testcases/org/apache/poi/TestEmbedded.java) | 4 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ooxml/TestXMLPropertiesTextExtractor.java (renamed from src/ooxml/testcases/org/apache/poi/TestXMLPropertiesTextExtractor.java) | 3 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ooxml/lite/OOXMLLiteAgent.java (renamed from src/ooxml/testcases/org/apache/poi/ooxml/util/OOXMLLiteAgent.java) | 2 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java (renamed from src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java) | 7 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/AllPOIFSCryptoTests.java (renamed from src/ooxml/testcases/org/apache/poi/poifs/crypt/AllPOIFSCryptoTests.java) | 2 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/TestAgileEncryptionParameters.java (renamed from src/ooxml/testcases/org/apache/poi/poifs/crypt/TestAgileEncryptionParameters.java) | 21 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/TestDecryptor.java (renamed from src/ooxml/testcases/org/apache/poi/poifs/crypt/TestDecryptor.java) | 6 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/TestEncryptionInfo.java (renamed from src/ooxml/testcases/org/apache/poi/poifs/crypt/TestEncryptionInfo.java) | 21 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/TestEncryptor.java (renamed from src/ooxml/testcases/org/apache/poi/poifs/crypt/TestEncryptor.java) | 9 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/TestHxxFEncryption.java (renamed from src/ooxml/testcases/org/apache/poi/poifs/crypt/TestHxxFEncryption.java) | 9 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/TestSecureTempZip.java (renamed from src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSecureTempZip.java) | 17 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/sl/tests/SLCommonUtils.java (renamed from src/ooxml/testcases/org/apache/poi/sl/SLCommonUtils.java) | 8 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/sl/tests/TestFonts.java (renamed from src/ooxml/testcases/org/apache/poi/sl/TestFonts.java) | 4 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/sl/tests/TestHeadersFooters.java (renamed from src/ooxml/testcases/org/apache/poi/sl/TestHeadersFooters.java) | 8 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/sl/tests/TestOleShape.java (renamed from src/ooxml/testcases/org/apache/poi/sl/TestOleShape.java) | 20 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/sl/tests/TestSlide.java (renamed from src/ooxml/testcases/org/apache/poi/sl/TestSlide.java) | 16 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/sl/tests/TestTable.java (renamed from src/ooxml/testcases/org/apache/poi/sl/TestTable.java) | 40 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/sl/tests/draw/TestDrawPictureShape.java (renamed from src/ooxml/testcases/org/apache/poi/sl/draw/TestDrawPictureShape.java) | 3 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/TestWorkbookFactory.java (renamed from src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java) | 30 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/extractor/TestEmbeddedExtractor.java (renamed from src/ooxml/testcases/org/apache/poi/ss/extractor/TestEmbeddedExtractor.java) | 4 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/format/TestCellFormatPart.java (renamed from src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java) | 16 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/formula/TestFormulaParser.java (renamed from src/ooxml/testcases/org/apache/poi/ss/formula/TestFormulaParser.java) | 26 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/formula/TestStructuredReferences.java (renamed from src/ooxml/testcases/org/apache/poi/ss/formula/TestStructuredReferences.java) | 7 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/formula/eval/TestXSSFCircularReferences.java (renamed from src/ooxml/testcases/org/apache/poi/ss/formula/eval/TestXSSFCircularReferences.java) | 3 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/formula/functions/CountifsTests.java (renamed from src/ooxml/testcases/org/apache/poi/ss/formula/functions/CountifsTests.java) | 10 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/formula/functions/TestProper.java (renamed from src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestProper.java) | 3 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/formula/functions/TestSumifsXSSF.java (renamed from src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestSumifsXSSF.java) | 6 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/formula/functions/TestVlookup.java (renamed from src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestVlookup.java) | 12 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/BaseTestXCell.java (renamed from src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXCell.java) | 7 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/BaseTestXRow.java (renamed from src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXRow.java) | 7 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/BaseTestXSheet.java (renamed from src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXSheet.java) | 7 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/BaseTestXWorkbook.java (renamed from src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXWorkbook.java) | 7 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/ConditionalFormattingEvalTest.java (renamed from src/ooxml/testcases/org/apache/poi/ss/usermodel/ConditionalFormattingEvalTest.java) | 56 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/TestEmbedOLEPackage.java (renamed from src/ooxml/testcases/org/apache/poi/ss/usermodel/TestEmbedOLEPackage.java) | 10 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/TestXSSFBorderStyle.java (renamed from src/ooxml/testcases/org/apache/poi/ss/usermodel/TestXSSFBorderStyle.java) | 5 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/TestXSSFRangeCopier.java (renamed from src/ooxml/testcases/org/apache/poi/ss/usermodel/TestXSSFRangeCopier.java) | 11 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/util/TestSXSSFCellUtil.java (renamed from src/ooxml/testcases/org/apache/poi/ss/util/TestSXSSFCellUtil.java) | 7 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/util/TestXSSFCellUtil.java (renamed from src/ooxml/testcases/org/apache/poi/ss/util/TestXSSFCellUtil.java) | 7 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/ss/tests/util/TestXSSFPropertyTemplate.java (renamed from src/ooxml/testcases/org/apache/poi/ss/util/TestXSSFPropertyTemplate.java) | 26 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/util/tests/TestIdentifierManager.java (renamed from src/ooxml/testcases/org/apache/poi/util/TestIdentifierManager.java) | 2 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/util/tests/TestTempFileThreaded.java (renamed from src/ooxml/testcases/org/apache/poi/util/TestTempFileThreaded.java) | 24 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java | 2 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java | 2 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java | 3 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java | 2 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java | 2 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/AllXSSFTests.java | 4 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/streaming/TestDeferredSXSSFWorkbook.java | 65 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFCell.java | 6 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFRow.java | 6 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java | 16 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java | 35 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java | 4 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java | 50 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMatrixFormulasFromXMLSpreadsheet.java | 4 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMissingWorkbookOnXSSF.java | 8 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java | 7 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java | 2 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java | 13 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFForkedEvaluator.java | 6 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java | 64 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java | 10 | ||||
-rw-r--r-- | src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java | 12 | ||||
-rw-r--r-- | src/resources/main/META-INF/services/org.apache.poi.ss.usermodel.WorkbookProvider | 18 | ||||
-rw-r--r-- | src/resources/ooxml/META-INF/services/org.apache.poi.ss.usermodel.WorkbookProvider | 18 | ||||
-rw-r--r-- | src/scratchpad/testcases/org/apache/poi/hslf/TestPOIDocumentScratchpad.java (renamed from src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java) | 8 | ||||
-rw-r--r-- | src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java | 2 | ||||
-rw-r--r-- | src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjListAtom.java | 2 | ||||
-rw-r--r-- | src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTextRun.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/TestJDK12.java (renamed from src/scratchpad/testcases/org/apache/poi/TestJDK12.java) | 4 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java (renamed from src/testcases/org/apache/poi/hssf/dev/BaseXLSIteratingTest.java) | 22 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/dev/TestFormulaViewer.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/dev/TestReSave.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/dev/TestRecordLister.java | 4 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java (renamed from src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java) | 0 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRangeCopier.java | 4 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/sl/draw/geom/TestFormulaParser.java (renamed from src/ooxml/testcases/org/apache/poi/xslf/geom/TestFormulaParser.java) | 6 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShow.java | 42 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/format/TestCellFormat.java | 15 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/AllSSFormulaTests.java | 4 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/BaseTestMissingWorkbook.java (renamed from src/testcases/org/apache/poi/ss/formula/TestMissingWorkbook.java) | 48 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/eval/forked/BaseTestForkedEvaluator.java (renamed from src/testcases/org/apache/poi/ss/formula/eval/forked/TestForkedEvaluator.java) | 10 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/functions/BaseTestNumeric.java (renamed from src/testcases/org/apache/poi/ss/formula/functions/AbstractNumericTestCase.java) | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/functions/TestFinanceLib.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/functions/TestMathX.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/functions/TestStatsLib.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/functions/TestTrunc.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/ptg/BaseTestPtg.java (renamed from src/testcases/org/apache/poi/ss/formula/ptg/AbstractPtgTestCase.java) | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/ptg/TestArea3DPtg.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/ptg/TestAreaErrPtg.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/ptg/TestAttrPtg.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/ptg/TestErrPtg.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/ptg/TestIntersectionPtg.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/ptg/TestPercentPtg.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/ptg/TestRangePtg.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/ptg/TestRef3DPtg.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/formula/ptg/TestUnionPtg.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/ss/usermodel/BaseTestRangeCopier.java (renamed from src/testcases/org/apache/poi/ss/usermodel/TestRangeCopier.java) | 12 |
312 files changed, 3540 insertions, 1963 deletions
@@ -54,6 +54,7 @@ under the License. <property name="main-tests.lib" location="${basedir}/lib/main-tests"/> <property name="ooxml.lib" location="${basedir}/lib/ooxml"/> <property name="ooxml-tests.lib" location="${basedir}/lib/ooxml-tests"/> + <property name="ooxml-provided.lib" location="${basedir}/lib/ooxml-provided"/> <property name="util.lib" location="${basedir}/lib/util"/> @@ -153,9 +154,9 @@ under the License. <property name="ooxml.output.test.dir" location="build/ooxml-test-classes"/> <property name="ooxml.testokfile" location="build/ooxml-testokfile.txt"/> - <property name="ooxml.lite.agent" location="build/ooxml-lite-agent.jar"/> + <property name="ooxml.lite.agent" location="lib/ooxml-tests/ooxml-lite-agent.jar"/> <property name="ooxml.lite.report" location="build/ooxml-lite-report.txt"/> - <property name="ooxml.lite.jar" location="build/ooxml-lite-classes.jar"/> + <property name="ooxml.lite.jar" location="build/dist/maven/poi-ooxml-schemas/poi-ooxml-schemas-${version.id}.jar"/> <property name="ooxml.lite.includes" value="^(com/microsoft/schemas|org/(etsi|openxmlformats|w3/)|org/apache/poi/schemas)"/> @@ -174,37 +175,70 @@ under the License. <property name="excelant.output.test.dir" location="build/excelant-test-classes"/> <property name="excelant.testokfile" location="build/excelant-testokfile.txt"/> - - <scriptdef name="dependency" language="javascript" description="define properties for library dependency"> + <macrodef name="dependency"> <attribute name="prefix"/> <attribute name="artifact"/> <attribute name="usage"/> - <attribute name="packaging"/> - <attribute name="repo"/> - <attribute name="snapshot"/> - <attribute name="query"/> - <attribute name="target"/> - <attribute name="url"/> - <![CDATA[ - var parts = attributes.get("artifact").split(/:/); - var packaging = attributes.get("packaging") || "jar"; - var version = attributes.get("snapshot") || parts[2]; - var repo = attributes.get("repo"); - if (repo == null) { - repo = project.getProperty("repository.m2"); - } - var query = attributes.get("query") || ""; - var usageDir = attributes.get("usage"); - usageDir = project.getProperty("basedir")+(usageDir.charAt(0) == '/' ? "" : "/lib/")+usageDir; - var jarLoc = usageDir+"/"+(attributes.get("target")||(parts[1]+"-"+parts[2]+"."+packaging)); - var urlLoc = attributes.get("url") || - repo+"/"+parts[0].replace(/\./g,"/")+"/"+parts[1]+"/"+parts[2]+"/"+ - parts[1]+"-"+(attributes.get("snapshot") || parts[2])+"."+packaging+query; - project.setProperty(attributes.get("prefix")+"."+packaging, jarLoc); - project.setProperty(attributes.get("prefix")+".url", urlLoc); - ]]> - <!-- TODO: add library to a queue for downloading ... --> - </scriptdef> + <attribute name="packaging" default="jar"/> + <attribute name="repo" default="${repository.m2}"/> + <attribute name="snapshot" default=""/> + <attribute name="query" default=""/> + <attribute name="target" default=""/> + <attribute name="url" default=""/> + + <sequential> + <local name="groupDir"/> + <loadresource property="groupDir"> + <string>@{artifact}</string> + <filterchain> + <replaceregex pattern="([^:]+).*" replace="\1"/> + <replaceregex pattern="\." replace="/" flags="g"/> + </filterchain> + </loadresource> + + <local name="artifactId"/> + <loadresource property="artifactId"> + <string>@{artifact}</string> + <filterchain> + <replaceregex pattern="[^:]+:([^:]+).*" replace="\1"/> + </filterchain> + </loadresource> + + <local name="versionDir"/> + <loadresource property="versionDir"> + <string>@{artifact}</string> + <filterchain> + <replaceregex pattern="[^:]+:[^:]+:(.*)" replace="\1"/> + </filterchain> + </loadresource> + + <local name="version"/> + <property name="version" value="${versionDir}" if:blank="@{snapshot}"/> + <property name="version" value="@{snapshot}"/> + + <local name="usageDir"/> + <loadresource property="usageDir"> + <string>@{usage}</string> + <filterchain> + <replaceregex pattern="^([^/])" replace="/lib/\1"/> + <prefixlines prefix="${basedir}"/> + </filterchain> + </loadresource> + + <local name="jarLoc"/> + <property name="jarLoc" value="${usageDir}/@{target}" unless:blank="@{target}"/> + <property name="jarLoc" value="${usageDir}/${artifactId}-${version}.@{packaging}"/> + + <local name="urlLoc"/> + <property name="urlLoc" value="@{url}" unless:blank="@{url}"/> + <property name="urlLoc" value="@{repo}/${groupDir}/${artifactId}/${versionDir}/${artifactId}-${version}.@{packaging}@{query}"/> + + <property name="@{prefix}.@{packaging}" value="${jarLoc}"/> + <property name="@{prefix}.url" value="${urlLoc}"/> + + <!-- TODO: add library to a queue for downloading ... --> + </sequential> + </macrodef> <!-- jars in the /lib directory, see the fetch-jars target--> @@ -225,13 +259,13 @@ under the License. <dependency prefix="main.byte-buddy-agent" artifact="net.bytebuddy:byte-buddy-agent:1.10.1" usage="main-tests"/> <dependency prefix="main.objenesis" artifact="org.objenesis:objenesis:2.6" usage="main-tests"/> - <dependency prefix="main.ant" artifact="org.apache.ant:ant:1.10.1" usage="excelant"/> - <dependency prefix="main.antlauncher" artifact="org.apache.ant:ant-launcher:1.10.1" usage="excelant"/> + <dependency prefix="main.ant" artifact="org.apache.ant:ant:1.10.8" usage="excelant"/> + <dependency prefix="main.antlauncher" artifact="org.apache.ant:ant-launcher:1.10.8" usage="excelant"/> <!-- xml signature libs - not part of the distribution --> <dependency prefix="dsig.xmlsec" artifact="org.apache.santuario:xmlsec:2.1.5" usage="ooxml-provided"/> - <dependency prefix="dsig.bouncycastle-prov" artifact="org.bouncycastle:bcprov-ext-jdk15on:1.65" usage="ooxml-provided"/> - <dependency prefix="dsig.bouncycastle-pkix" artifact="org.bouncycastle:bcpkix-jdk15on:1.65" usage="ooxml-provided"/> + <dependency prefix="dsig.bouncycastle-prov" artifact="org.bouncycastle:bcprov-ext-jdk15on:1.66" usage="ooxml-provided"/> + <dependency prefix="dsig.bouncycastle-pkix" artifact="org.bouncycastle:bcpkix-jdk15on:1.66" usage="ooxml-provided"/> <dependency prefix="dsig.slf4j-api" artifact="org.slf4j:slf4j-api:1.7.30" usage="ooxml-provided"/> <!-- svg/batik libs - not part of the distribution --> @@ -249,7 +283,7 @@ under the License. <!-- jars in the ooxml-test-lib directory, see the fetch-ooxml-jars target--> <dependency prefix="ooxml.test.reflections" artifact="org.reflections:reflections:0.9.11" usage="ooxml-tests"/> - <dependency prefix="ooxml.test.guava" artifact="com.google.guava:guava:20.0" usage="ooxml-tests"/> + <dependency prefix="ooxml.test.guava" artifact="com.google.guava:guava:29.0-jre" usage="ooxml-tests"/> <dependency prefix="ooxml.test.javassist" artifact="org.javassist:javassist:3.21.0-GA" usage="ooxml-tests"/> <!-- coverage libs --> @@ -262,21 +296,19 @@ under the License. <dependency prefix="rat" artifact="org.apache.rat:apache-rat:0.12" usage="util"/> <dependency prefix="forbidden" artifact="de.thetaphi:forbiddenapis:2.6" usage="util"/> - <property name="maven.ooxml.xsds.version.id" value="1.4"/> + <property name="maven.ooxml.xsds.version.id" value="1.5"/> <!-- See https://www.ecma-international.org/publications/standards/Ecma-376.htm --> <!-- "Copy these file(s), free of charge" --> <property name="ooxml.xsds.izip.1" value="${basedir}/src/ooxml/resources/org/apache/poi/schemas/OfficeOpenXML-XMLSchema.zip"/> <property name="ooxml.xsds.src.dir" location="build/ooxml-xsds-src"/> - <property name="ooxml.xsds.src.jar" location="${ooxml.lib}/ooxml-schemas-${maven.ooxml.xsds.version.id}-sources.jar"/> - <property name="ooxml.xsds.jar" location="${ooxml.lib}/ooxml-schemas-${maven.ooxml.xsds.version.id}.jar"/> + <property name="ooxml.xsds.src.jar" location="build/dist/maven/ooxml-schemas/ooxml-schemas-${maven.ooxml.xsds.version.id}-sources.jar"/> + <property name="ooxml.xsds.jar" location="build/dist/maven/ooxml-schemas/ooxml-schemas-${maven.ooxml.xsds.version.id}.jar"/> <!-- additional schemas are packed into the poi schemas jar, --> <!-- so we don't have to care about a seperate versioning of the original ooxml schemas --> <property name="ooxml.xsds.izip.2" value="${basedir}/src/ooxml/resources/org/apache/poi/schemas/OpenPackagingConventions-XMLSchema.zip"/> <property name="ooxml.security.src.dir" location="build/ooxml-security-src"/> - <property name="ooxml.security.src.jar" location="${ooxml.lib}/ooxml-security-1.1-sources.jar"/> - <property name="ooxml.security.jar" location="${ooxml.lib}/ooxml-security-1.1.jar"/> <property name="ooxml.security.xsd.dir" location="src/ooxml/resources/org/apache/poi/poifs/crypt"/> <property name="ooxml.visio.xsd.dir" location="src/ooxml/resources/org/apache/poi/xdgf"/> <property name="ooxml.schema.xsdconfig.dir" location="src/ooxml/resources/org/apache/poi/schemas"/> @@ -375,7 +407,6 @@ under the License. <pathelement location="${ooxml.commons-compress.jar}"/> <path refid="main.classpath"/> <pathelement location="${main.output.dir}"/> - <pathelement location="${ooxml.security.jar}"/> <pathelement location="${ooxml.test.guava.jar}"/> <!-- classes are omitted on test cases outside the xml-dsign area to avoid classpath poisioning --> <!--path refid="ooxml.xmlsec.classpath"/--> @@ -389,18 +420,8 @@ under the License. <pathelement location="${svg.xmlgraphics-commons.jar}"/> </path> - <path id="ooxml-lite.classpath"> - <path refid="ooxml.base.classpath"/> - <!-- instead of ooxml-xsds.jar use the filtered classes--> - <pathelement location="${ooxml.lite.jar}"/> - <pathelement location="${ooxml.output.dir}"/> - <pathelement location="${ooxml.output.test.dir}"/> - <pathelement location="${main.output.test.dir}"/> - <path refid="batik.classpath"/> - </path> - <path id="ooxml.classpath"> - <pathelement location="${ooxml.xsds.jar}"/> + <pathelement location="${ooxml.xsds.jar}"/> <path refid="ooxml.base.classpath"/> <path refid="batik.classpath"/> </path> @@ -410,38 +431,12 @@ under the License. <path refid="ooxml.base.classpath"/> </path> - <path id="test.classpath"> - <path refid="main.classpath"/> - <pathelement location="${main.output.dir}"/> - <pathelement location="${main.output.test.dir}"/> - <pathelement location="${additionaljar}"/> - </path> - - <path id="test.scratchpad.classpath"> - <path refid="scratchpad.classpath"/> - <pathelement location="${main.output.test.dir}"/> - <pathelement location="${scratchpad.output.dir}"/> - <pathelement location="${scratchpad.output.test.dir}"/> - <pathelement location="${additionaljar}"/> - </path> - <path id="test.ooxml.reflections.classpath"> <pathelement location="${ooxml.test.reflections.jar}"/> <pathelement location="${ooxml.test.guava.jar}"/> <pathelement location="${ooxml.test.javassist.jar}"/> </path> - <path id="test.ooxml.classpath"> - <path refid="ooxml.classpath"/> - <path refid="ooxml.xmlsec.classpath"/> - <path refid="test.jar.classpath"/> - <path refid="test.ooxml.reflections.classpath"/> - <pathelement location="${ooxml.output.dir}"/> - <pathelement location="${ooxml.output.test.dir}"/> - <pathelement location="${main.output.test.dir}"/> - <pathelement location="${additionaljar}"/> - </path> - <path id="test.ooxml.lite.verify.classpath"> <path refid="ooxml.lite.verify.classpath"/> <path refid="ooxml.xmlsec.classpath"/> @@ -452,17 +447,6 @@ under the License. <pathelement location="${additionaljar}"/> </path> - <path id="test.integration.classpath"> - <pathelement location="${integration.src.test}"/> - <path refid="scratchpad.classpath"/> - <path refid="ooxml.classpath"/> - <path refid="test.jar.classpath"/> - <pathelement location="${main.output.test.dir}"/> - <pathelement location="${ooxml.output.dir}"/> - <pathelement location="${integration.output.test.dir}"/> - <pathelement location="${examples.output.dir}"/> - </path> - <path id="examples.classpath"> <path refid="main.classpath"/> <pathelement location="${main.output.dir}"/> @@ -475,16 +459,6 @@ under the License. <pathelement location="${ooxml.output.dir}"/> </path> - <path id="test.excelant.classpath"> - <path refid="ooxml.classpath"/> - <path refid="test.jar.classpath"/> - <pathelement location="${ooxml.output.dir}"/> - <pathelement location="${excelant.output.dir}"/> - <pathelement location="${excelant.output.test.dir}"/> - <pathelement location="${main.output.test.dir}"/> - <pathelement location="${additionaljar}"/> - </path> - <path id="javadoc.classpath"> <path refid="main.classpath"/> <path refid="scratchpad.classpath"/> @@ -494,26 +468,6 @@ under the License. <path path="${env.CLASSPATH}"/> </path> - <path id="forbiddenapis.classpath"> - <path refid="main.classpath"/> - <path refid="test.jar.classpath"/> - <path refid="scratchpad.classpath"/> - <path refid="ooxml.classpath"/> - <path refid="ooxml.xmlsec.classpath"/> - <path refid="test.ooxml.reflections.classpath"/> - <path refid="excelant.classpath"/> - <path refid="examples.classpath"/> - <pathelement location="${examples.output.dir}"/> - <path path="${env.CLASSPATH}"/> - </path> - - <path id="lib.jacoco"> - <fileset dir="${util.lib}"> - <include name="org.jacoco*.jar" /> - <include name="asm-*.jar" /> - </fileset> - </path> - <patternset id="exclude-scratchpad-test"> <exclude name="**/TestExtractorFactory.java"/> <exclude name="**/TestEmbedOLEPackage.java"/> @@ -531,7 +485,6 @@ under the License. - compile Compile all files from main, ooxml and scratchpad - test Run all unit tests from main, ooxml and scratchpad - jar Produce jar files - - jar-src Produce source-jar files - assemble Produce the zipped distribution files - site Generate all documentation (Requires Apache Forrest) - dist Create a distribution (Requires Apache Forrest) @@ -610,14 +563,17 @@ under the License. <delete verbose="true" failonerror="false"> <fileset dir="${basedir}/lib" includes="*.jar"/> - <fileset dir="${basedir}/lib/util"> - <include name="asm*7.2.jar"/> + <fileset dir="${basedir}/lib/main-tests"> + <include name="mockito-core-3.2.4.jar"/> </fileset> <fileset dir="${basedir}/lib/ooxml"> <include name="xmlbeans-3.1.0.jar"/> </fileset> - <fileset dir="${basedir}/lib/main-tests"> - <include name="mockito-core-3.2.4.jar"/> + <fileset dir="${basedir}/lib/ooxml-tests"> + <include name="guava-20.0.jar"/> + </fileset> + <fileset dir="${basedir}/lib/util"> + <include name="asm*7.2.jar"/> </fileset> </delete> @@ -719,6 +675,7 @@ under the License. <target name="fetch-ooxml-jars" depends="check-ooxml-jars" unless="ooxml.jars.present"> <mkdir dir="${ooxml.lib}"/> <mkdir dir="${ooxml-tests.lib}"/> +<!-- <downloadfile src="${ooxml.xml-apis.url}" dest="${ooxml.xml-apis.jar}"/>--> <downloadfile src="${ooxml.curvesapi.url}" dest="${ooxml.curvesapi.jar}"/> <downloadfile src="${ooxml.xmlbeans.url}" dest="${ooxml.xmlbeans.jar}"/> <downloadfile src="${ooxml.commons-compress.url}" dest="${ooxml.commons-compress.jar}"/> @@ -760,296 +717,358 @@ under the License. <and> <available file="${ooxml.xsds.jar}"/> <available file="${ooxml.xsds.src.jar}"/> - <available file="${ooxml.security.jar}"/> - <available file="${ooxml.security.src.jar}"/> </and> </condition> </target> - <macrodef name="compile-ooxml-xmlbean"> - <attribute name="classes-jar"/> - <attribute name="sources-jar"/> - <attribute name="noupa" default="false"/> - <attribute name="nopvr" default="false"/> - <attribute name="multi-src"/> - <attribute name="typesystemname"/> - <element name="xsds"/> - <sequential> - <!-- We need a fair amount of memory to compile the xml schema, --> - <!-- but limit it in case it goes wrong! --> - <!-- Pick the right amount based on 32 vs 64 bit jvm --> - <condition property="ooxml.memory" value="1536m" else="1024m"> - <equals arg1="${sun.arch.data.model}" arg2="64" /> - </condition> + <target name="compile-ooxml-xsds" + depends="init,check-compiled-ooxml-xsds" + unless="ooxml-compiled-xsds.present" + description="Unpacks the OOXML xsd files, and compiles them into XmlBeans"> - <taskdef name="xmlbean" - classname="org.apache.xmlbeans.impl.tool.XMLBean" - classpath="${ooxml.xmlbeans.jar}"/> + <local name="ooxml.memory"/> - <property name="xmlbean.xsds.dir" location="build/xmlbean-xsds"/> - <property name="xmlbean.sources.dir" location="build/xmlbean-sources"/> - <property name="xmlbean.classes.dir" location="build/xmlbean-classes"/> + <!-- We need a fair amount of memory to compile the xml schema, --> + <!-- but limit it in case it goes wrong! --> + <!-- Pick the right amount based on 32 vs 64 bit jvm --> + <condition property="ooxml.memory" value="1536m" else="1024m"> + <equals arg1="${sun.arch.data.model}" arg2="64" /> + </condition> - <delete dir="${xmlbean.xsds.dir}"/> - <mkdir dir="${xmlbean.xsds.dir}"/> - <delete dir="${xmlbean.sources.dir}"/> - <mkdir dir="${xmlbean.sources.dir}"/> - <delete dir="${xmlbean.classes.dir}"/> - <mkdir dir="${xmlbean.classes.dir}"/> + <local name="xmlbean.xsds.dir"/> + <property name="xmlbean.xsds.dir" location="build/xmlbean-xsds"/> + <mkdir dir="${xmlbean.xsds.dir}"/> + + <copy todir="${xmlbean.xsds.dir}"> + <zipfileset src="${ooxml.xsds.izip.1}"/> + <fileset dir="${ooxml.visio.xsd.dir}"/> + <fileset dir="${ooxml.schema.xsdconfig.dir}" includes="ooxmlSchemas.xsdconfig,markup-compatibility.xsd"/> + <zipfileset src="${ooxml.xsds.izip.2}" includes="opc-digSig.xsd,opc-relationships.xsd"/> + <fileset dir="${ooxml.security.xsd.dir}" includes="signatureInfo.xsd"/> + <fileset dir="${ooxml.schema.xsdconfig.dir}" includes="XAdES*.xsd,*.xsdconfig,xmldsig*.xsd"/> + </copy> - <copy todir="${xmlbean.xsds.dir}"> - <xsds/> - </copy> + <local name="xmlbean.sources.dir"/> + <local name="xmlbean.classes.dir"/> + <property name="xmlbean.sources.dir" location="build/xmlbean-sources"/> + <property name="xmlbean.classes.dir" location="build/xmlbean-classes"/> + <mkdir dir="${xmlbean.sources.dir}"/> + <mkdir dir="${xmlbean.classes.dir}"/> + + <taskdef name="xmlbean" + classname="org.apache.xmlbeans.impl.tool.XMLBean" + classpath="${ooxml.xmlbeans.jar}"/> + + <!-- javasource > 1.5 will not generate all array accessor --> + <xmlbean + schema="${xmlbean.xsds.dir}" + srcgendir="${xmlbean.sources.dir}" + classgendir="${xmlbean.classes.dir}" + destfile="${xmlbean.xsds.dir}.jar" + srconly="true" + javasource="1.5" + failonerror="true" + fork="true" + memoryMaximumSize="${ooxml.memory}" + typesystemname="ooxml" + repackage="org.apache.xmlbeans.metadata:org.apache.poi.schemas.ooxml"> + <classpath> + <path location="${ooxml.xmlbeans.jar}"/> + </classpath> + </xmlbean> - <!-- javasource > 1.5 will not generate all array accessor --> - <xmlbean - schema="${xmlbean.xsds.dir}" - srcgendir="${xmlbean.sources.dir}" - classgendir="${xmlbean.classes.dir}" - destfile="${xmlbean.xsds.dir}.jar" - srconly="true" - javasource="1.5" - failonerror="true" - fork="true" - memoryMaximumSize="${ooxml.memory}" - noupa="@{noupa}" - nopvr="@{nopvr}" - typesystemname="@{typesystemname}" - repackage="org.apache.xmlbeans.metadata:org.apache.poi.schemas.@{typesystemname}" - > - <classpath> - <path location="${ooxml.xmlbeans.jar}"/> - </classpath> - </xmlbean> + <javac release="8" + target="${jdk.version.class}" + source="${jdk.version.source}" + srcdir="${xmlbean.sources.dir}" + destdir="${xmlbean.classes.dir}" + encoding="${java.source.encoding}" + fork="yes" + debug="${compile.debug}" + memoryMaximumSize="${ooxml.memory}" + includeantruntime="false"> + <classpath refid="ooxml.classpath"/> + </javac> + + <javac release="9" + srcdir="${basedir}/src/multimodule/ooxml-schemas/java9" + destdir="${basedir}/src/multimodule/ooxml-schemas/java9" + includeantruntime="false" + fork="true" + modulepath="lib/ooxml" + unless:true="${isJava8}"> + <compilerarg line="--patch-module org.apache.poi.ooxml.schemas=${xmlbean.classes.dir}"/> + </javac> + + <mkdir dir="build/dist/maven/ooxml-schemas"/> + + <jar destfile="${ooxml.xsds.jar}"> + <fileset dir="${xmlbean.classes.dir}"/> + <zipfileset dir="${basedir}/src/multimodule/ooxml-schemas/java9" prefix="META-INF/versions/9" excludes="*.java"/> + <metainf dir="legal/"/> + <manifest> + <attribute name="Multi-Release" value="true"/> + <attribute name="Automatic-Module-Name" value="org.apache.poi.ooxml.schemas"/> + <attribute name="Built-By" value="${user.name}"/> + <attribute name="Specification-Title" value="Apache POI OOXML Schemas"/> + <attribute name="Specification-Version" value="${maven.ooxml.xsds.version.id}"/> + <attribute name="Specification-Vendor" value="The Apache Software Foundation"/> + <attribute name="Implementation-Title" value="Apache POI OOXML Schemas"/> + <attribute name="Implementation-Version" value="${version.id}"/> + <attribute name="Implementation-Vendor-Id" value="org.apache.poi"/> + <attribute name="Implementation-Vendor" value="The Apache Software Foundation"/> + </manifest> + </jar> + + <jar destfile="${ooxml.xsds.src.jar}"> + <fileset dir="${xmlbean.sources.dir}"/> + <zipfileset dir="${basedir}/src/multimodule/ooxml-schemas/java9" prefix="META-INF/versions/9/" excludes="*.class"/> + <metainf dir="legal"/> + </jar> + </target> + + <target name="compile" depends="init, compile-main, + compile-scratchpad, compile-examples, compile-excelant" + description="Compiles the POI main classes, scratchpad and examples"/> - <echo>Forking javac with max heap size ${ooxml.memory}</echo> + <macrodef name="compile-jar"> + <attribute name="module"/> + <attribute name="java"/> + <attribute name="classes"/> + <attribute name="test" default=""/> + <attribute name="test-classes" default=""/> + <attribute name="version" default="${version.id}"/> + <element name="lib"/> + <element name="resources" optional="true"/> + <element name="test-resources" optional="true"/> + <sequential> + <local name="cp_java"/> + <pathconvert property="cp_java" pathsep=","> + <path><lib/></path> + <regexpmapper from="^${basedir}[/\\](.*)$" to="\1/*.jar"/> + </pathconvert> - <javac target="${jdk.version.class}" + <local name="maven-name"/> + <loadresource property="maven-name"> + <string>@{module}</string> + <filterchain> + <prefixlines prefix="poi-"/> + <replacestring from="poi-poi" to="poi"/> + </filterchain> + </loadresource> + + <!-- compile the sources --> + <javac release="8" + target="${jdk.version.class}" source="${jdk.version.source}" - srcdir="${xmlbean.sources.dir}" - destdir="${xmlbean.classes.dir}" + destdir="@{classes}" + srcdir="@{java}" + debug="${compile.debug}" encoding="${java.source.encoding}" fork="yes" - optimize="true" - memoryMaximumSize="${ooxml.memory}" includeantruntime="false"> - <classpath refid="ooxml.classpath"/> + <classpath> + <fileset dir="${basedir}" includes="${cp_java}"/> + </classpath> </javac> - <local name="module-package"/> - <loadfile property="module-package" srcFile="@{multi-src}/java9/module-info.java"> - <filterchain> - <containsregex pattern=".*module ([^ ]+).*" replace="\1" flags="i"/> - <striplinebreaks/> - </filterchain> - </loadfile> - - <mkdir dir="${xmlbean.classes.dir}/META-INF/versions/9"/> - + <!-- compile jigsaw files to sources, so we don't forget to update/provide them for Java 8 builds --> <javac release="9" - srcdir="@{multi-src}/java9" - destdir="${xmlbean.classes.dir}/META-INF/versions/9" + srcdir="${basedir}/src/multimodule/@{module}/java9" + destdir="${basedir}/src/multimodule/@{module}/java9" includeantruntime="false" fork="true" - modulepath="${ooxml.lib}" unless:true="${isJava8}"> - <compilerarg line="--patch-module ${module-package}=${xmlbean.classes.dir}"/> + <compilerarg line="--patch-module org.apache.poi.@{module}=@{classes}"/> + <modulepath> + <lib/> + </modulepath> </javac> - <delete file="@{classes-jar}"/> - <delete file="@{sources-jar}"/> + <mkdir dir="build/dist/maven/${maven-name}"/> - <jar destfile="@{classes-jar}" level="9"> - <fileset dir="${xmlbean.classes.dir}"/> - <zipfileset prefix="META-INF/versions/9/" dir="@{multi-src}/java9" includes="**/*.class" if:true="${isJava8}"/> - <metainf dir="legal"/> + <!-- create classes jar --> + <jar destfile="build/dist/maven/${maven-name}/${maven-name}-@{version}.jar"> + <fileset dir="@{classes}"/> + <resources/> + <zipfileset dir="${basedir}/src/multimodule/@{module}/java9" + prefix="META-INF/versions/9" + excludes="*.java"/> + <metainf dir="legal/"/> <manifest> <attribute name="Multi-Release" value="true"/> + <attribute name="Automatic-Module-Name" value="org.apache.poi.@{module}"/> + <attribute name="Built-By" value="${user.name}"/> + <attribute name="Specification-Title" value="Apache POI"/> + <attribute name="Specification-Version" value="${version.id}"/> + <attribute name="Specification-Vendor" value="The Apache Software Foundation"/> + <attribute name="Implementation-Title" value="Apache POI"/> + <attribute name="Implementation-Version" value="${version.id}"/> + <attribute name="Implementation-Vendor-Id" value="org.apache.poi"/> + <attribute name="Implementation-Vendor" value="The Apache Software Foundation"/> </manifest> </jar> - <jar destfile="@{sources-jar}" level="9"> - <fileset dir="${xmlbean.sources.dir}"/> - <zipfileset prefix="META-INF/versions/9/" dir="@{multi-src}/java9" excludes="**/*.class"/> - <metainf dir="legal"/> - </jar> - - <delete file="${xmlbean.xsds.dir}.jar"/> - <delete dir="${xmlbean.xsds.dir}"/> - <delete dir="${xmlbean.sources.dir}"/> - <delete dir="${xmlbean.classes.dir}"/> - </sequential> - </macrodef> - <target name="compile-ooxml-xsds" - depends="init,check-compiled-ooxml-xsds" - unless="ooxml-compiled-xsds.present" - description="Unpacks the OOXML xsd files, and compiles them into XmlBeans"> - <compile-ooxml-xmlbean - classes-jar="${ooxml.xsds.jar}" - sources-jar="${ooxml.xsds.src.jar}" - multi-src="${basedir}/src/multimodule/ooxml-schemas" - typesystemname="ooxml" - > - <xsds> - <zipfileset src="${ooxml.xsds.izip.1}"/> - <fileset dir="${ooxml.visio.xsd.dir}"/> - <fileset dir="${ooxml.schema.xsdconfig.dir}" includes="ooxmlSchemas.xsdconfig,markup-compatibility.xsd"/> - </xsds> - </compile-ooxml-xmlbean> - <!-- Now do the same for the security schemas --> - <compile-ooxml-xmlbean - classes-jar="${ooxml.security.jar}" - sources-jar="${ooxml.security.src.jar}" - multi-src="${basedir}/src/multimodule/ooxml-security" - typesystemname="security" - > - <xsds> - <zipfileset src="${ooxml.xsds.izip.2}" includes="opc-digSig.xsd,opc-relationships.xsd"/> - <fileset dir="${ooxml.security.xsd.dir}"/> - <fileset dir="${ooxml.schema.xsdconfig.dir}" includes="XAdES*.xsd,*.xsdconfig,xmldsig*.xsd"/> - </xsds> - </compile-ooxml-xmlbean> - </target> + <!-- compile the tests --> + <javac release="8" + target="${jdk.version.class}" + source="${jdk.version.source}" + destdir="@{test-classes}" + srcdir="@{test}" + debug="${compile.debug}" + encoding="${java.source.encoding}" + fork="yes" + includeantruntime="false" unless:blank="@{test}"> + <classpath> + <fileset dir="${basedir}" includes="${cp_java}"/> + <pathelement path="build/dist/maven/${maven-name}/${maven-name}-@{version}.jar"/> + </classpath> + </javac> - <target name="compile" depends="init, compile-main, - compile-scratchpad, compile-examples, compile-excelant" - description="Compiles the POI main classes, scratchpad and examples"/> + <!-- again, generate jigsaw files to sources ... --> + <local name="merged"/> + <pathconvert property="merged"> + <path location="@{classes}"/> + <path location="@{test-classes}"/> + </pathconvert> - <target name="compile-main" depends="init"> - <!-- compile the sources --> - <javac target="${jdk.version.class}" - source="${jdk.version.source}" - destdir="${main.output.dir}" - srcdir="${main.src}" - debug="${compile.debug}" - encoding="${java.source.encoding}" - fork="yes" - includeantruntime="false"> - <classpath refid="main.classpath"/> - </javac> - <!-- compile the tests --> - <javac target="${jdk.version.class}" - source="${jdk.version.source}" - destdir="${main.output.test.dir}" - srcdir="${main.src.test}" - debug="${compile.debug}" - encoding="${java.source.encoding}" - fork="yes" - includeantruntime="false"> - <classpath> - <path refid="main.classpath"/> - <path refid="test.jar.classpath"/> - <pathelement path="${main.output.dir}"/> - </classpath> - </javac> - <copy todir="${main.output.dir}"> - <fileset dir="${main.resource1.dir}"/> - </copy> + <javac release="9" + srcdir="${basedir}/src/multimodule/@{module}/test9" + destdir="${basedir}/src/multimodule/@{module}/test9" + includeantruntime="false" + fork="true" + unless:true="${isJava8}" unless:blank="@{test}"> + <compilerarg line="--patch-module org.apache.poi.@{module}=${merged}"/> + <modulepath> + <lib/> + </modulepath> + </javac> + <!-- create test classes jar - using the module-info of the tests --> + <jar destfile="build/dist/maven/${maven-name}-tests/${maven-name}-@{version}-tests.jar" unless:blank="@{test}"> + <fileset dir="@{classes}"/> + <fileset dir="@{test-classes}"> + <exclude name="org/apache/poi/ooxml/lite/**"/> + </fileset> + <resources/> + <test-resources/> + <zipfileset dir="${basedir}/src/multimodule/@{module}/test9" prefix="META-INF/versions/9" excludes="*.java"/> + <metainf dir="legal/"/> + <manifest> + <attribute name="Multi-Release" value="true"/> + <attribute name="Automatic-Module-Name" value="org.apache.poi.@{module}"/> + <attribute name="Built-By" value="${user.name}"/> + <attribute name="Specification-Title" value="Apache POI"/> + <attribute name="Specification-Version" value="${version.id}"/> + <attribute name="Specification-Vendor" value="The Apache Software Foundation"/> + <attribute name="Implementation-Title" value="Apache POI"/> + <attribute name="Implementation-Version" value="${version.id}"/> + <attribute name="Implementation-Vendor-Id" value="org.apache.poi"/> + <attribute name="Implementation-Vendor" value="The Apache Software Foundation"/> + </manifest> + </jar> - <mkdir dir="${main.output.dir}/META-INF/versions/9"/> + <!-- create the sources jar --> + <jar destfile="build/dist/maven/${maven-name}/${maven-name}-@{version}-sources.jar"> + <fileset dir="@{java}"/> + <metainf dir="legal/"/> +<!-- <resources/>--> +<!-- <zipfileset dir="src/multimodule/@{module}/java9" prefix="META-INF/versions/9" excludes="*.class"/>--> + <manifest> + <attribute name="Built-By" value="${user.name}"/> + <attribute name="Specification-Title" value="Apache POI"/> + <attribute name="Specification-Version" value="${version.id}"/> + <attribute name="Specification-Vendor" value="The Apache Software Foundation"/> + <attribute name="Implementation-Title" value="Apache POI"/> + <attribute name="Implementation-Version" value="${version.id}"/> + <attribute name="Implementation-Vendor-Id" value="org.apache.poi"/> + <attribute name="Implementation-Vendor" value="The Apache Software Foundation"/> + </manifest> + </jar> + </sequential> + </macrodef> - <javac release="9" - srcdir="${basedir}/src/multimodule/poi/java9" - destdir="${main.output.dir}/META-INF/versions/9" - includeantruntime="false" - fork="true" - modulepath="${main.lib}" - unless:true="${isJava8}"> - <compilerarg line="--patch-module org.apache.poi.poi=${main.output.dir}"/> - </javac> + <target name="compile-main" depends="init, compile-version"> + <compile-jar module="poi" + java="${main.src}" classes="${main.output.dir}" + test="${main.src.test}" test-classes="${main.output.test.dir}"> + <lib> + <pathelement path="lib/main"/> + <pathelement path="lib/main-tests"/> + </lib> + <resources> + <fileset dir="${main.resource1.dir}"/> + </resources> + </compile-jar> </target> <target name="compile-scratchpad" depends="compile-main"> - <!-- compile the sources --> - <javac target="${jdk.version.class}" - source="${jdk.version.source}" - destdir="${scratchpad.output.dir}" - srcdir="${scratchpad.src}" - debug="${compile.debug}" - encoding="${java.source.encoding}" - fork="yes" - includeantruntime="false"> - <classpath refid="scratchpad.classpath"/> - </javac> - <!-- compile the tests --> - <javac target="${jdk.version.class}" - source="${jdk.version.source}" - destdir="${scratchpad.output.test.dir}" - srcdir="${scratchpad.src.test}" - debug="${compile.debug}" - encoding="${java.source.encoding}" - fork="yes" - includeantruntime="false"> - <classpath> - <path refid="scratchpad.classpath"/> - <path refid="test.jar.classpath"/> - <pathelement location="${scratchpad.output.dir}"/> - <pathelement location="${main.output.test.dir}"/> - </classpath> - </javac> - <copy todir="${scratchpad.output.dir}"> - <fileset dir="${scratchpad.resource1.dir}"/> - </copy> + <compile-jar module="scratchpad" + java="${scratchpad.src}" classes="${scratchpad.output.dir}" + test="${scratchpad.src.test}" test-classes="${scratchpad.output.test.dir}"> + <lib> + <pathelement path="build/dist/maven/poi-tests"/> + <pathelement path="lib/main"/> + <pathelement path="lib/main-tests"/> + </lib> + <resources> + <fileset dir="${scratchpad.resource1.dir}"/> + </resources> + </compile-jar> </target> <target name="compile-examples" depends="compile-main,compile-scratchpad,compile-ooxml"> - <javac target="${jdk.version.class}" - source="${jdk.version.source}" - destdir="${examples.output.dir}" - srcdir="${examples.src}" - debug="${compile.debug}" - encoding="${java.source.encoding}" - fork="yes" - includeantruntime="false"> - <classpath> - <path refid="ooxml.classpath"/> - <pathelement path="${ooxml.output.dir}"/> - <pathelement location="${scratchpad.output.dir}"/> - </classpath> - </javac> - <copy todir="${examples.output.dir}"> - <fileset dir="${examples.src}"> - <include name="**/*.css"/> - </fileset> - </copy> + <compile-jar module="examples" + java="${examples.src}" classes="${examples.output.dir}"> + <lib> + <pathelement path="build/dist/maven/ooxml-schemas"/> + <pathelement path="build/dist/maven/poi-tests"/> + <pathelement path="build/dist/maven/poi-scratchpad-tests"/> + <pathelement path="build/dist/maven/poi-ooxml-tests"/> + <pathelement path="lib/main"/> + <pathelement path="lib/ooxml"/> + </lib> + </compile-jar> </target> <target name="compile-ooxml" depends="compile-main,compile-scratchpad,compile-ooxml-xsds"> - <!-- compile the sources --> - <javac target="${jdk.version.class}" - source="${jdk.version.source}" - destdir="${ooxml.output.dir}" - srcdir="${ooxml.src}" - debug="${compile.debug}" - encoding="${java.source.encoding}" - fork="yes" - includeantruntime="false"> - <classpath> - <path refid="ooxml.classpath"/> - <path refid="ooxml.xmlsec.classpath"/> - </classpath> - </javac> - <!-- compile the tests --> - <javac target="${jdk.version.class}" - source="${jdk.version.source}" - destdir="${ooxml.output.test.dir}" - srcdir="${ooxml.src.test}" - debug="${compile.debug}" - encoding="${java.source.encoding}" - fork="yes" - includeantruntime="false"> - <classpath> - <path refid="ooxml.classpath"/> - <path refid="ooxml.xmlsec.classpath"/> - <path refid="test.ooxml.classpath"/> - <pathelement path="${ooxml.output.dir}"/> - <pathelement path="${main.output.test.dir}"/> - </classpath> + <compile-jar module="ooxml" + java="${ooxml.src}" classes="${ooxml.output.dir}" + test="${ooxml.src.test}" test-classes="${ooxml.output.test.dir}"> + <lib> + <pathelement path="build/dist/maven/poi-tests"/> + <pathelement path="build/dist/maven/poi-scratchpad-tests"/> + <pathelement path="build/dist/maven/ooxml-schemas"/> + <pathelement path="lib/main"/> + <pathelement path="lib/main-tests"/> + <pathelement path="lib/ooxml"/> + <pathelement path="lib/ooxml-provided"/> + <pathelement path="lib/ooxml-tests"/> + </lib> + <resources> + <fileset dir="${ooxml.resource1.dir}"/> + </resources> + </compile-jar> + + <!-- create ooxml-lite-agent jar --> + <javac release="9" + srcdir="${basedir}/src/multimodule/ooxml-lite-agent/java9" + destdir="${basedir}/src/multimodule/ooxml-lite-agent/java9" + includeantruntime="false" + fork="true" + unless:true="${isJava8}"> + <compilerarg line="--patch-module org.apache.poi.ooxml_lite=${ooxml.output.test.dir}"/> </javac> - <copy todir="${ooxml.output.dir}"> - <fileset dir="${ooxml.resource1.dir}"/> - </copy> + + <jar destfile="${ooxml.lite.agent}"> + <fileset dir="${ooxml.output.test.dir}" includes="org/apache/poi/ooxml/lite/**"/> + <zipfileset dir="${basedir}/src/multimodule/ooxml-lite-agent/java9" prefix="META-INF/versions/9" excludes="*.java"/> + <manifest> + <attribute name="Multi-Release" value="true"/> + <attribute name="Automatic-Module-Name" value="org.apache.poi.ooxml_lite"/> + <attribute name="Premain-Class" value="org.apache.poi.ooxml.lite.OOXMLLiteAgent"/> + </manifest> + </jar> </target> <macrodef name="poiunit" xmlns:jacoco="antlib:org.jacoco.ant"> @@ -1057,103 +1076,82 @@ under the License. <attribute name="heap" default="512"/> <attribute name="showoutput" default="false"/> <attribute name="jacocodest" default="build/jacoco-dest.exec"/> + <attribute name="modulepath-ref"/> <element name="elements" implicit="true"/> <sequential> <local name="no.jit.sherlock"/> <!-- see http://www-01.ibm.com/support/docview.wss?uid=swg21294023 on how to determine the method strings --> - <property name="no.jit.sherlock"> - 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; - </property> - <script language="javascript"> - var before = project.getProperty("no.jit.sherlock"); - project.setProperty("no.jit.sherlock", before.trim().replace(/ *(\S+) */g,"exclude={$1}").replace(/\s/g,",")); - </script> + <loadresource property="no.jit.sherlock"> + <string> + 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; + </string> + <filterchain> + <trim/> + <ignoreblank/> + <prefixlines prefix=",exclude={"/> + <suffixlines suffix="}"/> + <striplinebreaks/> + </filterchain> + </loadresource> <local name="ooxml.lite.agent.exists"/> <available property="ooxml.lite.agent.exists" file="${ooxml.lite.agent}"/> + <local name="cp_java"/> + <pathconvert property="cp_java" pathsep=","> + <path refid="@{modulepath-ref}"/> + <regexpmapper from="^${basedir}[/\\](.*)$" to="\1/*.jar"/> + </pathconvert> + <jacoco:coverage enabled="${coverage.enabled}" excludes="${coverage.excludes}" destfile="@{jacocodest}"> <junit printsummary="yes" fork="yes" forkmode="once" haltonfailure="${halt.on.test.failure}" - failureproperty="@{failureproperty}" showoutput="@{showoutput}"> + failureproperty="@{failureproperty}" showoutput="@{showoutput}" filtertrace="off"> <syspropertyset refid="junit.properties"/> <sysproperty key="java.io.tmpdir" value="${tempdir}"/> <jvmarg value="-Xmx@{heap}M"/> <jvmarg value="-ea"/> - <!-- some "add-opens" are needed for Java 10, but not for 11+ --> - <jvmarg value="--add-modules=java.xml.bind" if:true="${addOpens10}" /> - <jvmarg value="--add-opens=java.base/java.lang=java.xml.bind" if:true="${addOpens10}" /> - <!-- some "add-opens" and other properties are needed when running with Java 9 or newer --> <sysproperty key="sun.reflect.debugModuleAccessChecks" value="true" if:true="${addOpens}" /> <sysproperty key="com.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize" value="true" if:true="${addOpens}" /> <jvmarg value="--illegal-access=warn" if:true="${addOpens}" /> - <jvmarg value="--add-opens=java.xml/com.sun.org.apache.xerces.internal.util=ALL-UNNAMED" if:true="${addOpens}" /> - <jvmarg value="--add-opens=java.base/java.io=ALL-UNNAMED" if:true="${addOpens}" /> - <jvmarg value="--add-opens=java.base/java.nio=ALL-UNNAMED" if:true="${addOpens}" /> - <jvmarg value="--add-opens=java.base/java.lang=ALL-UNNAMED" if:true="${addOpens}" /> - <jvmarg value="--add-opens=java.base/jdk.internal.ref=ALL-UNNAMED" if:true="${addOpens}" /> - <jvmarg value="-javaagent:${ooxml.lite.agent}=${ooxml.lite.report}|${ooxml.lite.includes}" if:true="${ooxml.lite.agent.exists}"/> <!-- jvmarg value="-Duser.timezone=UTC"/ --> <jvmarg value="${file.leak.detector}" /> - <jvmarg value="-Xjit:verbose={compileStart|compileEnd},vlog=build/jit.log,${no.jit.sherlock}" if:true="${isIBMVM}"/> + <jvmarg value="-Xjit:verbose={compileStart|compileEnd},vlog=build/jit.log${no.jit.sherlock}" if:true="${isIBMVM}"/> <formatter type="plain"/> <formatter type="xml"/> + <modulepath refid="@{modulepath-ref}" unless:true="${isJava8}"/> + <classpath if:true="${isJava8}"> + <fileset dir="${basedir}" includes="${cp_java}"/> + </classpath> <elements/> </junit> </jacoco:coverage> </sequential> </macrodef> - <target name="retest-ooxml" depends="jar"> - <delete dir="${ooxml.reports.test}"/> - <delete dir="${ooxml.output.test.dir}"/> - <mkdir dir="${ooxml.reports.test}"/> - <mkdir dir="${ooxml.output.test.dir}"/> - <!-- compile the sources --> - <javac target="${jdk.version.class}" - source="${jdk.version.source}" - destdir="${ooxml.output.dir}" - srcdir="${ooxml.src}" - debug="${compile.debug}" - encoding="${java.source.encoding}" - fork="yes" - includeantruntime="false"> - <classpath> - <path refid="ooxml.lite.verify.classpath"/> - <path refid="ooxml.xmlsec.classpath"/> - </classpath> - </javac> - <!-- compile the tests --> - <javac target="${jdk.version.class}" - source="${jdk.version.source}" - destdir="${ooxml.output.test.dir}" - srcdir="${ooxml.src.test}" - debug="${compile.debug}" - encoding="${java.source.encoding}" - fork="yes" - includeantruntime="false"> - <classpath> - <path refid="ooxml.classpath"/> - <path refid="ooxml.xmlsec.classpath"/> - <path refid="test.ooxml.lite.verify.classpath"/> - <pathelement path="${ooxml.output.dir}"/> - <pathelement path="${main.output.test.dir}"/> - </classpath> - </javac> - <copy todir="${ooxml.output.dir}"> - <fileset dir="${ooxml.resource1.dir}"/> - </copy> + <target name="retest-ooxml" depends="jar" + description="run ooxml tests with poi-ooxml-schemas (= lite schema)"> + <path id="restest.modules"> + <pathelement path="build/dist/maven/poi-tests"/> + <pathelement path="build/dist/maven/poi-scratchpad-tests"/> + <pathelement path="build/dist/maven/poi-ooxml-tests"/> + <pathelement path="build/dist/maven/poi-ooxml-schemas"/> + <pathelement path="lib/main"/> + <pathelement path="lib/main-tests"/> + <pathelement path="lib/ooxml"/> + <pathelement path="lib/ooxml-provided"/> + <pathelement path="lib/ooxml-tests"/> + </path> - <poiunit failureproperty="ooxml.test.failed" heap="768"> - <classpath> - <path refid="test.ooxml.lite.verify.classpath"/> - <path refid="test.jar.classpath"/> - </classpath> + <poiunit failureproperty="ooxml.test.failed" heap="768" + modulepath-ref="restest.modules"> + <jvmarg line="--add-modules org.apache.poi.ooxml" unless:true="${isJava8}"/> + <jvmarg line="--add-modules org.apache.poi.scratchpad" unless:true="${isJava8}"/> <batchtest todir="${ooxml.reports.test}"> <fileset dir="${ooxml.src.test}"> <include name="**/${testpattern}.java"/> @@ -1168,40 +1166,26 @@ under the License. </target> <target name="compile-excelant" depends="compile-main,compile-ooxml"> - <!-- compile the sources --> - <javac target="${jdk.version.class}" - source="${jdk.version.source}" - destdir="${excelant.output.dir}" - srcdir="${excelant.src}" - debug="${compile.debug}" - encoding="${java.source.encoding}" - fork="yes" - includeantruntime="false"> - <classpath refid="excelant.classpath"/> - </javac> - <!-- compile the tests --> - <javac target="${jdk.version.class}" - source="${jdk.version.source}" - destdir="${excelant.output.test.dir}" - srcdir="${excelant.src.test}" - debug="${compile.debug}" - encoding="${java.source.encoding}" - fork="yes" - includeantruntime="false"> - <classpath> - <path refid="excelant.classpath"/> - <path refid="test.jar.classpath"/> - <pathelement location="${excelant.output.dir}"/> - <pathelement path="${main.output.test.dir}"/> - </classpath> - </javac> - <copy todir="${excelant.output.dir}"> - <fileset dir="${excelant.resource.dir}"/> - </copy> + <compile-jar module="excelant" + java="${excelant.src}" classes="${excelant.output.dir}" + test="${excelant.src.test}" test-classes="${excelant.output.test.dir}"> + <lib> + <pathelement path="build/dist/maven/poi-tests"/> + <pathelement path="build/dist/maven/poi-scratchpad-tests"/> + <pathelement path="build/dist/maven/poi-ooxml-tests"/> + <pathelement path="lib/main"/> + <pathelement path="lib/main-tests"/> + <pathelement path="lib/excelant"/> + </lib> + <resources> + <fileset dir="${excelant.resource.dir}"/> + </resources> + </compile-jar> </target> <target name="compile-integration" depends="compile-scratchpad, compile-main, compile-ooxml, compile-examples"> - <javac target="${jdk.version.class}" + <javac release="8" + target="${jdk.version.class}" source="${jdk.version.source}" destdir="${integration.output.test.dir}" srcdir="${integration.src.test}" @@ -1221,9 +1205,37 @@ under the License. </classpath> <exclude name="**/HeapDump**" if:true="${isIBMVM}"/> </javac> - <!--copy todir="${integration.output.dir}"> - <fileset dir="${integration.resource1.dir}"/> - </copy--> + + + <mkdir dir="${integration.output.test.dir}/META-INF/versions/9"/> + + <javac release="9" + srcdir="${basedir}/src/multimodule/integration/java9" + destdir="${integration.output.test.dir}/META-INF/versions/9" + includeantruntime="false" + fork="true" + unless:true="${isJava8}"> + <compilerarg line="--patch-module org.apache.poi.stress=${integration.output.test.dir}"/> + <modulepath> + <pathelement path="build/dist/maven/poi"/> + <pathelement path="build/dist/maven/poi-ooxml"/> + <pathelement path="build/dist/maven/poi-scratchpad"/> + <pathelement path="build/dist/maven/poi-examples"/> + <pathelement path="${main.lib}"/> + <pathelement path="${main-tests.lib}"/> + <pathelement path="${ooxml.lib}"/> + <pathelement path="${ooxml-provided.lib}"/> + </modulepath> + </javac> + + <manifest file="build/poi-manifest.mf"> + <attribute name="Multi-Release" value="true"/> + <attribute name="Automatic-Module-Name" value="org.apache.poi.stress"/> + </manifest> + + <jar destfile="lib/ooxml-tests/poi-integration.jar" + basedir="${integration.output.test.dir}" + manifest="build/poi-manifest.mf"/> </target> <target name="-version-java-check"> @@ -1264,7 +1276,12 @@ under the License. <target name="jacocotask" depends=""> <echo message="Coverage reporting: ${coverage.enabled}"/> <taskdef uri="antlib:org.jacoco.ant" resource="org/jacoco/ant/antlib.xml"> - <classpath refid="lib.jacoco"/> + <classpath> + <fileset dir="${util.lib}"> + <include name="org.jacoco*.jar" /> + <include name="asm-*.jar" /> + </fileset> + </classpath> </taskdef> </target> @@ -1361,11 +1378,17 @@ under the License. <target name="test-main" unless="main.test.notRequired" depends="compile-main, -test-main-check,jacocotask" description="tests POI classes that deal with the Microsoft Office binary (BIFF8) file formats (excludes OOXML)"> - <poiunit failureproperty="main.test.failed" heap="256" showoutput="true" jacocodest="build/jacoco-main.exec"> - <classpath> - <path refid="test.classpath"/> - <path refid="test.jar.classpath"/> - </classpath> + + <path id="test-main.modules"> + <pathelement path="build/dist/maven/poi-tests"/> + <pathelement path="lib/main"/> + <pathelement path="lib/main-tests"/> + </path> + + <poiunit failureproperty="main.test.failed" heap="256" showoutput="true" jacocodest="build/jacoco-main.exec" + modulepath-ref="test-main.modules"> + <jvmarg line="--add-modules org.apache.poi.poi" unless:true="${isJava8}"/> + <batchtest todir="${main.reports.test}"> <fileset dir="${main.src.test}"> <include name="**/${testpattern}.java"/> @@ -1377,6 +1400,7 @@ under the License. </fileset> </batchtest> </poiunit> + <delete file="${main.testokfile}"/> <antcall target="-test-main-write-testfile"/> </target> @@ -1409,14 +1433,22 @@ under the License. </uptodate> </target> - <target name="test-scratchpad" depends="jacocotask,compile-main,compile-scratchpad,-test-scratchpad-check,test-scratchpad-download-resources" + + <target name="test-scratchpad" depends="jacocotask,compile-scratchpad,-test-scratchpad-check,test-scratchpad-download-resources" unless="scratchpad.test.notRequired" description="test non-OOXML scratchpad classes"> - <poiunit failureproperty="scratchpad.test.failed" heap="512" jacocodest="build/jacoco-scratchpad.exec"> - <classpath> - <path refid="test.scratchpad.classpath"/> - <path refid="test.jar.classpath"/> - </classpath> + + <path id="test-scratchpad.modules"> + <pathelement path="build/dist/maven/poi-tests"/> + <pathelement path="build/dist/maven/poi-scratchpad-tests"/> + <pathelement path="lib/main"/> + <pathelement path="lib/main-tests"/> + </path> + + <poiunit failureproperty="scratchpad.test.failed" heap="512" jacocodest="build/jacoco-scratchpad.exec" + modulepath-ref="test-scratchpad.modules"> + <jvmarg line="--add-modules org.apache.poi.scratchpad" unless:true="${isJava8}"/> + <batchtest todir="${scratchpad.reports.test}"> <fileset dir="${scratchpad.src.test}"> <include name="**/${testpattern}.java"/> @@ -1443,44 +1475,43 @@ under the License. </target> <macrodef name="ooxml-test-runner" xmlns:jacoco="antlib:org.jacoco.ant"> - <attribute name="classpath"/> + <attribute name="modulepath-ref"/> <attribute name="type"/> <sequential> - <poiunit failureproperty="ooxml.test.failed" heap="768" jacocodest="build/jacoco-@{type}.exec"> - <classpath> - <path refid="@{classpath}"/> - <path refid="test.jar.classpath"/> - </classpath> + <poiunit failureproperty="ooxml.test.failed" heap="768" jacocodest="build/jacoco-@{type}.exec" + modulepath-ref="@{modulepath-ref}"> + <jvmarg line="--add-modules org.apache.poi.ooxml" unless:true="${isJava8}"/> + <jvmarg line="--add-modules org.apache.poi.scratchpad" unless:true="${isJava8}"/> + <batchtest todir="${ooxml.reports.test}"> <fileset dir="${ooxml.src.test}"> <include name="**/${testpattern}.java"/> <exclude name="**/TestUnfixedBugs.java"/> <exclude name="**/All*Tests.java"/> - <exclude name="**/TestSignatureInfo.java"/> <exclude name="**/${testexcludepattern}.java"/> <patternset refid="exclude-scratchpad-test" if:true="${scratchpad.ignore}"/> </fileset> </batchtest> </poiunit> - - <poiunit failureproperty="ooxml.xmlsec.test.failed" heap="768" jacocodest="build/jacoco-@{type}-xmlsec.exec"> - <classpath> - <path refid="@{classpath}"/> - <path refid="test.jar.classpath"/> - <path refid="ooxml.xmlsec.classpath"/> - </classpath> - <batchtest todir="${ooxml.reports.test}"> - <fileset dir="${ooxml.src.test}"> - <include name="**/TestSignatureInfo.java"/> - </fileset> - </batchtest> - </poiunit> </sequential> </macrodef> - <target name="test-ooxml" depends="compile-main,compile-ooxml,-test-ooxml-check,jacocotask,-ooxml-lite-agent" unless="ooxml.test.notRequired" + <target name="test-ooxml" depends="compile-main,compile-ooxml,-test-ooxml-check,jacocotask" unless="ooxml.test.notRequired" description="test OOXML classes"> - <ooxml-test-runner classpath="test.ooxml.classpath" type="ooxml"/> + <path id="test-ooxml.modules"> + <!-- full schema --> + <pathelement path="build/dist/maven/ooxml-schemas"/> + <pathelement path="build/dist/maven/poi-tests"/> + <pathelement path="build/dist/maven/poi-ooxml-tests"/> + <pathelement path="build/dist/maven/poi-scratchpad-tests"/> + <pathelement path="lib/main"/> + <pathelement path="lib/main-tests"/> + <pathelement path="lib/ooxml"/> + <pathelement path="lib/ooxml-provided"/> + <pathelement path="lib/ooxml-tests"/> + </path> + + <ooxml-test-runner modulepath-ref="test-ooxml.modules" type="ooxml"/> <delete file="${ooxml.testokfile}"/> <antcall target="-test-ooxml-write-testfile"/> </target> @@ -1496,12 +1527,28 @@ under the License. </uptodate> </target> - <target name="test-integration" depends="compile-integration,-test-integration-check,jacocotask,-ooxml-lite-agent" + <target name="test-integration" depends="compile-integration,-test-integration-check,jacocotask" unless="integration.test.notRequired"> <propertyreset name="org.apache.poi.util.POILogger" value="org.apache.poi.util.CommonsLogger"/> <delete dir="build" includes="test-integration.log*"/> - <poiunit failureproperty="integration.test.failed" heap="1512" showoutput="true" jacocodest="build/jacoco-integration.exec"> - <classpath refid="test.integration.classpath"/> + + <path id="test-integration.modules"> + <pathelement path="build/dist/maven/poi"/> + <pathelement path="build/dist/maven/poi-ooxml"/> + <pathelement path="build/dist/maven/poi-scratchpad"/> + <pathelement path="build/dist/maven/poi-examples"/> + <pathelement path="build/dist/maven/ooxml-schemas"/> + <pathelement path="lib/main"/> + <pathelement path="lib/main-tests"/> + <pathelement path="lib/ooxml"/> + <pathelement path="lib/ooxml-provided"/> + <pathelement path="lib/ooxml-tests"/> + </path> + + <poiunit failureproperty="integration.test.failed" heap="1512" showoutput="true" jacocodest="build/jacoco-integration.exec" + modulepath-ref="test-integration.modules"> + <jvmarg line="--add-modules org.apache.poi.stress" unless:true="${isJava8}"/> + <batchtest todir="${integration.reports.test}"> <fileset dir="${integration.src.test}"> <include name="**/${testpattern}.java"/> @@ -1520,41 +1567,97 @@ under the License. <!-- the ooxml lite agent collects referenced schema files while other junit tests are run, --> <!-- therefore its best to compile the ooxml lite jar after all usual tests are done --> - <target name="compile-ooxml-lite" depends="compile-ooxml,-ooxml-lite-agent,test-ooxml"> + <target name="compile-ooxml-lite" depends="test-ooxml"> <echo message="Create ooxml-lite schemas"/> + <local name="lite.exports"/> + <loadresource property="lite.exports"> + <file file="${ooxml.lite.report}"/> + <filterchain> + <tokenfilter> + <replaceregex pattern="[/\\][^/\\]+$" replace=""/> + <replaceregex pattern="[/\\]" replace="." flags="g"/> + </tokenfilter> + <linecontainsregexp negate="true" regexp="\.impl$"/> + <sortfilter/> + <uniqfilter/> + <prefixlines prefix=" exports "/> + <suffixlines suffix=";"/> + </filterchain> + </loadresource> - <copy file="${ooxml.lite.report}" tofile="${ooxml.lite.report}-pat" overwrite="true"/> - <replaceregexp file="${ooxml.lite.report}-pat" byline="true" match="(.*)" replace="\1.class${line.separator}\1$*.class"/> + <local name="full.schema"/> + <loadresource property="full.schema"> + <file file="${basedir}/src/multimodule/ooxml-schemas/java9/module-info.java"/> + <filterchain> + <linecontains negate="true" matchany="true"> + <contains value="exports"/> + <contains value="}"/> + </linecontains> + </filterchain> + </loadresource> - <patternset id="xsbfiles"> - <includesfile name="${ooxml.lite.report}-pat"/> - <include name="org/apache/poi/schemas/*/system/**/*.xsb"/> - <include name="org/apache/poi/schemas/*/element/**/*.xsb"/> - </patternset> + <echo output="${basedir}/src/multimodule/ooxml-lite/java9/module-info.java">${full.schema}${lite.exports}}</echo> + + <javac release="9" + srcdir="${basedir}/src/multimodule/ooxml-lite/java9" + destdir="${basedir}/src/multimodule/ooxml-lite/java9" + includeantruntime="false" + fork="true" + unless:true="${isJava8}"> + <compilerarg line="--patch-module org.apache.poi.ooxml.schemas=${ooxml.xsds.jar}"/> + <modulepath> + <pathelement path="lib/ooxml"/> + </modulepath> + </javac> + + <local name="lite.classes"/> + <loadresource property="lite.classes"> + <file file="${ooxml.lite.report}"/> + <filterchain> + <tokenfilter> + <replaceregex pattern="(.*)" replace="\1.class \1$*.class "/> + </tokenfilter> + <striplinebreaks/> + </filterchain> + </loadresource> + + <mkdir dir="build/dist/maven/poi-ooxml-schemas"/> <jar destfile="${ooxml.lite.jar}" duplicate="preserve"> + <zipfileset dir="${basedir}/src/multimodule/ooxml-lite/java9" prefix="META-INF/versions/9" excludes="*.java"/> <zipfileset src="${ooxml.xsds.jar}"> - <patternset refid="xsbfiles"/> - </zipfileset> - <zipfileset src="${ooxml.security.jar}"> - <patternset refid="xsbfiles"/> + <patternset includes="${lite.classes}"> + <include name="org/apache/poi/schemas/*/system/**/*.xsb"/> + <include name="org/apache/poi/schemas/*/element/**/*.xsb"/> + </patternset> </zipfileset> + <zipfileset dir="src/multimodule/ooxml-schemas/java9" prefix="META-INF/versions/9" excludes="*.java"/> + <manifest> + <attribute name="Multi-Release" value="true"/> + <attribute name="Automatic-Module-Name" value="org.apache.poi.ooxml.schemas"/> + </manifest> </jar> </target> - <target name="test-ooxml-lite" depends="jacocotask,compile-ooxml-xsds,compile-ooxml-lite"> + <target name="test-ooxml-lite" depends="jacocotask,compile-ooxml-lite"> <delete file="${ooxml.testokfile}"/> <echo message="Running ooxml tests against 'poi-ooxml-schemas'"/> - <ooxml-test-runner classpath="ooxml-lite.classpath" type="ooxml-lite"/> - </target> - <target name="-ooxml-lite-agent" depends="jacocotask,compile-ooxml-xsds,compile-ooxml"> - <jar destfile="${ooxml.lite.agent}"> - <fileset dir="${ooxml.output.test.dir}" includes="org/apache/poi/ooxml/util/OOXMLLiteAgent*.class"/> - <manifest> - <attribute name="Premain-Class" value="org.apache.poi.ooxml.util.OOXMLLiteAgent"/> - </manifest> - </jar> + <path id="test-ooxml-lite.modules"> + <!-- lite schema --> + <pathelement path="build/dist/maven/poi-ooxml-schemas"/> + <pathelement path="build/dist/maven/poi-tests"/> + <pathelement path="build/dist/maven/poi-ooxml-tests"/> + <pathelement path="build/dist/maven/poi-scratchpad-tests"/> + <pathelement path="lib/main"/> + <pathelement path="lib/main-tests"/> + <pathelement path="lib/ooxml"/> + <pathelement path="lib/ooxml-provided"/> + <pathelement path="lib/ooxml-tests"/> + </path> + + + <ooxml-test-runner modulepath-ref="test-ooxml-lite.modules" type="ooxml-lite"/> </target> <!-- Section: test-excelant --> @@ -1569,10 +1672,27 @@ under the License. <echo file="${excelant.testokfile}" append="false" message="testok"/> </target> - <target name="test-excelant" depends="compile-excelant,-test-excelant-check,jacocotask" + <target name="test-excelant" depends="compile-excelant,compile-ooxml-lite,-test-excelant-check,jacocotask" unless="excelant.test.notRequired"> - <poiunit failureproperty="excelant.test.failed" jacocodest="build/jacoco-excelant.exec"> - <classpath refid="test.excelant.classpath"/> + + <path id="test-excelant.modules"> + <pathelement path="lib/main"/> + <pathelement path="lib/main-tests"/> + <pathelement path="lib/ooxml"/> + <pathelement path="lib/ooxml-tests"/> + <pathelement path="lib/ooxml-provided"/> + <pathelement path="lib/excelant"/> + <pathelement path="build/dist/maven/poi-tests"/> + <pathelement path="build/dist/maven/poi-ooxml-tests"/> + <pathelement path="build/dist/maven/poi-ooxml-schemas"/> + <pathelement path="build/dist/maven/poi-scratchpad-tests"/> + <pathelement path="build/dist/maven/poi-excelant-tests"/> + </path> + + <poiunit failureproperty="excelant.test.failed" jacocodest="build/jacoco-excelant.exec" + modulepath-ref="test-excelant.modules"> + <jvmarg line="--add-modules org.apache.poi.excelant" unless:true="${isJava8}"/> + <batchtest todir="${excelant.reports.test}"> <fileset dir="${excelant.src.test}"> <include name="**/${testpattern}.java"/> @@ -1768,6 +1888,7 @@ under the License. <target name="-manifest"> <manifest file="build/poi-manifest.mf"> + <attribute name="Multi-Release" value="true"/> <attribute name="Built-By" value="${user.name}"/> <attribute name="Specification-Title" value="Apache POI"/> <attribute name="Specification-Version" value="${version.id}"/> @@ -1781,6 +1902,9 @@ under the License. <macrodef name="maven-jar"> <attribute name="src"/> + <attribute name="module"/> + <element name="elements" implicit="true" optional="true"/> + <sequential> <local name="destfile"/> <pathconvert property="destfile" targetos="unix"> @@ -1799,35 +1923,46 @@ under the License. </chainedmapper> </mapper> </pathconvert> + <local name="isjar"/> <condition property="isjar"> <contains string="@{src}" substring=".jar"/> </condition> - <jar destfile="build/dist/maven/${destfile}.jar" - manifest="build/poi-manifest.mf"> + <mkdir dir="@{src}/META-INF/versions/9"/> + + <javac release="9" + srcdir="${basedir}/src/multimodule/@{module}/java9" + destdir="@{src}/META-INF/versions/9" + includeantruntime="false" + fork="true" + modulepath="${main.lib}" + unless:true="${isJava8}"> + <compilerarg line="--patch-module org.apache.poi.@{module}=@{src}"/> + <elements/> + </javac> + + <jar destfile="build/dist/maven/${destfile}.jar"> <fileset dir="@{src}" unless:true="${isjar}"/> <zipfileset src="@{src}" if:true="${isjar}"/> <metainf dir="legal/"/> + <manifest> + <attribute name="Multi-Release" value="true"/> + <attribute name="Automatic-Module-Name" value="org.apache.poi.@{module}"/> + <attribute name="Built-By" value="${user.name}"/> + <attribute name="Specification-Title" value="Apache POI"/> + <attribute name="Specification-Version" value="${version.id}"/> + <attribute name="Specification-Vendor" value="The Apache Software Foundation"/> + <attribute name="Implementation-Title" value="Apache POI"/> + <attribute name="Implementation-Version" value="${version.id}"/> + <attribute name="Implementation-Vendor-Id" value="org.apache.poi"/> + <attribute name="Implementation-Vendor" value="The Apache Software Foundation"/> + </manifest> </jar> </sequential> </macrodef> - <target name="jar" depends="compile, compile-version, compile-ooxml-lite, -manifest" description="Creates jar files for distribution"> - <maven-jar src="${main.output.dir}"/> - <maven-jar src="${scratchpad.output.dir}"/> - <maven-jar src="${ooxml.output.dir}"/> - <maven-jar src="${examples.output.dir}"/> - <maven-jar src="${excelant.output.dir}"/> - <maven-jar src="${ooxml.lite.jar}"/> - </target> - - <target name="jar-src" depends="compile, compile-version, -manifest" description="Sources for Maven"> - <maven-jar src="${main.src}"/> - <maven-jar src="${scratchpad.src}"/> - <maven-jar src="${ooxml.src}"/> - <maven-jar src="${examples.src}"/> - <maven-jar src="${excelant.src}"/> + <target name="jar" depends="compile, compile-ooxml-lite" description="Creates jar files for distribution"> </target> <target name="integration-test-jar" depends="compile-integration,-manifest" description="target for packaging the integration-test code for mass regression test runs"> @@ -1893,7 +2028,7 @@ under the License. </copy> </target> - <target name="assemble" depends="jar,jar-src,jar-javadocs" description="Produce the zipped distribution files"> + <target name="assemble" depends="jar,jar-javadocs" description="Produce the zipped distribution files"> <property name="zipdir" value="${jar.name}-${version.id}"/> <mappedresources id="legal-files" cache="true"> @@ -2096,6 +2231,19 @@ under the License. classname="de.thetaphi.forbiddenapis.ant.AntTask" classpath="${forbidden.jar}"/> + <path id="forbiddenapis.classpath"> + <fileset dir="lib/main" includes="*.jar"/> + <fileset dir="lib/main-tests" includes="*.jar"/> + <fileset dir="lib/ooxml" includes="*.jar"/> + <fileset dir="lib/ooxml-tests" includes="*.jar"/> + <fileset dir="lib/ooxml-provided" includes="*.jar"/> + <fileset dir="lib/excelant" includes="*.jar"/> + <pathelement location="${ooxml.xsds.jar}"/> + <pathelement location="build/dist/maven/poi-examples/poi-examples-${version.id}.jar"/> + <path path="${env.CLASSPATH}"/> + </path> + + <!-- first check rules that apply to all the source code --> <forbiddenapis classpathref="forbiddenapis.classpath" @@ -2112,16 +2260,16 @@ under the License. --> <signaturesFileset file="src/resources/devtools/forbidden-signatures.txt"/> <!-- sources --> - <fileset dir="${main.output.dir}"/> - <fileset dir="${ooxml.output.dir}"/> - <fileset dir="${scratchpad.output.dir}"/> - <fileset dir="${excelant.output.dir}"/> + <!-- zipfileset src="build/dist/maven/poi/poi-5.0.0-SNAPSHOT.jar"/ --> + <!-- zipfileset src="build/dist/maven/poi-ooxml/poi-ooxml-5.0.0-SNAPSHOT.jar"/ --> + <zipfileset src="build/dist/maven/poi-scratchpad/poi-scratchpad-5.0.0-SNAPSHOT.jar"/> + <zipfileset src="build/dist/maven/poi-excelant/poi-excelant-5.0.0-SNAPSHOT.jar"/> <!-- <fileset dir="${examples.output.dir}"/> --> - <!-- test-sources --> - <fileset dir="${main.output.test.dir}"/> - <fileset dir="${ooxml.output.test.dir}"/> + <!-- test-sources (incl. sources) --> + <zipfileset src="build/dist/maven/poi-tests/poi-${version.id}-tests.jar"/> + <zipfileset src="build/dist/maven/poi-ooxml-tests/poi-ooxml-${version.id}-tests.jar"/> <!-- <fileset dir="${scratchpad.output.test.dir}"/> <fileset dir="${excelant.output.test.dir}"/> @@ -2137,11 +2285,12 @@ under the License. > <signaturesFileset file="src/resources/devtools/forbidden-signatures-prod.txt"/> <!-- sources --> - <fileset dir="${main.output.dir}"/> - <fileset dir="${ooxml.output.dir}"/> - <fileset dir="${scratchpad.output.dir}"/> - <fileset dir="${excelant.output.dir}"/> - <fileset dir="${integration.output.test.dir}"/> + <zipfileset src="build/dist/maven/poi/poi-5.0.0-SNAPSHOT.jar"/> + <zipfileset src="build/dist/maven/poi-ooxml/poi-ooxml-5.0.0-SNAPSHOT.jar"/> + <zipfileset src="build/dist/maven/poi-scratchpad/poi-scratchpad-5.0.0-SNAPSHOT.jar"/> + <zipfileset src="build/dist/maven/poi-excelant/poi-excelant-5.0.0-SNAPSHOT.jar"/> + + <zipfileset src="lib/ooxml-tests/poi-integration.jar"/> </forbiddenapis> </target> @@ -2238,7 +2387,6 @@ under the License. <auxClasspath path="${dsig.slf4j-api.jar}" /> <auxClasspath path="${dsig.xmlsec.jar}" /> <auxClasspath path="${ooxml.xsds.jar}" /> - <auxClasspath path="${ooxml.security.jar}" /> <auxClasspath path="${ooxml.curvesapi.jar}" /> <auxClasspath path="${ooxml.xmlbeans.jar}" /> <auxClasspath path="${ooxml.commons-compress.jar}" /> diff --git a/src/examples/src/org/apache/poi/crypt/examples/OOXMLPasswordsTry.java b/src/examples/src/org/apache/poi/examples/crypt/OOXMLPasswordsTry.java index 261020fc79..406d6dc335 100644 --- a/src/examples/src/org/apache/poi/crypt/examples/OOXMLPasswordsTry.java +++ b/src/examples/src/org/apache/poi/examples/crypt/OOXMLPasswordsTry.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.apache.poi.crypt.examples; +package org.apache.poi.examples.crypt; import java.io.File; import java.nio.file.Files; diff --git a/src/examples/src/org/apache/poi/hpsf/examples/CopyCompare.java b/src/examples/src/org/apache/poi/examples/hpsf/CopyCompare.java index 567323d514..6c1189e375 100644 --- a/src/examples/src/org/apache/poi/hpsf/examples/CopyCompare.java +++ b/src/examples/src/org/apache/poi/examples/hpsf/CopyCompare.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hpsf.examples; +package org.apache.poi.examples.hpsf; import java.io.File; import java.io.FileOutputStream; diff --git a/src/examples/src/org/apache/poi/hpsf/examples/ModifyDocumentSummaryInformation.java b/src/examples/src/org/apache/poi/examples/hpsf/ModifyDocumentSummaryInformation.java index 41711061fa..cf26fee949 100644 --- a/src/examples/src/org/apache/poi/hpsf/examples/ModifyDocumentSummaryInformation.java +++ b/src/examples/src/org/apache/poi/examples/hpsf/ModifyDocumentSummaryInformation.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hpsf.examples; +package org.apache.poi.examples.hpsf; import java.io.File; import java.io.FileNotFoundException; diff --git a/src/examples/src/org/apache/poi/hpsf/examples/ReadCustomPropertySets.java b/src/examples/src/org/apache/poi/examples/hpsf/ReadCustomPropertySets.java index fc8751bda6..ca8cba1ce9 100644 --- a/src/examples/src/org/apache/poi/hpsf/examples/ReadCustomPropertySets.java +++ b/src/examples/src/org/apache/poi/examples/hpsf/ReadCustomPropertySets.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hpsf.examples; +package org.apache.poi.examples.hpsf; import java.io.File; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hpsf/examples/ReadTitle.java b/src/examples/src/org/apache/poi/examples/hpsf/ReadTitle.java index 1072064998..b901a89a3d 100644 --- a/src/examples/src/org/apache/poi/hpsf/examples/ReadTitle.java +++ b/src/examples/src/org/apache/poi/examples/hpsf/ReadTitle.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hpsf.examples; +package org.apache.poi.examples.hpsf; import java.io.File; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hpsf/examples/WriteAuthorAndTitle.java b/src/examples/src/org/apache/poi/examples/hpsf/WriteAuthorAndTitle.java index ce51773a25..94ceaf6c03 100644 --- a/src/examples/src/org/apache/poi/hpsf/examples/WriteAuthorAndTitle.java +++ b/src/examples/src/org/apache/poi/examples/hpsf/WriteAuthorAndTitle.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hpsf.examples; +package org.apache.poi.examples.hpsf; import java.io.File; import java.io.FileOutputStream; diff --git a/src/examples/src/org/apache/poi/hpsf/examples/WriteTitle.java b/src/examples/src/org/apache/poi/examples/hpsf/WriteTitle.java index 8fd505f27d..a9a50cf8e4 100644 --- a/src/examples/src/org/apache/poi/hpsf/examples/WriteTitle.java +++ b/src/examples/src/org/apache/poi/examples/hpsf/WriteTitle.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hpsf.examples; +package org.apache.poi.examples.hpsf; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java b/src/examples/src/org/apache/poi/examples/hslf/ApacheconEU08.java index 73871cb335..53d3c46077 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/ApacheconEU08.java +++ b/src/examples/src/org/apache/poi/examples/hslf/ApacheconEU08.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hslf.examples; +package org.apache.poi.examples.hslf; import java.awt.Color; import java.awt.Dimension; diff --git a/src/examples/src/org/apache/poi/hslf/examples/BulletsDemo.java b/src/examples/src/org/apache/poi/examples/hslf/BulletsDemo.java index dc814f35b5..5ab8b86a39 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/BulletsDemo.java +++ b/src/examples/src/org/apache/poi/examples/hslf/BulletsDemo.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hslf.examples; +package org.apache.poi.examples.hslf; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hslf/examples/CreateHyperlink.java b/src/examples/src/org/apache/poi/examples/hslf/CreateHyperlink.java index 65fb0b9876..be8a227d1a 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/CreateHyperlink.java +++ b/src/examples/src/org/apache/poi/examples/hslf/CreateHyperlink.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hslf.examples; +package org.apache.poi.examples.hslf; import java.awt.Rectangle; import java.io.FileOutputStream; diff --git a/src/examples/src/org/apache/poi/hslf/examples/DataExtraction.java b/src/examples/src/org/apache/poi/examples/hslf/DataExtraction.java index e73b8971e6..6996dc8751 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/DataExtraction.java +++ b/src/examples/src/org/apache/poi/examples/hslf/DataExtraction.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hslf.examples; +package org.apache.poi.examples.hslf; import java.io.FileInputStream; import java.io.FileOutputStream; diff --git a/src/examples/src/org/apache/poi/hslf/examples/Graphics2DDemo.java b/src/examples/src/org/apache/poi/examples/hslf/Graphics2DDemo.java index 75ccf0121e..938b52e6d2 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/Graphics2DDemo.java +++ b/src/examples/src/org/apache/poi/examples/hslf/Graphics2DDemo.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hslf.examples; +package org.apache.poi.examples.hslf; import java.awt.Color; import java.awt.Font; diff --git a/src/examples/src/org/apache/poi/hslf/examples/HeadersFootersDemo.java b/src/examples/src/org/apache/poi/examples/hslf/HeadersFootersDemo.java index 28fc8b1343..4dd4349df5 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/HeadersFootersDemo.java +++ b/src/examples/src/org/apache/poi/examples/hslf/HeadersFootersDemo.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.hslf.examples; +package org.apache.poi.examples.hslf; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hslf/examples/Hyperlinks.java b/src/examples/src/org/apache/poi/examples/hslf/Hyperlinks.java index f63afb44d2..307178d0e0 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/Hyperlinks.java +++ b/src/examples/src/org/apache/poi/examples/hslf/Hyperlinks.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hslf.examples; +package org.apache.poi.examples.hslf; import java.io.FileInputStream; import java.util.List; diff --git a/src/examples/src/org/apache/poi/hslf/examples/SoundFinder.java b/src/examples/src/org/apache/poi/examples/hslf/SoundFinder.java index 49ca94be9b..0f6929fee7 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/SoundFinder.java +++ b/src/examples/src/org/apache/poi/examples/hslf/SoundFinder.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.hslf.examples; +package org.apache.poi.examples.hslf; import java.io.FileInputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hslf/examples/TableDemo.java b/src/examples/src/org/apache/poi/examples/hslf/TableDemo.java index da8464f586..561ec717ab 100644 --- a/src/examples/src/org/apache/poi/hslf/examples/TableDemo.java +++ b/src/examples/src/org/apache/poi/examples/hslf/TableDemo.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hslf.examples; +package org.apache.poi.examples.hslf; import java.awt.Color; import java.io.FileOutputStream; @@ -64,7 +64,7 @@ public final class TableDemo { } } } - + static void create1stTable(HSLFSlide slide) { //six rows, two columns HSLFTable table1 = slide.createTable(6, 2); diff --git a/src/examples/src/org/apache/poi/hsmf/examples/Msg2txt.java b/src/examples/src/org/apache/poi/examples/hsmf/Msg2txt.java index 010e711557..a4756a27d5 100644 --- a/src/examples/src/org/apache/poi/hsmf/examples/Msg2txt.java +++ b/src/examples/src/org/apache/poi/examples/hsmf/Msg2txt.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hsmf.examples; +package org.apache.poi.examples.hsmf; import java.io.File; import java.io.FileOutputStream; diff --git a/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java b/src/examples/src/org/apache/poi/examples/hssf/eventusermodel/XLS2CSVmra.java index da06079c32..42056d0716 100644 --- a/src/examples/src/org/apache/poi/hssf/eventusermodel/examples/XLS2CSVmra.java +++ b/src/examples/src/org/apache/poi/examples/hssf/eventusermodel/XLS2CSVmra.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.eventusermodel.examples; +package org.apache.poi.examples.hssf.eventusermodel; import java.io.FileInputStream; import java.io.FileNotFoundException; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/AddDimensionedImage.java index 38e2fe6f51..129f9327da 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/AddDimensionedImage.java @@ -16,8 +16,8 @@ ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; /* Placeholder - this is now handled in the Common SS example **/ -public class AddDimensionedImage extends org.apache.poi.ss.examples.AddDimensionedImage { +public class AddDimensionedImage extends org.apache.poi.examples.ss.AddDimensionedImage { }
\ No newline at end of file diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Alignment.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/Alignment.java index 57395b1c46..25affcb0f8 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Alignment.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/Alignment.java @@ -15,9 +15,9 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - -package org.apache.poi.hssf.usermodel.examples; + +package org.apache.poi.examples.hssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/BigExample.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/BigExample.java index ef1a06b3bf..f50391ade8 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/BigExample.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/BigExample.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Borders.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/Borders.java index 9509619cc6..fba3b33214 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Borders.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/Borders.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellComments.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/CellComments.java index 877708bde8..6b6434b3e1 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellComments.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/CellComments.java @@ -15,7 +15,10 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; + +import java.io.FileOutputStream; +import java.io.IOException; import org.apache.poi.hssf.usermodel.HSSFComment; import org.apache.poi.hssf.usermodel.HSSFWorkbook; @@ -31,9 +34,6 @@ import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; -import java.io.FileOutputStream; -import java.io.IOException; - /** * Demonstrates how to work with excel cell comments.<p> * diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellTypes.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/CellTypes.java index f589bc6ad0..5ba1656ff1 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellTypes.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/CellTypes.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CreateCells.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/CreateCells.java index b2b803f111..8994d6f17e 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CreateCells.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/CreateCells.java @@ -15,16 +15,16 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; - -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.hssf.usermodel.HSSFSheet; -import org.apache.poi.hssf.usermodel.HSSFRow; -import org.apache.poi.hssf.usermodel.HSSFCell; +package org.apache.poi.examples.hssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; + /** * Illustrates how to create cell values. * diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CreateDateCells.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/CreateDateCells.java index 9fea613aad..b77e0d1474 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CreateDateCells.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/CreateDateCells.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/EmbeddedObjects.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/EmbeddedObjects.java index 9c9d0bce6f..149c908fac 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/EmbeddedObjects.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/EmbeddedObjects.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.Closeable; import java.io.FileInputStream; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/EventExample.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/EventExample.java index 9d3ba51bef..0e71406b58 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/EventExample.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/EventExample.java @@ -16,7 +16,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.FileInputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/FrillsAndFills.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/FrillsAndFills.java index 9627780e1f..ca2a61e41e 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/FrillsAndFills.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/FrillsAndFills.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/HSSFReadWrite.java index 52667d1c65..f53065de94 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/HSSFReadWrite.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.FileInputStream; import java.io.FileOutputStream; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/HyperlinkFormula.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/HyperlinkFormula.java index 52294360c6..96fa30a90f 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/HyperlinkFormula.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/HyperlinkFormula.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/Hyperlinks.java index 9189f15375..ae4a37ea13 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/Hyperlinks.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/InCellLists.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/InCellLists.java index b8d19039c1..76d0172f82 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/InCellLists.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/InCellLists.java @@ -16,7 +16,7 @@ ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.File; import java.io.FileOutputStream; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/MergedCells.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/MergedCells.java index af1d8dd98a..16114b2d63 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/MergedCells.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/MergedCells.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewLinesInCells.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/NewLinesInCells.java index 2b7ce2d96d..487668da10 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewLinesInCells.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/NewLinesInCells.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewSheet.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/NewSheet.java index 225425445d..d2d8f31d0a 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewSheet.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/NewSheet.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewWorkbook.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/NewWorkbook.java index 3e61aaf342..16c0e04de1 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewWorkbook.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/NewWorkbook.java @@ -15,9 +15,9 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - -package org.apache.poi.hssf.usermodel.examples; + +package org.apache.poi.examples.hssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawing.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/OfficeDrawing.java index 7e703c5867..4603864d86 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawing.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/OfficeDrawing.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/OfficeDrawingWithGraphics.java index b437371ac1..eca55d4378 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawingWithGraphics.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/OfficeDrawingWithGraphics.java @@ -15,14 +15,24 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; -import org.apache.poi.hssf.usermodel.*; - -import java.awt.*; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.RenderingHints; import java.io.FileOutputStream; import java.io.IOException; +import org.apache.poi.hssf.usermodel.EscherGraphics; +import org.apache.poi.hssf.usermodel.EscherGraphics2d; +import org.apache.poi.hssf.usermodel.HSSFClientAnchor; +import org.apache.poi.hssf.usermodel.HSSFPatriarch; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFShapeGroup; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; + /** * Demonstrates the use of the EscherGraphics2d library. * diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Outlines.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/Outlines.java index 9630957232..d059a3d392 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Outlines.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/Outlines.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.Closeable; import java.io.FileOutputStream; @@ -54,7 +54,7 @@ public class Outlines implements Closeable { wb.write(fileOut); } } - + @Override public void close() throws IOException { wb.close(); diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/ReadWriteWorkbook.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/ReadWriteWorkbook.java index 9b856f99b8..e36b7ad26c 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/ReadWriteWorkbook.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/ReadWriteWorkbook.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.FileInputStream; import java.io.FileOutputStream; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/RepeatingRowsAndColumns.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/RepeatingRowsAndColumns.java index 5d6b4d5f90..db737cd5bb 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/RepeatingRowsAndColumns.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/RepeatingRowsAndColumns.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/SplitAndFreezePanes.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/SplitAndFreezePanes.java index a76864094b..54c3879e41 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/SplitAndFreezePanes.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/SplitAndFreezePanes.java @@ -15,9 +15,9 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - -package org.apache.poi.hssf.usermodel.examples; + +package org.apache.poi.examples.hssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/WorkingWithFonts.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/WorkingWithFonts.java index f0e114a1a0..0c87a335b3 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/WorkingWithFonts.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/WorkingWithFonts.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel.examples; +package org.apache.poi.examples.hssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/ZoomSheet.java b/src/examples/src/org/apache/poi/examples/hssf/usermodel/ZoomSheet.java index 600041fc29..e958489cf7 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/ZoomSheet.java +++ b/src/examples/src/org/apache/poi/examples/hssf/usermodel/ZoomSheet.java @@ -15,15 +15,15 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ - -package org.apache.poi.hssf.usermodel.examples; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.hssf.usermodel.HSSFSheet; +package org.apache.poi.examples.hssf.usermodel; -import java.io.IOException; import java.io.FileOutputStream; +import java.io.IOException; + +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; /** * Sets the zoom magnication for a sheet. diff --git a/src/examples/src/org/apache/poi/hwpf/Word2Forrest.java b/src/examples/src/org/apache/poi/examples/hwpf/Word2Forrest.java index b26f3c1675..937da16a33 100644 --- a/src/examples/src/org/apache/poi/hwpf/Word2Forrest.java +++ b/src/examples/src/org/apache/poi/examples/hwpf/Word2Forrest.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.hwpf; +package org.apache.poi.examples.hwpf; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -26,6 +26,7 @@ import java.io.OutputStreamWriter; import java.io.Writer; import java.nio.charset.StandardCharsets; +import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.model.StyleDescription; import org.apache.poi.hwpf.model.StyleSheet; import org.apache.poi.hwpf.usermodel.CharacterRun; diff --git a/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java b/src/examples/src/org/apache/poi/examples/ss/AddDimensionedImage.java index 05a8a78121..6e102038b6 100644 --- a/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java +++ b/src/examples/src/org/apache/poi/examples/ss/AddDimensionedImage.java @@ -16,7 +16,7 @@ ==================================================================== */ -package org.apache.poi.ss.examples; +package org.apache.poi.examples.ss; import java.io.File; import java.io.FileOutputStream; diff --git a/src/examples/src/org/apache/poi/ss/examples/AligningCells.java b/src/examples/src/org/apache/poi/examples/ss/AligningCells.java index cdd2bbc4c0..af86efc724 100644 --- a/src/examples/src/org/apache/poi/ss/examples/AligningCells.java +++ b/src/examples/src/org/apache/poi/examples/ss/AligningCells.java @@ -14,13 +14,20 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples; +package org.apache.poi.examples.ss; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; -import org.apache.poi.ss.usermodel.*; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.CreationHelper; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; /** diff --git a/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java b/src/examples/src/org/apache/poi/examples/ss/BusinessPlan.java index 0e35509e28..59ccc6f337 100644 --- a/src/examples/src/org/apache/poi/ss/examples/BusinessPlan.java +++ b/src/examples/src/org/apache/poi/examples/ss/BusinessPlan.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples; +package org.apache.poi.examples.ss; import java.io.FileOutputStream; import java.text.SimpleDateFormat; diff --git a/src/examples/src/org/apache/poi/ss/examples/CalendarDemo.java b/src/examples/src/org/apache/poi/examples/ss/CalendarDemo.java index 108cc25962..f11c1e0227 100644 --- a/src/examples/src/org/apache/poi/ss/examples/CalendarDemo.java +++ b/src/examples/src/org/apache/poi/examples/ss/CalendarDemo.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples; +package org.apache.poi.examples.ss; import java.io.FileOutputStream; import java.util.Calendar; diff --git a/src/examples/src/org/apache/poi/ss/examples/CellStyleDetails.java b/src/examples/src/org/apache/poi/examples/ss/CellStyleDetails.java index 4729c9fb53..5081bfcd52 100644 --- a/src/examples/src/org/apache/poi/ss/examples/CellStyleDetails.java +++ b/src/examples/src/org/apache/poi/examples/ss/CellStyleDetails.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples; +package org.apache.poi.examples.ss; import java.io.File; diff --git a/src/examples/src/org/apache/poi/ss/examples/ConditionalFormats.java b/src/examples/src/org/apache/poi/examples/ss/ConditionalFormats.java index ff26f9d17d..22eec9633a 100644 --- a/src/examples/src/org/apache/poi/ss/examples/ConditionalFormats.java +++ b/src/examples/src/org/apache/poi/examples/ss/ConditionalFormats.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.apache.poi.ss.examples; +package org.apache.poi.examples.ss; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/ss/examples/DrawingBorders.java b/src/examples/src/org/apache/poi/examples/ss/DrawingBorders.java index 8a4ad94e1e..f98d64b2c6 100644 --- a/src/examples/src/org/apache/poi/ss/examples/DrawingBorders.java +++ b/src/examples/src/org/apache/poi/examples/ss/DrawingBorders.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.apache.poi.ss.examples; +package org.apache.poi.examples.ss; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java b/src/examples/src/org/apache/poi/examples/ss/ExcelComparator.java index f2cd249ef4..825b72b0c2 100644 --- a/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java +++ b/src/examples/src/org/apache/poi/examples/ss/ExcelComparator.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples; +package org.apache.poi.examples.ss; import java.io.File; import java.util.ArrayList; diff --git a/src/examples/src/org/apache/poi/ss/examples/LinkedDropDownLists.java b/src/examples/src/org/apache/poi/examples/ss/LinkedDropDownLists.java index c98c87ad79..5cbc63be60 100644 --- a/src/examples/src/org/apache/poi/ss/examples/LinkedDropDownLists.java +++ b/src/examples/src/org/apache/poi/examples/ss/LinkedDropDownLists.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples; +package org.apache.poi.examples.ss; import java.io.FileOutputStream; import java.io.IOException; @@ -42,12 +42,12 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; * case; the data could appear on a separate sheet. If this were done, then the * names for the regions would have to be different, they would have to include * the name of the sheet. - * - * There are two keys to this technique. The first is the use of named area or + * + * There are two keys to this technique. The first is the use of named area or * regions of cells to hold the data for the drop down lists and the second is * making use of the INDIRECT() function to convert a name into the addresses * of the cells it refers to. - * + * * Note that whilst this class builds just two linked drop down lists, there is * nothing to prevent more being created. Quite simply, use the value selected * by the user in one drop down list to determine what is shown in another and the @@ -114,16 +114,16 @@ public class LinkedDropDownLists { * the cells on rows two, three and four will be used to populate the second * drop down list, just which row will be determined by the choice the user * makes in the first drop down list. - * + * * In all cases, the approach is to create a row, create and populate cells * with data and then specify a name that identifies those cells. With the * exception of the first range, the names that are chosen for each range - * of cells are quite important. In short, each of the options the user + * of cells are quite important. In short, each of the options the user * could select in the first drop down list is used as the name for another - * range of cells. Thus, in this example, the user can select either + * range of cells. Thus, in this example, the user can select either * 'Animal', 'Vegetable' or 'Mineral' in the first drop down and so the * sheet contains ranges named 'ANIMAL', 'VEGETABLE' and 'MINERAL'. - * + * * @param dataSheet An instance of a class that implements the Sheet Sheet * interface (HSSFSheet or XSSFSheet). */ diff --git a/src/examples/src/org/apache/poi/ss/examples/LoadEmbedded.java b/src/examples/src/org/apache/poi/examples/ss/LoadEmbedded.java index 34313b07b9..3c52ecf253 100644 --- a/src/examples/src/org/apache/poi/ss/examples/LoadEmbedded.java +++ b/src/examples/src/org/apache/poi/examples/ss/LoadEmbedded.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples; +package org.apache.poi.examples.ss; import java.io.File; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/ss/examples/LoanCalculator.java b/src/examples/src/org/apache/poi/examples/ss/LoanCalculator.java index 079b782b14..28d1c648f0 100644 --- a/src/examples/src/org/apache/poi/ss/examples/LoanCalculator.java +++ b/src/examples/src/org/apache/poi/examples/ss/LoanCalculator.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples; +package org.apache.poi.examples.ss; import java.io.FileOutputStream; import java.util.HashMap; diff --git a/src/examples/src/org/apache/poi/ss/examples/SSPerformanceTest.java b/src/examples/src/org/apache/poi/examples/ss/SSPerformanceTest.java index 05776bee3e..a5b7eb7170 100644 --- a/src/examples/src/org/apache/poi/ss/examples/SSPerformanceTest.java +++ b/src/examples/src/org/apache/poi/examples/ss/SSPerformanceTest.java @@ -16,7 +16,7 @@ * limitations under the License. * ==================================================================== */ -package org.apache.poi.ss.examples; +package org.apache.poi.examples.ss; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java b/src/examples/src/org/apache/poi/examples/ss/TimesheetDemo.java index 5829454ec2..77b55c826d 100644 --- a/src/examples/src/org/apache/poi/ss/examples/TimesheetDemo.java +++ b/src/examples/src/org/apache/poi/examples/ss/TimesheetDemo.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples; +package org.apache.poi.examples.ss; import java.io.FileOutputStream; import java.util.HashMap; diff --git a/src/examples/src/org/apache/poi/ss/examples/ToCSV.java b/src/examples/src/org/apache/poi/examples/ss/ToCSV.java index a7a806d388..f334667505 100644 --- a/src/examples/src/org/apache/poi/ss/examples/ToCSV.java +++ b/src/examples/src/org/apache/poi/examples/ss/ToCSV.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples; +package org.apache.poi.examples.ss; import java.io.BufferedWriter; diff --git a/src/examples/src/org/apache/poi/ss/examples/formula/CalculateMortgage.java b/src/examples/src/org/apache/poi/examples/ss/formula/CalculateMortgage.java index 678776c060..2675df181b 100644 --- a/src/examples/src/org/apache/poi/ss/examples/formula/CalculateMortgage.java +++ b/src/examples/src/org/apache/poi/examples/ss/formula/CalculateMortgage.java @@ -14,19 +14,19 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples.formula; +package org.apache.poi.examples.ss.formula; -import org.apache.poi.ss.formula.OperationEvaluationContext ; -import org.apache.poi.ss.formula.eval.ErrorEval ; -import org.apache.poi.ss.formula.eval.EvaluationException ; -import org.apache.poi.ss.formula.eval.NumberEval ; -import org.apache.poi.ss.formula.eval.OperandResolver ; -import org.apache.poi.ss.formula.eval.ValueEval ; -import org.apache.poi.ss.formula.functions.FreeRefFunction ; +import org.apache.poi.ss.formula.OperationEvaluationContext; +import org.apache.poi.ss.formula.eval.ErrorEval; +import org.apache.poi.ss.formula.eval.EvaluationException; +import org.apache.poi.ss.formula.eval.NumberEval; +import org.apache.poi.ss.formula.eval.OperandResolver; +import org.apache.poi.ss.formula.eval.ValueEval; +import org.apache.poi.ss.formula.functions.FreeRefFunction; /** * A simple user-defined function to calculate principal and interest. - * + * * @author Jon Svede ( jon [at] loquatic [dot] com ) * @author Brian Bush ( brian [dot] bush [at] nrel [dot] gov ) * @@ -35,9 +35,9 @@ public class CalculateMortgage implements FreeRefFunction { @Override public ValueEval evaluate( ValueEval[] args, OperationEvaluationContext ec ) { - + // verify that we have enough data - if (args.length != 3) { + if (args.length != 3) { return ErrorEval.VALUE_INVALID; } @@ -45,33 +45,33 @@ public class CalculateMortgage implements FreeRefFunction { double principal, rate, years, result; try { // extract values as ValueEval - ValueEval v1 = OperandResolver.getSingleValue( args[0], - ec.getRowIndex(), + ValueEval v1 = OperandResolver.getSingleValue( args[0], + ec.getRowIndex(), ec.getColumnIndex() ) ; - ValueEval v2 = OperandResolver.getSingleValue( args[1], - ec.getRowIndex(), + ValueEval v2 = OperandResolver.getSingleValue( args[1], + ec.getRowIndex(), ec.getColumnIndex() ) ; - ValueEval v3 = OperandResolver.getSingleValue( args[2], - ec.getRowIndex(), + ValueEval v3 = OperandResolver.getSingleValue( args[2], + ec.getRowIndex(), ec.getColumnIndex() ) ; // get data as doubles - principal = OperandResolver.coerceValueToDouble( v1 ) ; + principal = OperandResolver.coerceValueToDouble( v1 ) ; rate = OperandResolver.coerceValueToDouble( v2 ) ; years = OperandResolver.coerceValueToDouble( v3 ) ; - + result = calculateMortgagePayment( principal, rate, years ) ; System.out.println( "Result = " + result ) ; checkValue(result); - + } catch (EvaluationException e) { return e.getErrorEval(); } return new NumberEval( result ) ; } - + public double calculateMortgagePayment( double p, double r, double y ) { double i = r / 12 ; double n = y * 12 ; @@ -87,5 +87,5 @@ public class CalculateMortgage implements FreeRefFunction { if (Double.isNaN(result) || Double.isInfinite(result)) { throw new EvaluationException(ErrorEval.NUM_ERROR); } - } + } } diff --git a/src/examples/src/org/apache/poi/ss/examples/formula/CheckFunctionsSupported.java b/src/examples/src/org/apache/poi/examples/ss/formula/CheckFunctionsSupported.java index d2291f009d..4135c80904 100644 --- a/src/examples/src/org/apache/poi/ss/examples/formula/CheckFunctionsSupported.java +++ b/src/examples/src/org/apache/poi/examples/ss/formula/CheckFunctionsSupported.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples.formula; +package org.apache.poi.examples.ss.formula; import java.io.File; import java.util.ArrayList; diff --git a/src/examples/src/org/apache/poi/ss/examples/formula/SettingExternalFunction.java b/src/examples/src/org/apache/poi/examples/ss/formula/SettingExternalFunction.java index 992d0f0552..49feb3f7aa 100644 --- a/src/examples/src/org/apache/poi/ss/examples/formula/SettingExternalFunction.java +++ b/src/examples/src/org/apache/poi/examples/ss/formula/SettingExternalFunction.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.apache.poi.ss.examples.formula; +package org.apache.poi.examples.ss.formula; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/ss/examples/formula/UserDefinedFunctionExample.java b/src/examples/src/org/apache/poi/examples/ss/formula/UserDefinedFunctionExample.java index 7f5922b02a..939fd9ab9d 100644 --- a/src/examples/src/org/apache/poi/ss/examples/formula/UserDefinedFunctionExample.java +++ b/src/examples/src/org/apache/poi/examples/ss/formula/UserDefinedFunctionExample.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples.formula; +package org.apache.poi.examples.ss.formula; import java.io.File; diff --git a/src/examples/src/org/apache/poi/ss/examples/formula/mortgage-calculation.xls b/src/examples/src/org/apache/poi/examples/ss/formula/mortgage-calculation.xls Binary files differindex 4e71ba8e65..4e71ba8e65 100644 --- a/src/examples/src/org/apache/poi/ss/examples/formula/mortgage-calculation.xls +++ b/src/examples/src/org/apache/poi/examples/ss/formula/mortgage-calculation.xls diff --git a/src/examples/src/org/apache/poi/ss/examples/html/HSSFHtmlHelper.java b/src/examples/src/org/apache/poi/examples/ss/html/HSSFHtmlHelper.java index e7c4ea6f02..4614a31031 100644 --- a/src/examples/src/org/apache/poi/ss/examples/html/HSSFHtmlHelper.java +++ b/src/examples/src/org/apache/poi/examples/ss/html/HSSFHtmlHelper.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples.html; +package org.apache.poi.examples.ss.html; import java.util.Formatter; diff --git a/src/examples/src/org/apache/poi/ss/examples/html/HtmlHelper.java b/src/examples/src/org/apache/poi/examples/ss/html/HtmlHelper.java index 2cb1a91734..8747ad4c9d 100644 --- a/src/examples/src/org/apache/poi/ss/examples/html/HtmlHelper.java +++ b/src/examples/src/org/apache/poi/examples/ss/html/HtmlHelper.java @@ -15,12 +15,12 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples.html; - -import org.apache.poi.ss.usermodel.CellStyle; +package org.apache.poi.examples.ss.html; import java.util.Formatter; +import org.apache.poi.ss.usermodel.CellStyle; + /** * This interface is used where code wants to be independent of the workbook * formats. If you are writing such code, you can add a method to this diff --git a/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java b/src/examples/src/org/apache/poi/examples/ss/html/ToHtml.java index 15fdc2af58..930de56a29 100644 --- a/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java +++ b/src/examples/src/org/apache/poi/examples/ss/html/ToHtml.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples.html; +package org.apache.poi.examples.ss.html; import java.io.BufferedReader; import java.io.Closeable; diff --git a/src/examples/src/org/apache/poi/ss/examples/html/XSSFHtmlHelper.java b/src/examples/src/org/apache/poi/examples/ss/html/XSSFHtmlHelper.java index 20a30ed2eb..40bd504818 100644 --- a/src/examples/src/org/apache/poi/ss/examples/html/XSSFHtmlHelper.java +++ b/src/examples/src/org/apache/poi/examples/ss/html/XSSFHtmlHelper.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples.html; +package org.apache.poi.examples.ss.html; import java.util.Formatter; diff --git a/src/examples/src/org/apache/poi/ss/examples/html/excelStyle.css b/src/examples/src/org/apache/poi/examples/ss/html/excelStyle.css index f056123780..f056123780 100644 --- a/src/examples/src/org/apache/poi/ss/examples/html/excelStyle.css +++ b/src/examples/src/org/apache/poi/examples/ss/html/excelStyle.css diff --git a/src/examples/src/org/apache/poi/ss/examples/html/package-info.java b/src/examples/src/org/apache/poi/examples/ss/html/package-info.java index 11b5fd5914..1b41376632 100644 --- a/src/examples/src/org/apache/poi/ss/examples/html/package-info.java +++ b/src/examples/src/org/apache/poi/examples/ss/html/package-info.java @@ -19,4 +19,4 @@ * This package contains an example that uses POI to convert a workbook into * an HTML representation of the data. It can use both XSSF and HSSF workbooks. */ -package org.apache.poi.ss.examples.html;
\ No newline at end of file +package org.apache.poi.examples.ss.html;
\ No newline at end of file diff --git a/src/examples/src/org/apache/poi/examples/util/TempFileUtils.java b/src/examples/src/org/apache/poi/examples/util/TempFileUtils.java deleted file mode 100644 index b5ad6ea9f1..0000000000 --- a/src/examples/src/org/apache/poi/examples/util/TempFileUtils.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * ==================================================================== - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.apache.poi.examples.util; - -import java.io.File; - -import org.apache.poi.util.TempFile; - -public final class TempFileUtils { - private TempFileUtils() { - } - - @SuppressWarnings("java:S106") - public static void checkTempFiles() { - String tmpDir = System.getProperty(TempFile.JAVA_IO_TMPDIR) + "/poifiles"; - File tempDir = new File(tmpDir); - if(tempDir.exists()) { - String[] tempFiles = tempDir.list(); - if(tempFiles != null && tempFiles.length > 0) { - System.out.println("found files in poi temp dir " + tempDir.getAbsolutePath()); - for(String filename : tempFiles) { - System.out.println("file: " + filename); - } - } - } else { - System.out.println("unable to find poi temp dir"); - } - } -} diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/AddVideoToPptx.java.txt b/src/examples/src/org/apache/poi/examples/xslf/AddVideoToPptx.java.txt index 2d32c4d81b..2d32c4d81b 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/AddVideoToPptx.java.txt +++ b/src/examples/src/org/apache/poi/examples/xslf/AddVideoToPptx.java.txt diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/BarChartDemo.java b/src/examples/src/org/apache/poi/examples/xslf/BarChartDemo.java index d717e37ab0..6864c69810 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/BarChartDemo.java +++ b/src/examples/src/org/apache/poi/examples/xslf/BarChartDemo.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.apache.poi.xslf.usermodel; +package org.apache.poi.examples.xslf; import java.io.BufferedReader; import java.io.FileInputStream; @@ -37,6 +37,9 @@ import org.apache.poi.xddf.usermodel.chart.XDDFChartData; import org.apache.poi.xddf.usermodel.chart.XDDFDataSource; import org.apache.poi.xddf.usermodel.chart.XDDFDataSourcesFactory; import org.apache.poi.xddf.usermodel.chart.XDDFNumericalDataSource; +import org.apache.poi.xslf.usermodel.XMLSlideShow; +import org.apache.poi.xslf.usermodel.XSLFChart; +import org.apache.poi.xslf.usermodel.XSLFSlide; /** * Build a bar chart from a template pptx diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/ChartFromScratch.java b/src/examples/src/org/apache/poi/examples/xslf/ChartFromScratch.java index eb007fc09b..d012744deb 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/ChartFromScratch.java +++ b/src/examples/src/org/apache/poi/examples/xslf/ChartFromScratch.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.apache.poi.xslf.usermodel; +package org.apache.poi.examples.xslf; import java.awt.geom.Rectangle2D; import java.io.BufferedReader; @@ -45,6 +45,11 @@ import org.apache.poi.xddf.usermodel.chart.XDDFDataSource; import org.apache.poi.xddf.usermodel.chart.XDDFDataSourcesFactory; import org.apache.poi.xddf.usermodel.chart.XDDFNumericalDataSource; import org.apache.poi.xddf.usermodel.chart.XDDFValueAxis; +import org.apache.poi.xslf.usermodel.XMLSlideShow; +import org.apache.poi.xslf.usermodel.XSLFChart; +import org.apache.poi.xslf.usermodel.XSLFGraphicFrame; +import org.apache.poi.xslf.usermodel.XSLFShape; +import org.apache.poi.xslf.usermodel.XSLFSlide; /** * Build a chart without reading template file diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/DataExtraction.java b/src/examples/src/org/apache/poi/examples/xslf/DataExtraction.java index 543726a48b..40a7c7f0d9 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/DataExtraction.java +++ b/src/examples/src/org/apache/poi/examples/xslf/DataExtraction.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.apache.poi.xslf.usermodel; +package org.apache.poi.examples.xslf; import java.awt.Dimension; import java.io.FileInputStream; @@ -26,6 +26,12 @@ import java.io.InputStream; import java.io.PrintStream; import org.apache.poi.openxml4j.opc.PackagePart; +import org.apache.poi.xslf.usermodel.XMLSlideShow; +import org.apache.poi.xslf.usermodel.XSLFPictureData; +import org.apache.poi.xslf.usermodel.XSLFPictureShape; +import org.apache.poi.xslf.usermodel.XSLFShape; +import org.apache.poi.xslf.usermodel.XSLFSlide; +import org.apache.poi.xslf.usermodel.XSLFTextShape; /** * Demonstrates how you can extract data from a .pptx file diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/MergePresentations.java b/src/examples/src/org/apache/poi/examples/xslf/MergePresentations.java index e295ffd1ee..89ae0b1aa9 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/MergePresentations.java +++ b/src/examples/src/org/apache/poi/examples/xslf/MergePresentations.java @@ -17,11 +17,14 @@ * ==================================================================== */ -package org.apache.poi.xslf.usermodel; +package org.apache.poi.examples.xslf; import java.io.FileInputStream; import java.io.FileOutputStream; +import org.apache.poi.xslf.usermodel.XMLSlideShow; +import org.apache.poi.xslf.usermodel.XSLFSlide; + /** * Merge multiple pptx presentations together */ diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/PPTX2SVG.txt b/src/examples/src/org/apache/poi/examples/xslf/PPTX2SVG.txt index dbe089ac30..dbe089ac30 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/PPTX2SVG.txt +++ b/src/examples/src/org/apache/poi/examples/xslf/PPTX2SVG.txt diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java b/src/examples/src/org/apache/poi/examples/xslf/PieChartDemo.java index 15036a874f..9f0ca73fb6 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java +++ b/src/examples/src/org/apache/poi/examples/xslf/PieChartDemo.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.apache.poi.xslf.usermodel; +package org.apache.poi.examples.xslf; import java.io.BufferedReader; import java.io.FileInputStream; @@ -34,6 +34,9 @@ import org.apache.poi.xddf.usermodel.chart.XDDFDataSource; import org.apache.poi.xddf.usermodel.chart.XDDFDataSourcesFactory; import org.apache.poi.xddf.usermodel.chart.XDDFNumericalDataSource; import org.apache.poi.xddf.usermodel.chart.XDDFPieChartData; +import org.apache.poi.xslf.usermodel.XMLSlideShow; +import org.apache.poi.xslf.usermodel.XSLFChart; +import org.apache.poi.xslf.usermodel.XSLFSlide; /** * Build a pie chart from a template pptx diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial1.java b/src/examples/src/org/apache/poi/examples/xslf/Tutorial1.java index 34a33f74e5..d1b4768a1c 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial1.java +++ b/src/examples/src/org/apache/poi/examples/xslf/Tutorial1.java @@ -14,14 +14,22 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ==================================================================== + * ==================================================================== */ -package org.apache.poi.xslf.usermodel; +package org.apache.poi.examples.xslf; import java.io.FileOutputStream; import java.io.IOException; +import org.apache.poi.xslf.usermodel.SlideLayout; +import org.apache.poi.xslf.usermodel.XMLSlideShow; +import org.apache.poi.xslf.usermodel.XSLFSlide; +import org.apache.poi.xslf.usermodel.XSLFSlideLayout; +import org.apache.poi.xslf.usermodel.XSLFSlideMaster; +import org.apache.poi.xslf.usermodel.XSLFTextParagraph; +import org.apache.poi.xslf.usermodel.XSLFTextShape; + /** * Demonstrates how to create slides with predefined layout * and fill the placeholder shapes diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial2.java b/src/examples/src/org/apache/poi/examples/xslf/Tutorial2.java index b1c1e1eb6c..78afd7015f 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial2.java +++ b/src/examples/src/org/apache/poi/examples/xslf/Tutorial2.java @@ -14,16 +14,22 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ==================================================================== + * ==================================================================== */ -package org.apache.poi.xslf.usermodel; +package org.apache.poi.examples.xslf; import java.awt.Color; import java.awt.Rectangle; import java.io.FileOutputStream; import java.io.IOException; +import org.apache.poi.xslf.usermodel.XMLSlideShow; +import org.apache.poi.xslf.usermodel.XSLFSlide; +import org.apache.poi.xslf.usermodel.XSLFTextBox; +import org.apache.poi.xslf.usermodel.XSLFTextParagraph; +import org.apache.poi.xslf.usermodel.XSLFTextRun; + /** * Basic paragraph and text formatting */ diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial3.java b/src/examples/src/org/apache/poi/examples/xslf/Tutorial3.java index 15b8660b9b..420605ee75 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial3.java +++ b/src/examples/src/org/apache/poi/examples/xslf/Tutorial3.java @@ -14,16 +14,19 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ==================================================================== + * ==================================================================== */ -package org.apache.poi.xslf.usermodel; +package org.apache.poi.examples.xslf; import java.awt.Rectangle; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.sl.usermodel.Placeholder; +import org.apache.poi.xslf.usermodel.XMLSlideShow; +import org.apache.poi.xslf.usermodel.XSLFSlide; +import org.apache.poi.xslf.usermodel.XSLFTextShape; /** * How to set slide title diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial4.java b/src/examples/src/org/apache/poi/examples/xslf/Tutorial4.java index 68648ab823..a39e9030d8 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial4.java +++ b/src/examples/src/org/apache/poi/examples/xslf/Tutorial4.java @@ -14,10 +14,10 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ==================================================================== + * ==================================================================== */ -package org.apache.poi.xslf.usermodel; +package org.apache.poi.examples.xslf; import java.awt.Color; import java.awt.Rectangle; @@ -26,6 +26,13 @@ import java.io.IOException; import org.apache.poi.sl.usermodel.TableCell.BorderEdge; import org.apache.poi.sl.usermodel.TextParagraph.TextAlign; +import org.apache.poi.xslf.usermodel.XMLSlideShow; +import org.apache.poi.xslf.usermodel.XSLFSlide; +import org.apache.poi.xslf.usermodel.XSLFTable; +import org.apache.poi.xslf.usermodel.XSLFTableCell; +import org.apache.poi.xslf.usermodel.XSLFTableRow; +import org.apache.poi.xslf.usermodel.XSLFTextParagraph; +import org.apache.poi.xslf.usermodel.XSLFTextRun; /** * PPTX Tables diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial5.java b/src/examples/src/org/apache/poi/examples/xslf/Tutorial5.java index 4230cc265d..cc459a17bb 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial5.java +++ b/src/examples/src/org/apache/poi/examples/xslf/Tutorial5.java @@ -14,16 +14,19 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ==================================================================== + * ==================================================================== */ -package org.apache.poi.xslf.usermodel; +package org.apache.poi.examples.xslf; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.sl.usermodel.PictureData.PictureType; +import org.apache.poi.xslf.usermodel.XMLSlideShow; +import org.apache.poi.xslf.usermodel.XSLFPictureData; +import org.apache.poi.xslf.usermodel.XSLFSlide; /** * Images diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial6.java b/src/examples/src/org/apache/poi/examples/xslf/Tutorial6.java index 8ddd6ce3fa..1648e21acf 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial6.java +++ b/src/examples/src/org/apache/poi/examples/xslf/Tutorial6.java @@ -17,12 +17,18 @@ * ==================================================================== */ -package org.apache.poi.xslf.usermodel; +package org.apache.poi.examples.xslf; import java.awt.Rectangle; import java.io.FileOutputStream; import java.io.IOException; +import org.apache.poi.xslf.usermodel.XMLSlideShow; +import org.apache.poi.xslf.usermodel.XSLFHyperlink; +import org.apache.poi.xslf.usermodel.XSLFSlide; +import org.apache.poi.xslf.usermodel.XSLFTextBox; +import org.apache.poi.xslf.usermodel.XSLFTextRun; + /** * Hyperlinks */ diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial7.java b/src/examples/src/org/apache/poi/examples/xslf/Tutorial7.java index 2fcd9c3250..d617de8dbc 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/Tutorial7.java +++ b/src/examples/src/org/apache/poi/examples/xslf/Tutorial7.java @@ -14,10 +14,10 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * ==================================================================== + * ==================================================================== */ -package org.apache.poi.xslf.usermodel; +package org.apache.poi.examples.xslf; import java.awt.Color; import java.awt.Rectangle; @@ -25,6 +25,11 @@ import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.sl.usermodel.AutoNumberingScheme; +import org.apache.poi.xslf.usermodel.XMLSlideShow; +import org.apache.poi.xslf.usermodel.XSLFSlide; +import org.apache.poi.xslf.usermodel.XSLFTextBox; +import org.apache.poi.xslf.usermodel.XSLFTextParagraph; +import org.apache.poi.xslf.usermodel.XSLFTextRun; /** * Bullets and numbering diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/bar-chart-data.txt b/src/examples/src/org/apache/poi/examples/xslf/bar-chart-data.txt index 22c7b86ab8..22c7b86ab8 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/bar-chart-data.txt +++ b/src/examples/src/org/apache/poi/examples/xslf/bar-chart-data.txt diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/bar-chart-template.pptx b/src/examples/src/org/apache/poi/examples/xslf/bar-chart-template.pptx Binary files differindex e4d2613046..e4d2613046 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/bar-chart-template.pptx +++ b/src/examples/src/org/apache/poi/examples/xslf/bar-chart-template.pptx diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/pie-chart-data.txt b/src/examples/src/org/apache/poi/examples/xslf/pie-chart-data.txt index 40b6959c2c..40b6959c2c 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/pie-chart-data.txt +++ b/src/examples/src/org/apache/poi/examples/xslf/pie-chart-data.txt diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/pie-chart-template.pptx b/src/examples/src/org/apache/poi/examples/xslf/pie-chart-template.pptx Binary files differindex 33d28e154c..33d28e154c 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/pie-chart-template.pptx +++ b/src/examples/src/org/apache/poi/examples/xslf/pie-chart-template.pptx diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/tutorial/Step1.java b/src/examples/src/org/apache/poi/examples/xslf/tutorial/Step1.java index 6651bcc4f8..2d384a8389 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/tutorial/Step1.java +++ b/src/examples/src/org/apache/poi/examples/xslf/tutorial/Step1.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.apache.poi.xslf.usermodel.tutorial; +package org.apache.poi.examples.xslf.tutorial; import java.io.FileInputStream; diff --git a/src/examples/src/org/apache/poi/xslf/usermodel/tutorial/Step2.java b/src/examples/src/org/apache/poi/examples/xslf/tutorial/Step2.java index 03fd4f6abb..68fcf14f5c 100644 --- a/src/examples/src/org/apache/poi/xslf/usermodel/tutorial/Step2.java +++ b/src/examples/src/org/apache/poi/examples/xslf/tutorial/Step2.java @@ -17,7 +17,9 @@ * ==================================================================== */ -package org.apache.poi.xslf.usermodel.tutorial; +package org.apache.poi.examples.xslf.tutorial; + +import java.io.FileOutputStream; import org.apache.poi.xslf.usermodel.SlideLayout; import org.apache.poi.xslf.usermodel.XMLSlideShow; @@ -26,8 +28,6 @@ import org.apache.poi.xslf.usermodel.XSLFSlideLayout; import org.apache.poi.xslf.usermodel.XSLFSlideMaster; import org.apache.poi.xslf.usermodel.XSLFTextShape; -import java.io.FileOutputStream; - /** * Create slides from pre-defined slide layouts */ diff --git a/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java b/src/examples/src/org/apache/poi/examples/xssf/eventusermodel/FromHowTo.java index 3c79e1c4fa..4b376a979d 100644 --- a/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/FromHowTo.java +++ b/src/examples/src/org/apache/poi/examples/xssf/eventusermodel/FromHowTo.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.eventusermodel.examples; +package org.apache.poi.examples.xssf.eventusermodel; import java.io.InputStream; import java.util.Iterator; @@ -26,7 +26,6 @@ import javax.xml.parsers.ParserConfigurationException; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackageAccess; import org.apache.poi.util.XMLHelper; -import org.apache.poi.xssf.eventusermodel.XLSX2CSV; import org.apache.poi.xssf.eventusermodel.XSSFReader; import org.apache.poi.xssf.model.SharedStringsTable; import org.xml.sax.Attributes; @@ -133,11 +132,11 @@ public class FromHowTo { throws SAXException { // Process the last contents as required. // Do now, as characters() may be called more than once - if(nextIsString && !lastContents.trim().isEmpty()) { + if(nextIsString) { Integer idx = Integer.valueOf(lastContents); lastContents = lruCache.get(idx); if (lastContents == null && !lruCache.containsKey(idx)) { - lastContents = sst.getItemAt(idx).toString(); + lastContents = sst.getItemAt(idx).getString(); lruCache.put(idx, lastContents); } nextIsString = false; diff --git a/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/LoadPasswordProtectedXlsxStreaming.java b/src/examples/src/org/apache/poi/examples/xssf/eventusermodel/LoadPasswordProtectedXlsxStreaming.java index 7a3ad6b022..96ba25e396 100644 --- a/src/examples/src/org/apache/poi/xssf/eventusermodel/examples/LoadPasswordProtectedXlsxStreaming.java +++ b/src/examples/src/org/apache/poi/examples/xssf/eventusermodel/LoadPasswordProtectedXlsxStreaming.java @@ -17,15 +17,15 @@ * ==================================================================== */ -package org.apache.poi.xssf.eventusermodel.examples; +package org.apache.poi.examples.xssf.eventusermodel; import java.io.InputStream; +import org.apache.poi.examples.xssf.usermodel.LoadPasswordProtectedXlsx; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.poifs.crypt.temp.AesZipFileZipEntrySource; import org.apache.poi.xssf.eventusermodel.XSSFReader; import org.apache.poi.xssf.eventusermodel.XSSFReader.SheetIterator; -import org.apache.poi.xssf.usermodel.examples.LoadPasswordProtectedXlsx; /** * An example that loads a password protected workbook and counts the sheets. diff --git a/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java b/src/examples/src/org/apache/poi/examples/xssf/eventusermodel/XLSX2CSV.java index 5b9a519b28..1786538366 100644 --- a/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java +++ b/src/examples/src/org/apache/poi/examples/xssf/eventusermodel/XLSX2CSV.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.eventusermodel; +package org.apache.poi.examples.xssf.eventusermodel; import java.io.File; import java.io.IOException; @@ -31,6 +31,9 @@ import org.apache.poi.ss.usermodel.DataFormatter; import org.apache.poi.ss.util.CellAddress; import org.apache.poi.ss.util.CellReference; import org.apache.poi.util.XMLHelper; +import org.apache.poi.xssf.eventusermodel.ReadOnlySharedStringsTable; +import org.apache.poi.xssf.eventusermodel.XSSFReader; +import org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler; import org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler.SheetContentsHandler; import org.apache.poi.xssf.extractor.XSSFEventBasedExcelExtractor; import org.apache.poi.xssf.model.SharedStrings; @@ -132,7 +135,7 @@ public class XLSX2CSV { //noinspection ResultOfMethodCallIgnored Double.parseDouble(formattedValue); output.append(formattedValue); - } catch (Exception e) { + } catch (NumberFormatException e) { output.append('"'); output.append(formattedValue); output.append('"'); diff --git a/src/examples/src/org/apache/poi/xssf/streaming/examples/HybridStreaming.java b/src/examples/src/org/apache/poi/examples/xssf/streaming/HybridStreaming.java index 2092475c55..f131e5b6e8 100644 --- a/src/examples/src/org/apache/poi/xssf/streaming/examples/HybridStreaming.java +++ b/src/examples/src/org/apache/poi/examples/xssf/streaming/HybridStreaming.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.streaming.examples; +package org.apache.poi.examples.xssf.streaming; import java.io.FileInputStream; import java.io.IOException; @@ -30,12 +30,12 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet; import org.xml.sax.SAXException; /** - * This demonstrates how a hybrid approach to workbook read can be taken, using + * This demonstrates how a hybrid approach to workbook read can be taken, using * a mix of traditional XSSF and streaming one particular worksheet (perhaps one * which is too big for the ordinary DOM parse). */ public class HybridStreaming { - + private static final String SHEET_TO_STREAM = "large sheet"; public static void main(String[] args) throws IOException, SAXException { @@ -61,15 +61,15 @@ public class HybridStreaming { private static SheetContentsHandler createSheetContentsHandler() { return new SheetContentsHandler() { - + @Override public void startRow(int rowNum) { } - + @Override public void endRow(int rowNum) { } - + @Override public void cell(String cellReference, String formattedValue, XSSFComment comment) { } diff --git a/src/examples/src/org/apache/poi/xssf/streaming/examples/Outlining.java b/src/examples/src/org/apache/poi/examples/xssf/streaming/Outlining.java index 7c892a89a8..bd558e9743 100644 --- a/src/examples/src/org/apache/poi/xssf/streaming/examples/Outlining.java +++ b/src/examples/src/org/apache/poi/examples/xssf/streaming/Outlining.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.streaming.examples; +package org.apache.poi.examples.xssf.streaming; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/streaming/examples/SavePasswordProtectedXlsx.java b/src/examples/src/org/apache/poi/examples/xssf/streaming/SavePasswordProtectedXlsx.java index a20c87e825..f991047db7 100644 --- a/src/examples/src/org/apache/poi/xssf/streaming/examples/SavePasswordProtectedXlsx.java +++ b/src/examples/src/org/apache/poi/examples/xssf/streaming/SavePasswordProtectedXlsx.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.apache.poi.xssf.streaming.examples; +package org.apache.poi.examples.xssf.streaming; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/AligningCells.java index bee89d1dfb..17a92d3d8c 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/AligningCells.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/AligningCells.java @@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; @@ -37,7 +37,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTRowImpl; * Shows how various alignment options work. * * Modified by Cristian Petrula, Romania on May 26, 2010 - * New method was added centerAcrossSelection to center a column content over + * New method was added centerAcrossSelection to center a column content over * one selection using {@link HorizontalAlignment#CENTER_SELECTION} * To create this method example was change for XSSF only and the previous * AligningCells.java example has been moved into the SS examples folder. diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/BarAndLineChart.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/BarAndLineChart.java index 2ad12a3683..e5cf0542b0 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/BarAndLineChart.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/BarAndLineChart.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.util.Random; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/BarChart.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/BarChart.java index 0cd57fc70e..2a3c6a761b 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/BarChart.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/BarChart.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/BigGridDemo.java index 8aaecb4f1a..2afc73a6ab 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/BigGridDemo.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/BigGridDemo.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.File; import java.io.FileInputStream; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/CalendarDemo.java index 11ffafc63e..b97ef1a8b9 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CalendarDemo.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/CalendarDemo.java @@ -15,16 +15,27 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; - -import org.apache.poi.xssf.usermodel.*; -import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.ss.usermodel.*; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.util.Calendar; -import java.util.Map; import java.util.HashMap; +import java.util.Map; + +import org.apache.poi.ss.usermodel.BorderStyle; +import org.apache.poi.ss.usermodel.FillPatternType; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.PrintOrientation; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFCellStyle; +import org.apache.poi.xssf.usermodel.XSSFColor; +import org.apache.poi.xssf.usermodel.XSSFFont; +import org.apache.poi.xssf.usermodel.XSSFPrintSetup; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; /** * A monthly calendar created using Apache POI. Each month is on a separate sheet. diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CellComments.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/CellComments.java index 40f490520b..eb5757779c 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CellComments.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/CellComments.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateCell.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/CreateCell.java index 27bc0601f1..36e93dec2f 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateCell.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/CreateCell.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreatePivotTable.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/CreatePivotTable.java index a048ae4014..991dd2f71a 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreatePivotTable.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/CreatePivotTable.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileNotFoundException; import java.io.FileOutputStream; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreatePivotTable2.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/CreatePivotTable2.java index 27ff990c37..7ba0c78bdf 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreatePivotTable2.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/CreatePivotTable2.java @@ -14,13 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import java.util.Date; import java.util.Calendar; +import java.util.Date; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.SpreadsheetVersion; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateTable.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/CreateTable.java index ad2b6adcdd..7e1d56ad00 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateTable.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/CreateTable.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateUserDefinedDataFormats.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/CreateUserDefinedDataFormats.java index 134560b45c..03d88d67ef 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CreateUserDefinedDataFormats.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/CreateUserDefinedDataFormats.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CustomXMLMapping.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/CustomXMLMapping.java index 9f2ab3d4b7..ebc04a4d33 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/CustomXMLMapping.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/CustomXMLMapping.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.ByteArrayOutputStream; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/EmbeddedObjects.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/EmbeddedObjects.java index 1931af7557..b4af95c5ae 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/EmbeddedObjects.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/EmbeddedObjects.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.Closeable; import java.io.InputStream; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/ExcelChartWithTargetLine.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/ExcelChartWithTargetLine.java index c5a4f8dee8..01cdaf5def 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/ExcelChartWithTargetLine.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/ExcelChartWithTargetLine.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/FillsAndColors.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/FillsAndColors.java index f7ffcf5d42..baf462ce32 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/FillsAndColors.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/FillsAndColors.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/FitSheetToOnePage.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/FitSheetToOnePage.java index 398b8de8fd..389e87fd0b 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/FitSheetToOnePage.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/FitSheetToOnePage.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/HeadersAndFooters.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/HeadersAndFooters.java index fc9860dec0..946ae50fd4 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/HeadersAndFooters.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/HeadersAndFooters.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/HyperlinkExample.java index e5663ecf42..519631960e 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/HyperlinkExample.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/IterateCells.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/IterateCells.java index b7f2930ffc..0b49927977 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/IterateCells.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/IterateCells.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileInputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/LineChart.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/LineChart.java index 0141e17573..268d632a04 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/LineChart.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/LineChart.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/LoadPasswordProtectedXlsx.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/LoadPasswordProtectedXlsx.java index 7afe88f00e..6e376f0f56 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/LoadPasswordProtectedXlsx.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/LoadPasswordProtectedXlsx.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileInputStream; import java.io.InputStream; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/MergingCells.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/MergingCells.java index f9abb80005..22695c53fe 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/MergingCells.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/MergingCells.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/NewLinesInCells.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/NewLinesInCells.java index c3b4c1c0a0..8064260dd8 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/NewLinesInCells.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/NewLinesInCells.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/Outlining.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/Outlining.java index b00b59a308..09f87cd5fa 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/Outlining.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/Outlining.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/ScatterChart.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/ScatterChart.java index 5e10db8591..6946126a39 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/ScatterChart.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/ScatterChart.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/SelectedSheet.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/SelectedSheet.java index ffe384f828..ef6d9470c7 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/SelectedSheet.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/SelectedSheet.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; @@ -24,7 +24,7 @@ import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public abstract class SelectedSheet { - + public static void main(String[]args) throws IOException { try (Workbook wb = new XSSFWorkbook()) { //or new HSSFWorkbook(); diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/ShiftRows.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/ShiftRows.java index 48ab3bf4fd..92d1f4ce6d 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/ShiftRows.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/ShiftRows.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; @@ -26,7 +26,7 @@ import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; /** - * How to shift rows up or down + * How to shift rows up or down */ public class ShiftRows { diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/SplitAndFreezePanes.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/SplitAndFreezePanes.java index dfee2473d9..4a8afee879 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/SplitAndFreezePanes.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/SplitAndFreezePanes.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkbookProperties.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/WorkbookProperties.java index 4e28e9da3a..9bb43f96fc 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkbookProperties.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/WorkbookProperties.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithBorders.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/WorkingWithBorders.java index bdf856fa99..5ffa54aab8 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithBorders.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/WorkingWithBorders.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithFonts.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/WorkingWithFonts.java index b2fa5993b1..a40ae57f42 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithFonts.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/WorkingWithFonts.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.IOException; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPageSetup.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/WorkingWithPageSetup.java index 7da2d53a37..a43c5125a3 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPageSetup.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/WorkingWithPageSetup.java @@ -14,14 +14,14 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; +import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.util.CellRangeAddress; -import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFWorkbook; /** diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/WorkingWithPictures.java index 0bee5e73e9..555bc513d8 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithPictures.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/WorkingWithPictures.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileInputStream; import java.io.FileOutputStream; diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java b/src/examples/src/org/apache/poi/examples/xssf/usermodel/WorkingWithRichText.java index 9fdda45c2c..43376fa1f6 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/WorkingWithRichText.java +++ b/src/examples/src/org/apache/poi/examples/xssf/usermodel/WorkingWithRichText.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.xssf.usermodel.examples; +package org.apache.poi.examples.xssf.usermodel; import java.io.FileOutputStream; import java.io.OutputStream; diff --git a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/BarChartExample.java b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/BarChartExample.java index 2301687c47..89bd260505 100644 --- a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/BarChartExample.java +++ b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/BarChartExample.java @@ -18,7 +18,7 @@ * ==================================================================== */ -package org.apache.poi.xwpf.usermodel.examples; +package org.apache.poi.examples.xwpf.usermodel; import java.io.BufferedReader; import java.io.FileInputStream; diff --git a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/BetterHeaderFooterExample.java b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/BetterHeaderFooterExample.java index 6cd7cfa9e6..39c9d0812e 100644 --- a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/BetterHeaderFooterExample.java +++ b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/BetterHeaderFooterExample.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xwpf.usermodel.examples; +package org.apache.poi.examples.xwpf.usermodel; import java.io.File; import java.io.FileOutputStream; diff --git a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/ChartFromScratch.java b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/ChartFromScratch.java index 266466c141..9eb0e2dd3f 100644 --- a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/ChartFromScratch.java +++ b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/ChartFromScratch.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.apache.poi.xwpf.usermodel.examples; +package org.apache.poi.examples.xwpf.usermodel; import java.io.BufferedReader; import java.io.FileOutputStream; diff --git a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/HeaderFooterTable.java b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/HeaderFooterTable.java index bc40c4d764..70d2b7e588 100644 --- a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/HeaderFooterTable.java +++ b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/HeaderFooterTable.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xwpf.usermodel.examples; +package org.apache.poi.examples.xwpf.usermodel; import java.io.File; import java.io.FileOutputStream; @@ -66,7 +66,7 @@ public class HeaderFooterTable { // Now set up a grid for the table, cells will fit into the grid // Each cell width is 3120 in 1440ths of an inch, or 1/3rd of 6.5" - BigInteger w = BigInteger.valueOf(3120); + BigInteger w = new BigInteger("3120"); CTTblGrid grid = ctTbl.addNewTblGrid(); for (int i = 0; i < 3; i++) { CTTblGridCol gridCol = grid.addNewGridCol(); diff --git a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleDocument.java b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/SimpleDocument.java index 2699015445..57515545cf 100644 --- a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleDocument.java +++ b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/SimpleDocument.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xwpf.usermodel.examples; +package org.apache.poi.examples.xwpf.usermodel; import java.io.FileOutputStream; diff --git a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleDocumentWithHeader.java b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/SimpleDocumentWithHeader.java index 7927e911c7..659f6b6f39 100644 --- a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleDocumentWithHeader.java +++ b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/SimpleDocumentWithHeader.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xwpf.usermodel.examples; +package org.apache.poi.examples.xwpf.usermodel; import java.io.File; import java.io.FileOutputStream; @@ -29,7 +29,7 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText; /** - * + * * @author Richard Ngo * */ diff --git a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleImages.java b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/SimpleImages.java index 9e379955e2..1f996cfd1f 100644 --- a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleImages.java +++ b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/SimpleImages.java @@ -16,7 +16,7 @@ * limitations under the License. * ==================================================================== */ -package org.apache.poi.xwpf.usermodel.examples; +package org.apache.poi.examples.xwpf.usermodel; import java.io.FileInputStream; import java.io.FileOutputStream; diff --git a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleTable.java b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/SimpleTable.java index b09e00bd48..2a67f8f5df 100644 --- a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/SimpleTable.java +++ b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/SimpleTable.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.xwpf.usermodel.examples; +package org.apache.poi.examples.xwpf.usermodel; import java.io.FileOutputStream; import java.io.OutputStream; diff --git a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/UpdateEmbeddedDoc.java b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/UpdateEmbeddedDoc.java index af0eefde46..faf31b3ded 100644 --- a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/UpdateEmbeddedDoc.java +++ b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/UpdateEmbeddedDoc.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.apache.poi.xwpf.usermodel.examples; +package org.apache.poi.examples.xwpf.usermodel; import java.io.File; import java.io.FileInputStream; diff --git a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/bar-chart-data.txt b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/bar-chart-data.txt index 22c7b86ab8..22c7b86ab8 100644 --- a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/bar-chart-data.txt +++ b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/bar-chart-data.txt diff --git a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/bar-chart-template.docx b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/bar-chart-template.docx Binary files differindex ddd57ef0a3..ddd57ef0a3 100644 --- a/src/examples/src/org/apache/poi/xwpf/usermodel/examples/bar-chart-template.docx +++ b/src/examples/src/org/apache/poi/examples/xwpf/usermodel/bar-chart-template.docx diff --git a/src/examples/src/org/apache/poi/xssf/streaming/examples/DeferredGeneration.java b/src/examples/src/org/apache/poi/xssf/streaming/examples/DeferredGeneration.java deleted file mode 100644 index ce1db096ac..0000000000 --- a/src/examples/src/org/apache/poi/xssf/streaming/examples/DeferredGeneration.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * ==================================================================== - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -package org.apache.poi.xssf.streaming.examples; - -import org.apache.poi.xssf.streaming.DeferredSXSSFSheet; -import org.apache.poi.xssf.streaming.DeferredSXSSFWorkbook; -import org.apache.poi.xssf.streaming.SXSSFCell; -import org.apache.poi.xssf.streaming.SXSSFRow; - -import java.io.FileOutputStream; - -/** - * An example that outputs a simple generated workbook that uses deferred creation of the rows in the sheets. - * When the workbook is written to an output stream, the output data is streamed immediately. - * There is no collation of the data in temp files prior to writing the overall file. - * This depends on how efficient the row generating functions are. - */ -public final class DeferredGeneration { - - private DeferredGeneration() {} - - public static void main(String[] args) throws Exception { - String filename; - if(args.length == 0) { - filename = "deferred-generation.xlsx"; - } else { - filename = args[0]; - } - try (DeferredSXSSFWorkbook wb = new DeferredSXSSFWorkbook()){ - for(int i = 0; i < 10; i++) { - DeferredSXSSFSheet sheet = wb.createSheet("Sheet" + i); - sheet.setRowGenerator((sh) -> { - for (int r = 0; r < 1000; r++) { - SXSSFRow row = sheet.createRow(r); - for (int c = 0; c < 100; c++) { - SXSSFCell cell = row.createCell(c); - cell.setCellValue("abcd"); - } - } - }); - } - wb.write(new FileOutputStream(filename)); - System.out.println("wrote " + filename); - } - } -} diff --git a/src/excelant/testcases/org/apache/poi/ss/examples/formula/CalculateMortgageFunction.java b/src/excelant/testcases/org/apache/poi/ss/excelant/CalculateMortgageFunction.java index 2e2e62bf81..73eb984db7 100644 --- a/src/excelant/testcases/org/apache/poi/ss/examples/formula/CalculateMortgageFunction.java +++ b/src/excelant/testcases/org/apache/poi/ss/excelant/CalculateMortgageFunction.java @@ -14,21 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples.formula; +package org.apache.poi.ss.excelant; -import org.apache.poi.ss.formula.OperationEvaluationContext ; -import org.apache.poi.ss.formula.eval.ErrorEval ; -import org.apache.poi.ss.formula.eval.EvaluationException ; -import org.apache.poi.ss.formula.eval.NumberEval ; -import org.apache.poi.ss.formula.eval.OperandResolver ; -import org.apache.poi.ss.formula.eval.ValueEval ; -import org.apache.poi.ss.formula.functions.FreeRefFunction ; +import org.apache.poi.ss.formula.OperationEvaluationContext; +import org.apache.poi.ss.formula.eval.ErrorEval; +import org.apache.poi.ss.formula.eval.EvaluationException; +import org.apache.poi.ss.formula.eval.NumberEval; +import org.apache.poi.ss.formula.eval.OperandResolver; +import org.apache.poi.ss.formula.eval.ValueEval; +import org.apache.poi.ss.formula.functions.FreeRefFunction; /** * A simple user-defined function to calculate principal and interest. * * Used by {@link org.apache.poi.ss.excelant.util.TestExcelAntWorkbookUtil}. - * + * * @author Jon Svede ( jon [at] loquatic [dot] com ) * @author Brian Bush ( brian [dot] bush [at] nrel [dot] gov ) * @@ -37,9 +37,9 @@ public class CalculateMortgageFunction implements FreeRefFunction { @Override public ValueEval evaluate( ValueEval[] args, OperationEvaluationContext ec ) { - + // verify that we have enough data - if (args.length != 3) { + if (args.length != 3) { return ErrorEval.VALUE_INVALID; } @@ -47,33 +47,33 @@ public class CalculateMortgageFunction implements FreeRefFunction { double principal, rate, years, result; try { // extract values as ValueEval - ValueEval v1 = OperandResolver.getSingleValue( args[0], - ec.getRowIndex(), + ValueEval v1 = OperandResolver.getSingleValue( args[0], + ec.getRowIndex(), ec.getColumnIndex() ) ; - ValueEval v2 = OperandResolver.getSingleValue( args[1], - ec.getRowIndex(), + ValueEval v2 = OperandResolver.getSingleValue( args[1], + ec.getRowIndex(), ec.getColumnIndex() ) ; - ValueEval v3 = OperandResolver.getSingleValue( args[2], - ec.getRowIndex(), + ValueEval v3 = OperandResolver.getSingleValue( args[2], + ec.getRowIndex(), ec.getColumnIndex() ) ; // get data as doubles - principal = OperandResolver.coerceValueToDouble( v1 ) ; + principal = OperandResolver.coerceValueToDouble( v1 ) ; rate = OperandResolver.coerceValueToDouble( v2 ) ; years = OperandResolver.coerceValueToDouble( v3 ) ; - + result = calculateMortgagePayment( principal, rate, years ) ; System.out.println( "Result = " + result ) ; checkValue(result); - + } catch (EvaluationException e) { return e.getErrorEval(); } return new NumberEval( result ) ; } - + public double calculateMortgagePayment( double p, double r, double y ) { double i = r / 12 ; double n = y * 12 ; @@ -89,5 +89,5 @@ public class CalculateMortgageFunction implements FreeRefFunction { if (Double.isNaN(result) || Double.isInfinite(result)) { throw new EvaluationException(ErrorEval.NUM_ERROR); } - } + } } diff --git a/src/excelant/testcases/org/apache/poi/ss/examples/formula/ExcelAntUserDefinedFunctionTestHelper.java b/src/excelant/testcases/org/apache/poi/ss/excelant/ExcelAntUserDefinedFunctionTestHelper.java index 68e4b6957f..48086fc22d 100644 --- a/src/excelant/testcases/org/apache/poi/ss/examples/formula/ExcelAntUserDefinedFunctionTestHelper.java +++ b/src/excelant/testcases/org/apache/poi/ss/excelant/ExcelAntUserDefinedFunctionTestHelper.java @@ -14,9 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples.formula; - -import org.apache.poi.ss.excelant.ExcelAntUserDefinedFunction; +package org.apache.poi.ss.excelant; public class ExcelAntUserDefinedFunctionTestHelper extends ExcelAntUserDefinedFunction { diff --git a/src/excelant/testcases/org/apache/poi/ss/examples/formula/TestExcelAntUserDefinedFunction.java b/src/excelant/testcases/org/apache/poi/ss/excelant/TestExcelAntUserDefinedFunction.java index 0606a8bd89..73b10806ab 100644 --- a/src/excelant/testcases/org/apache/poi/ss/examples/formula/TestExcelAntUserDefinedFunction.java +++ b/src/excelant/testcases/org/apache/poi/ss/excelant/TestExcelAntUserDefinedFunction.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.ss.examples.formula; +package org.apache.poi.ss.excelant; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; diff --git a/src/excelant/testcases/org/apache/poi/ss/excelant/tests.xml b/src/excelant/testcases/org/apache/poi/ss/excelant/tests.xml index d387aab365..0882195551 100644 --- a/src/excelant/testcases/org/apache/poi/ss/excelant/tests.xml +++ b/src/excelant/testcases/org/apache/poi/ss/excelant/tests.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<!-- +<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information @@ -164,7 +164,7 @@ under the License. <target name="test-udf"> <poi:excelant fileName="${data.dir.name}/spreadsheet/excelant.xls"> <poi:udf functionAlias="calculatePayment" - className="org.apache.poi.ss.examples.formula.CalculateMortgageFunction"/> + className="org.apache.poi.ss.excelant.CalculateMortgageFunction"/> <poi:test> <poi:setDouble cell="'MortageCalculatorFunction'!$B$1" value="240000"/> <poi:setDouble cell="'MortageCalculatorFunction'!$B$2" value ="0.11"/> diff --git a/src/excelant/testcases/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtil.java b/src/excelant/testcases/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtil.java index 3771405cb6..b6c7df7a29 100644 --- a/src/excelant/testcases/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtil.java +++ b/src/excelant/testcases/org/apache/poi/ss/excelant/util/TestExcelAntWorkbookUtil.java @@ -29,7 +29,7 @@ import java.io.IOException; import java.util.Date; import java.util.List; -import org.apache.poi.ss.examples.formula.CalculateMortgageFunction; +import org.apache.poi.ss.excelant.CalculateMortgageFunction; import org.apache.poi.ss.excelant.TestBuildFile; import org.apache.poi.ss.formula.udf.UDFFinder; import org.apache.poi.ss.usermodel.DateUtil; diff --git a/src/integrationtest/org/apache/poi/BaseIntegrationTest.java b/src/integrationtest/org/apache/poi/stress/BaseIntegrationTest.java index 10c534eacc..8abe9fcff0 100644 --- a/src/integrationtest/org/apache/poi/BaseIntegrationTest.java +++ b/src/integrationtest/org/apache/poi/stress/BaseIntegrationTest.java @@ -14,17 +14,9 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi; +package org.apache.poi.stress; -import org.apache.poi.poifs.filesystem.OfficeXmlFileException; -import org.apache.poi.stress.FileHandler; -import org.apache.poi.stress.HSLFFileHandler; -import org.apache.poi.stress.HSSFFileHandler; -import org.apache.poi.stress.HWPFFileHandler; -import org.apache.poi.stress.XSLFFileHandler; -import org.apache.poi.stress.XSSFFileHandler; -import org.apache.poi.stress.XWPFFileHandler; -import org.junit.Assume; +import static org.junit.Assert.assertNotNull; import java.io.BufferedInputStream; import java.io.File; @@ -33,7 +25,10 @@ import java.io.IOException; import java.io.InputStream; import java.util.zip.ZipException; -import static org.junit.Assert.assertNotNull; +import org.apache.poi.EncryptedDocumentException; +import org.apache.poi.OldFileFormatException; +import org.apache.poi.poifs.filesystem.OfficeXmlFileException; +import org.junit.Assume; /** * This class is used for mass-regression testing via a diff --git a/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java index ba2e1bc617..2c125db1c0 100644 --- a/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java @@ -30,12 +30,12 @@ import java.util.Collections; import java.util.HashSet; import java.util.Set; +import org.apache.poi.examples.hpsf.CopyCompare; import org.apache.poi.hpsf.DocumentSummaryInformation; import org.apache.poi.hpsf.HPSFPropertiesOnlyDocument; import org.apache.poi.hpsf.MarkUnsupportedException; import org.apache.poi.hpsf.PropertySet; import org.apache.poi.hpsf.SummaryInformation; -import org.apache.poi.hpsf.examples.CopyCompare; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.DocumentInputStream; import org.apache.poi.poifs.filesystem.POIFSFileSystem; diff --git a/src/integrationtest/org/apache/poi/hssf/usermodel/RecordsStresser.java b/src/integrationtest/org/apache/poi/stress/HSSFRecordsStresser.java index d277d40e8a..932fd396b1 100644 --- a/src/integrationtest/org/apache/poi/hssf/usermodel/RecordsStresser.java +++ b/src/integrationtest/org/apache/poi/stress/HSSFRecordsStresser.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.hssf.usermodel; +package org.apache.poi.stress; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; @@ -25,13 +25,14 @@ import java.io.InputStream; import java.util.List; import org.apache.poi.hssf.record.Record; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.junit.Test; /** * Needs to be implemented in this package to have access to * HSSFWorkbook.getWorkbook() */ -public class RecordsStresser { +public class HSSFRecordsStresser { public static void handleWorkbook(HSSFWorkbook wb) { List<org.apache.poi.hssf.record.Record> records = wb.getWorkbook().getRecords(); for(org.apache.poi.hssf.record.Record record : records) { diff --git a/src/integrationtest/org/apache/poi/HeapDump.java b/src/integrationtest/org/apache/poi/stress/HeapDump.java index 625527d84e..59a3832b59 100644 --- a/src/integrationtest/org/apache/poi/HeapDump.java +++ b/src/integrationtest/org/apache/poi/stress/HeapDump.java @@ -14,13 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi; - -import com.sun.management.HotSpotDiagnosticMXBean; +package org.apache.poi.stress; import java.io.IOException; import java.lang.management.ManagementFactory; +import com.sun.management.HotSpotDiagnosticMXBean; + public class HeapDump { // This is the name of the HotSpot Diagnostic MBean private static final String HOTSPOT_BEAN_NAME = diff --git a/src/integrationtest/org/apache/poi/POIFileScanner.java b/src/integrationtest/org/apache/poi/stress/POIFileScanner.java index 4e8c002c9d..947e709dd2 100644 --- a/src/integrationtest/org/apache/poi/POIFileScanner.java +++ b/src/integrationtest/org/apache/poi/stress/POIFileScanner.java @@ -17,7 +17,18 @@ * ==================================================================== */ -package org.apache.poi; +package org.apache.poi.stress; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hwpf.HWPFDocument; @@ -25,25 +36,12 @@ import org.apache.poi.poifs.filesystem.FileMagic; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; -import org.apache.poi.stress.FileHandler; -import org.apache.poi.stress.XSSFFileHandler; import org.apache.poi.util.SuppressForbidden; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.tools.ant.DirectoryScanner; import org.junit.Ignore; import org.junit.Test; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.AbstractMap; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.assertEquals; - /** * Helper class to scan a folder for files and return a collection of * found files together with the matching {@link FileHandler}. @@ -65,7 +63,7 @@ public class POIFileScanner { * Scan a folder for files and return a collection of * found files together with the matching {@link FileHandler}. * - * Note: unknown files will be assigned to {@link org.apache.poi.TestAllFiles.NullFileHandler} + * Note: unknown files will be assigned to {@link TestAllFiles.NullFileHandler} * * @param rootDir The directory to scan * @return A collection with file-FileHandler pairs which can be used for running tests on that file @@ -110,7 +108,7 @@ public class POIFileScanner { * * @param rootDir The directory where the file resides * @param file The name of the file without directory - * @return The matching {@link FileHandler}, A {@link org.apache.poi.TestAllFiles.NullFileHandler} + * @return The matching {@link FileHandler}, A {@link TestAllFiles.NullFileHandler} * is returned if no match is found * @throws IOException If determining the file-type fails */ diff --git a/src/integrationtest/org/apache/poi/TestAllFiles.java b/src/integrationtest/org/apache/poi/stress/TestAllFiles.java index 6a54ba2d45..d95b156ccc 100644 --- a/src/integrationtest/org/apache/poi/TestAllFiles.java +++ b/src/integrationtest/org/apache/poi/stress/TestAllFiles.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi; +package org.apache.poi.stress; import static org.junit.Assert.assertFalse; @@ -35,25 +35,9 @@ import java.util.Locale; import java.util.Map; import java.util.Set; +import org.apache.poi.OldFileFormatException; import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey; import org.apache.poi.poifs.crypt.Decryptor; -import org.apache.poi.stress.AbstractFileHandler; -import org.apache.poi.stress.FileHandler; -import org.apache.poi.stress.HDGFFileHandler; -import org.apache.poi.stress.HMEFFileHandler; -import org.apache.poi.stress.HPBFFileHandler; -import org.apache.poi.stress.HPSFFileHandler; -import org.apache.poi.stress.HSLFFileHandler; -import org.apache.poi.stress.HSMFFileHandler; -import org.apache.poi.stress.HSSFFileHandler; -import org.apache.poi.stress.HWPFFileHandler; -import org.apache.poi.stress.OPCFileHandler; -import org.apache.poi.stress.POIFSFileHandler; -import org.apache.poi.stress.XDGFFileHandler; -import org.apache.poi.stress.XSLFFileHandler; -import org.apache.poi.stress.XSSFBFileHandler; -import org.apache.poi.stress.XSSFFileHandler; -import org.apache.poi.stress.XWPFFileHandler; import org.apache.tools.ant.DirectoryScanner; import org.junit.AssumptionViolatedException; import org.junit.Before; diff --git a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java index 0505d72df9..c0f88768b8 100644 --- a/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java +++ b/src/integrationtest/org/apache/poi/stress/XSSFFileHandler.java @@ -38,8 +38,11 @@ import java.util.Set; import javax.xml.transform.TransformerException; import org.apache.poi.EncryptedDocumentException; -import org.apache.poi.ooxml.POIXMLException; +import org.apache.poi.examples.ss.ExcelComparator; +import org.apache.poi.examples.xssf.eventusermodel.FromHowTo; +import org.apache.poi.examples.xssf.eventusermodel.XLSX2CSV; import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey; +import org.apache.poi.ooxml.POIXMLException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException; import org.apache.poi.openxml4j.exceptions.OpenXML4JException; @@ -47,11 +50,8 @@ import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.poifs.crypt.Decryptor; import org.apache.poi.poifs.crypt.EncryptionInfo; import org.apache.poi.poifs.filesystem.POIFSFileSystem; -import org.apache.poi.ss.examples.ExcelComparator; import org.apache.poi.util.IOUtils; -import org.apache.poi.xssf.eventusermodel.XLSX2CSV; import org.apache.poi.xssf.eventusermodel.XSSFReader; -import org.apache.poi.xssf.eventusermodel.examples.FromHowTo; import org.apache.poi.xssf.extractor.XSSFExportToXml; import org.apache.poi.xssf.usermodel.XSSFMap; import org.apache.poi.xssf.usermodel.XSSFWorkbook; @@ -99,27 +99,27 @@ public class XSSFFileHandler extends SpreadsheetHandler { // use the combined handler for HSSF/XSSF handleWorkbook(wb); - + // TODO: some documents fail currently... //XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); //evaluator.evaluateAll(); // also verify general POIFS-stuff new POIXMLDocumentHandler().handlePOIXMLDocument(wb); - + // and finally ensure that exporting to XML works exportToXML(wb); // this allows to trigger a heap-dump at this point to see which memory is still allocated //HeapDump.dumpHeap("/tmp/poi.hprof", false); - + wb.close(); } private void checkXSSFReader(OPCPackage p) throws IOException, OpenXML4JException { XSSFReader reader = new XSSFReader(p); - + // these can be null... InputStream sharedStringsData = reader.getSharedStringsData(); if(sharedStringsData != null) { @@ -132,21 +132,21 @@ public class XSSFFileHandler extends SpreadsheetHandler { stylesData.close(); } reader.getStylesTable(); - + InputStream themesData = reader.getThemesData(); if(themesData != null) { themesData.close(); } assertNotNull(reader.getWorkbookData()); - + Iterator<InputStream> sheetsData = reader.getSheetsData(); while(sheetsData.hasNext()) { InputStream str = sheetsData.next(); str.close(); } } - + private void exportToXML(XSSFWorkbook wb) throws SAXException, TransformerException { for (XSSFMap map : wb.getCustomXMLMappings()) { @@ -221,8 +221,8 @@ public class XSSFFileHandler extends SpreadsheetHandler { public void testAdditional() throws Exception { handleAdditional(new File("test-data/spreadsheet/poc-xmlbomb.xlsx")); } - - // need to override all methods to omit calls to UTF-handling methods + + // need to override all methods to omit calls to UTF-handling methods static class NullPrintStream extends PrintStream { @SuppressWarnings("resource") NullPrintStream() { diff --git a/src/java/org/apache/poi/POIDocument.java b/src/java/org/apache/poi/POIDocument.java index e7d8afa8d7..06a76a952b 100644 --- a/src/java/org/apache/poi/POIDocument.java +++ b/src/java/org/apache/poi/POIDocument.java @@ -49,7 +49,7 @@ import org.apache.poi.util.POILogger; /** * This holds the common functionality for all POI * Document classes. - * Currently, this relates to Document Information Properties + * Currently, this relates to Document Information Properties */ public abstract class POIDocument implements Closeable { /** Holds metadata on our document */ @@ -76,7 +76,7 @@ public abstract class POIDocument implements Closeable { /** * Constructs from the default POIFS - * + * * @param fs the filesystem the document is read from */ protected POIDocument(POIFSFileSystem fs) { @@ -85,8 +85,8 @@ public abstract class POIDocument implements Closeable { /** * Fetch the Document Summary Information of the document - * - * @return The Document Summary Information or null + * + * @return The Document Summary Information or null * if it could not be read for this document. */ public DocumentSummaryInformation getDocumentSummaryInformation() { @@ -96,9 +96,9 @@ public abstract class POIDocument implements Closeable { return dsInf; } - /** + /** * Fetch the Summary Information of the document - * + * * @return The Summary information for the document or null * if it could not be read for this document. */ @@ -108,7 +108,7 @@ public abstract class POIDocument implements Closeable { } return sInf; } - + /** * Will create whichever of SummaryInformation * and DocumentSummaryInformation (HPSF) properties @@ -136,7 +136,8 @@ public abstract class POIDocument implements Closeable { * If a given property set is missing or corrupt, * it will remain null; */ - protected void readProperties() { + @Internal + public void readProperties() { if (initialized) { return; } @@ -170,11 +171,11 @@ public abstract class POIDocument implements Closeable { } return null; } - - /** + + /** * For a given named property entry, either return it or null if * if it wasn't found - * + * * @param setName The property to read * @return The value of the given property or null if it wasn't found. * @@ -184,11 +185,11 @@ public abstract class POIDocument implements Closeable { protected PropertySet getPropertySet(String setName) throws IOException { return getPropertySet(setName, getEncryptionInfo()); } - - /** + + /** * For a given named property entry, either return it or null if * if it wasn't found - * + * * @param setName The property to read * @param encryptionInfo the encryption descriptor in case of cryptoAPI encryption * @return The value of the given property or null if it wasn't found. @@ -198,7 +199,7 @@ public abstract class POIDocument implements Closeable { @SuppressWarnings("WeakerAccess") protected PropertySet getPropertySet(String setName, EncryptionInfo encryptionInfo) throws IOException { DirectoryNode dirNode = directory; - + POIFSFileSystem encPoifs = null; String step = "getting"; try { @@ -212,12 +213,12 @@ public abstract class POIDocument implements Closeable { encPoifs = dec.getSummaryEntries(dirNode, encryptedStream); dirNode = encPoifs.getRoot(); } - + //directory can be null when creating new documents if (dirNode == null || !dirNode.hasEntry(setName)) { return null; } - + // Find the entry, and get an input stream for it step = "getting"; try (DocumentInputStream dis = dirNode.createDocumentInputStream(dirNode.getEntry(setName))) { @@ -233,11 +234,11 @@ public abstract class POIDocument implements Closeable { IOUtils.closeQuietly(encPoifs); } } - + /** * Writes out the updated standard Document Information Properties (HPSF) * into the currently open POIFSFileSystem - * + * * @throws IOException if an error when writing to the open * {@link POIFSFileSystem} occurs */ @@ -249,19 +250,20 @@ public abstract class POIDocument implements Closeable { /** * Writes out the standard Document Information Properties (HPSF) * @param outFS the POIFSFileSystem to write the properties into - * - * @throws IOException if an error when writing to the + * + * @throws IOException if an error when writing to the * {@link POIFSFileSystem} occurs */ - protected void writeProperties(POIFSFileSystem outFS) throws IOException { + @Internal + public void writeProperties(POIFSFileSystem outFS) throws IOException { writeProperties(outFS, null); } /** * Writes out the standard Document Information Properties (HPSF) * @param outFS the {@link POIFSFileSystem} to write the properties into * @param writtenEntries a list of POIFS entries to add the property names too - * - * @throws IOException if an error when writing to the + * + * @throws IOException if an error when writing to the * {@link POIFSFileSystem} occurs */ protected void writeProperties(POIFSFileSystem outFS, List<String> writtenEntries) throws IOException { @@ -308,15 +310,15 @@ public abstract class POIDocument implements Closeable { writtenEntries.add(name); } } - + /** * Writes out a given PropertySet * * @param name the (POIFS Level) name of the property to write - * @param set the PropertySet to write out + * @param set the PropertySet to write out * @param outFS the {@link POIFSFileSystem} to write the property into - * - * @throws IOException if an error when writing to the + * + * @throws IOException if an error when writing to the * {@link POIFSFileSystem} occurs */ private void writePropertySet(String name, PropertySet set, POIFSFileSystem outFS) throws IOException { @@ -341,7 +343,7 @@ public abstract class POIDocument implements Closeable { * Called during a {@link #write()} to ensure that the Document (and * associated {@link POIFSFileSystem}) was opened in a way compatible * with an in-place write. - * + * * @throws IllegalStateException if the document was opened suitably */ protected void validateInPlaceWritePossible() throws IllegalStateException { @@ -356,32 +358,32 @@ public abstract class POIDocument implements Closeable { throw new IllegalStateException("Opened read-only or via an InputStream, a Writeable File is required"); } } - + /** * Writes the document out to the currently open {@link File}, via the * writeable {@link POIFSFileSystem} it was opened from. - * + * * <p>This will fail (with an {@link IllegalStateException} if the * document was opened read-only, opened from an {@link InputStream} - * instead of a File, or if this is not the root document. For those cases, - * you must use {@link #write(OutputStream)} or {@link #write(File)} to + * instead of a File, or if this is not the root document. For those cases, + * you must use {@link #write(OutputStream)} or {@link #write(File)} to * write to a brand new document. - * + * * @since POI 3.15 beta 3 - * + * * @throws IOException thrown on errors writing to the file * @throws IllegalStateException if this isn't from a writable File */ public abstract void write() throws IOException; /** - * Writes the document out to the specified new {@link File}. If the file + * Writes the document out to the specified new {@link File}. If the file * exists, it will be replaced, otherwise a new one will be created * * @since POI 3.15 beta 3 - * + * * @param newFile The new File to write to. - * + * * @throws IOException thrown on errors writing to the file */ public abstract void write(File newFile) throws IOException; @@ -389,20 +391,20 @@ public abstract class POIDocument implements Closeable { /** * Writes the document out to the specified output stream. The * stream is not closed as part of this operation. - * + * * Note - if the Document was opened from a {@link File} rather * than an {@link InputStream}, you <b>must</b> write out using * {@link #write()} or to a different File. Overwriting the currently * open file via an OutputStream isn't possible. - * + * * If {@code stream} is a {@link java.io.FileOutputStream} on a networked drive * or has a high cost/latency associated with each written byte, * consider wrapping the OutputStream in a {@link java.io.BufferedOutputStream} * to improve write performance, or use {@link #write()} / {@link #write(File)} * if possible. - * + * * @param out The stream to write to. - * + * * @throws IOException thrown on errors writing to the stream */ public abstract void write(OutputStream out) throws IOException; @@ -429,7 +431,7 @@ public abstract class POIDocument implements Closeable { public DirectoryNode getDirectory() { return directory; } - + /** * Clear/unlink the attached directory entry */ @@ -437,11 +439,11 @@ public abstract class POIDocument implements Closeable { protected void clearDirectory() { directory = null; } - + /** * check if we were created by POIFS otherwise create a new dummy POIFS * for storing the package data - * + * * @return {@code true} if dummy directory was created, {@code false} otherwise */ @SuppressWarnings("resource") @@ -453,7 +455,7 @@ public abstract class POIDocument implements Closeable { } return false; } - + /** * Replaces the attached directory, e.g. if this document is written * to a new POIFSFileSystem diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java index db4fa77a0e..6ce74d1206 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java @@ -1546,7 +1546,8 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss } } - /*package*/ InternalWorkbook getWorkbook() { + @Internal + public InternalWorkbook getWorkbook() { return workbook; } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbookFactory.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbookFactory.java index 1d826e4c10..0c4c98a7c2 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbookFactory.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbookFactory.java @@ -17,11 +17,17 @@ package org.apache.poi.hssf.usermodel; +import java.io.File; import java.io.IOException; +import java.io.InputStream; +import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey; import org.apache.poi.poifs.filesystem.DirectoryNode; +import org.apache.poi.poifs.filesystem.FileMagic; import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.apache.poi.ss.usermodel.WorkbookProvider; import org.apache.poi.util.Internal; /** @@ -30,15 +36,11 @@ import org.apache.poi.util.Internal; */ @SuppressWarnings("unused") @Internal -public class HSSFWorkbookFactory extends WorkbookFactory { +public class HSSFWorkbookFactory implements WorkbookProvider { - static { - init(); - } - - public static void init() { - WorkbookFactory.createHssfFromScratch = HSSFWorkbookFactory::createWorkbook; - WorkbookFactory.createHssfByNode = HSSFWorkbookFactory::createWorkbook; + @Override + public boolean accepts(FileMagic fm) { + return FileMagic.OLE2 == fm; } /** @@ -46,7 +48,7 @@ public class HSSFWorkbookFactory extends WorkbookFactory { * * @return The created workbook */ - public static HSSFWorkbook createWorkbook() { + public HSSFWorkbook create() { return new HSSFWorkbook(); } @@ -64,7 +66,45 @@ public class HSSFWorkbookFactory extends WorkbookFactory { * Note that in order to properly release resources the * Workbook should be closed after use. */ - public static HSSFWorkbook createWorkbook(final DirectoryNode root) throws IOException { - return new HSSFWorkbook(root, true); + public HSSFWorkbook create(final DirectoryNode root, String password) throws IOException { + boolean passwordSet = false; + if (password != null) { + Biff8EncryptionKey.setCurrentUserPassword(password); + passwordSet = true; + } + try { + return new HSSFWorkbook(root, true); + } finally { + if (passwordSet) { + Biff8EncryptionKey.setCurrentUserPassword(null); + } + } + } + + @Override + public Workbook create(InputStream inp) throws IOException { + return create(inp, null); + } + + @Override + public Workbook create(InputStream inp, String password) throws IOException { + POIFSFileSystem fs = new POIFSFileSystem(inp); + return create(fs.getRoot(), password); + } + + @Override + public Workbook create(File file, String password, boolean readOnly) throws IOException { + boolean passwordSet = false; + if (password != null) { + Biff8EncryptionKey.setCurrentUserPassword(password); + passwordSet = true; + } + try { + return new HSSFWorkbook(new POIFSFileSystem(file, readOnly), true); + } finally { + if (passwordSet) { + Biff8EncryptionKey.setCurrentUserPassword(null); + } + } } } diff --git a/src/java/org/apache/poi/poifs/crypt/ChainingMode.java b/src/java/org/apache/poi/poifs/crypt/ChainingMode.java index 88c2c8493c..f32910e1ab 100644 --- a/src/java/org/apache/poi/poifs/crypt/ChainingMode.java +++ b/src/java/org/apache/poi/poifs/crypt/ChainingMode.java @@ -19,15 +19,27 @@ package org.apache.poi.poifs.crypt; public enum ChainingMode { // ecb - only for standard encryption - ecb("ECB", 1), - cbc("CBC", 2), + ecb("ECB", 1, null), + cbc("CBC", 2, "ChainingModeCBC"), /* Cipher feedback chaining (CFB), with an 8-bit window */ - cfb("CFB8", 3); + cfb("CFB8", 3, "ChainingModeCFB"); public final String jceId; public final int ecmaId; - ChainingMode(String jceId, int ecmaId) { + public final String xmlId; + + ChainingMode(String jceId, int ecmaId, String xmlId) { this.jceId = jceId; this.ecmaId = ecmaId; + this.xmlId = xmlId; + } + + public static ChainingMode fromXmlId(String xmlId) { + for (ChainingMode cm : values()) { + if (cm.xmlId != null && cm.xmlId.equals(xmlId)) { + return cm; + } + } + return null; } }
\ No newline at end of file diff --git a/src/java/org/apache/poi/poifs/crypt/EncryptionHeader.java b/src/java/org/apache/poi/poifs/crypt/EncryptionHeader.java index 38f666e15e..f10dda09bd 100644 --- a/src/java/org/apache/poi/poifs/crypt/EncryptionHeader.java +++ b/src/java/org/apache/poi/poifs/crypt/EncryptionHeader.java @@ -86,7 +86,7 @@ public abstract class EncryptionHeader implements GenericRecord, Duplicatable { return flags; } - protected void setFlags(int flags) { + public void setFlags(int flags) { this.flags = flags; } @@ -94,7 +94,7 @@ public abstract class EncryptionHeader implements GenericRecord, Duplicatable { return sizeExtra; } - protected void setSizeExtra(int sizeExtra) { + public void setSizeExtra(int sizeExtra) { this.sizeExtra = sizeExtra; } @@ -102,7 +102,7 @@ public abstract class EncryptionHeader implements GenericRecord, Duplicatable { return cipherAlgorithm; } - protected void setCipherAlgorithm(CipherAlgorithm cipherAlgorithm) { + public void setCipherAlgorithm(CipherAlgorithm cipherAlgorithm) { this.cipherAlgorithm = cipherAlgorithm; if (cipherAlgorithm.allowedKeySize.length == 1) { setKeySize(cipherAlgorithm.defaultKeySize); @@ -113,7 +113,7 @@ public abstract class EncryptionHeader implements GenericRecord, Duplicatable { return hashAlgorithm; } - protected void setHashAlgorithm(HashAlgorithm hashAlgorithm) { + public void setHashAlgorithm(HashAlgorithm hashAlgorithm) { this.hashAlgorithm = hashAlgorithm; } @@ -128,7 +128,7 @@ public abstract class EncryptionHeader implements GenericRecord, Duplicatable { * * @param keyBits */ - protected void setKeySize(int keyBits) { + public void setKeySize(int keyBits) { this.keyBits = keyBits; for (int allowedBits : getCipherAlgorithm().allowedKeySize) { if (allowedBits == keyBits) { @@ -142,7 +142,7 @@ public abstract class EncryptionHeader implements GenericRecord, Duplicatable { return blockSize; } - protected void setBlockSize(int blockSize) { + public void setBlockSize(int blockSize) { this.blockSize = blockSize; } @@ -150,7 +150,7 @@ public abstract class EncryptionHeader implements GenericRecord, Duplicatable { return keySalt; } - protected void setKeySalt(byte[] salt) { + public void setKeySalt(byte[] salt) { this.keySalt = (salt == null) ? null : salt.clone(); } @@ -158,7 +158,7 @@ public abstract class EncryptionHeader implements GenericRecord, Duplicatable { return providerType; } - protected void setCipherProvider(CipherProvider providerType) { + public void setCipherProvider(CipherProvider providerType) { this.providerType = providerType; } @@ -166,7 +166,7 @@ public abstract class EncryptionHeader implements GenericRecord, Duplicatable { return cspName; } - protected void setCspName(String cspName) { + public void setCspName(String cspName) { this.cspName = cspName; } diff --git a/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java b/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java index 81aca4e417..17a9136fe4 100644 --- a/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java +++ b/src/java/org/apache/poi/poifs/crypt/EncryptionInfo.java @@ -43,6 +43,12 @@ import org.apache.poi.util.LittleEndianInput; * @see #getBuilder(EncryptionMode) */ public class EncryptionInfo implements GenericRecord { + + /** + * Document entry name for encryption info xml descriptor + */ + public static final String ENCRYPTION_INFO_ENTRY = "EncryptionInfo"; + /** * A flag that specifies whether CryptoAPI RC4 or ECMA-376 encryption * ECMA-376 is used. It MUST be 1 unless flagExternal is 1. If flagExternal is 1, it MUST be 0. @@ -110,25 +116,16 @@ public class EncryptionInfo implements GenericRecord { versionMinor = dis.readUShort(); } - if ( versionMajor == xor.versionMajor - && versionMinor == xor.versionMinor) { + if (versionMajor == xor.versionMajor && versionMinor == xor.versionMinor) { encryptionMode = xor; encryptionFlags = -1; - } else if ( versionMajor == binaryRC4.versionMajor - && versionMinor == binaryRC4.versionMinor) { + } else if (versionMajor == binaryRC4.versionMajor && versionMinor == binaryRC4.versionMinor) { encryptionMode = binaryRC4; encryptionFlags = -1; - } else if ( - 2 <= versionMajor && versionMajor <= 4 - && versionMinor == 2) { + } else if (2 <= versionMajor && versionMajor <= 4 && versionMinor == 2) { encryptionFlags = dis.readInt(); - encryptionMode = ( - preferredEncryptionMode == cryptoAPI - || !flagAES.isSet(encryptionFlags)) - ? cryptoAPI : standard; - } else if ( - versionMajor == agile.versionMajor - && versionMinor == agile.versionMinor){ + encryptionMode = (preferredEncryptionMode == cryptoAPI || !flagAES.isSet(encryptionFlags)) ? cryptoAPI : standard; + } else if (versionMajor == agile.versionMajor && versionMinor == agile.versionMinor){ encryptionMode = agile; encryptionFlags = dis.readInt(); } else { diff --git a/src/java/org/apache/poi/poifs/crypt/EncryptionVerifier.java b/src/java/org/apache/poi/poifs/crypt/EncryptionVerifier.java index d45fb28c27..2d3f0fe64a 100644 --- a/src/java/org/apache/poi/poifs/crypt/EncryptionVerifier.java +++ b/src/java/org/apache/poi/poifs/crypt/EncryptionVerifier.java @@ -83,35 +83,35 @@ public abstract class EncryptionVerifier implements GenericRecord, Duplicatable return chainingMode; } - protected void setSalt(byte[] salt) { + public void setSalt(byte[] salt) { this.salt = (salt == null) ? null : salt.clone(); } - protected void setEncryptedVerifier(byte[] encryptedVerifier) { + public void setEncryptedVerifier(byte[] encryptedVerifier) { this.encryptedVerifier = (encryptedVerifier == null) ? null : encryptedVerifier.clone(); } - protected void setEncryptedVerifierHash(byte[] encryptedVerifierHash) { + public void setEncryptedVerifierHash(byte[] encryptedVerifierHash) { this.encryptedVerifierHash = (encryptedVerifierHash == null) ? null : encryptedVerifierHash.clone(); } - protected void setEncryptedKey(byte[] encryptedKey) { + public void setEncryptedKey(byte[] encryptedKey) { this.encryptedKey = (encryptedKey == null) ? null : encryptedKey.clone(); } - protected void setSpinCount(int spinCount) { + public void setSpinCount(int spinCount) { this.spinCount = spinCount; } - protected void setCipherAlgorithm(CipherAlgorithm cipherAlgorithm) { + public void setCipherAlgorithm(CipherAlgorithm cipherAlgorithm) { this.cipherAlgorithm = cipherAlgorithm; } - protected void setChainingMode(ChainingMode chainingMode) { + public void setChainingMode(ChainingMode chainingMode) { this.chainingMode = chainingMode; } - protected void setHashAlgorithm(HashAlgorithm hashAlgorithm) { + public void setHashAlgorithm(HashAlgorithm hashAlgorithm) { this.hashAlgorithm = hashAlgorithm; } diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileDecryptor.java b/src/java/org/apache/poi/poifs/crypt/agile/AgileDecryptor.java index f8efe0d201..f8efe0d201 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileDecryptor.java +++ b/src/java/org/apache/poi/poifs/crypt/agile/AgileDecryptor.java diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionHeader.java b/src/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionHeader.java index 0c4983e65e..78c289f5ea 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionHeader.java +++ b/src/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionHeader.java @@ -19,10 +19,6 @@ package org.apache.poi.poifs.crypt.agile; import java.util.Map; import java.util.function.Supplier; -import com.microsoft.schemas.office.x2006.encryption.CTDataIntegrity; -import com.microsoft.schemas.office.x2006.encryption.CTKeyData; -import com.microsoft.schemas.office.x2006.encryption.EncryptionDocument; -import com.microsoft.schemas.office.x2006.encryption.STCipherChaining; import org.apache.poi.EncryptedDocumentException; import org.apache.poi.poifs.crypt.ChainingMode; import org.apache.poi.poifs.crypt.CipherAlgorithm; @@ -45,9 +41,9 @@ public class AgileEncryptionHeader extends EncryptionHeader { } protected AgileEncryptionHeader(EncryptionDocument ed) { - CTKeyData keyData; + KeyData keyData; try { - keyData = ed.getEncryption().getKeyData(); + keyData = ed.getKeyData(); if (keyData == null) { throw new NullPointerException("keyData not set"); } @@ -55,9 +51,9 @@ public class AgileEncryptionHeader extends EncryptionHeader { throw new EncryptedDocumentException("Unable to parse keyData"); } - int keyBits = (int)keyData.getKeyBits(); + int keyBits = keyData.getKeyBits(); - CipherAlgorithm ca = CipherAlgorithm.fromXmlId(keyData.getCipherAlgorithm().toString(), keyBits); + CipherAlgorithm ca = keyData.getCipherAlgorithm(); setCipherAlgorithm(ca); setCipherProvider(ca.provider); @@ -67,20 +63,15 @@ public class AgileEncryptionHeader extends EncryptionHeader { setCspName(null); setBlockSize(keyData.getBlockSize()); - switch (keyData.getCipherChaining().intValue()) { - case STCipherChaining.INT_CHAINING_MODE_CBC: - setChainingMode(ChainingMode.cbc); - break; - case STCipherChaining.INT_CHAINING_MODE_CFB: - setChainingMode(ChainingMode.cfb); - break; - default: + setChainingMode(keyData.getCipherChaining()); + + if (getChainingMode() != ChainingMode.cbc && getChainingMode() != ChainingMode.cfb) { throw new EncryptedDocumentException("Unsupported chaining mode - "+ keyData.getCipherChaining()); } int hashSize = keyData.getHashSize(); - HashAlgorithm ha = HashAlgorithm.fromEcmaId(keyData.getHashAlgorithm().toString()); + HashAlgorithm ha = keyData.getHashAlgorithm(); setHashAlgorithm(ha); if (getHashAlgorithm().hashSize != hashSize) { @@ -94,7 +85,7 @@ public class AgileEncryptionHeader extends EncryptionHeader { throw new EncryptedDocumentException("Invalid salt length"); } - CTDataIntegrity di = ed.getEncryption().getDataIntegrity(); + DataIntegrity di = ed.getDataIntegrity(); setEncryptedHmacKey(di.getEncryptedHmacKey()); setEncryptedHmacValue(di.getEncryptedHmacValue()); } @@ -110,7 +101,7 @@ public class AgileEncryptionHeader extends EncryptionHeader { // make method visible for this package @Override - protected void setKeySalt(byte[] salt) { + public void setKeySalt(byte[] salt) { if (salt == null || salt.length != getBlockSize()) { throw new EncryptedDocumentException("invalid verifier salt"); } diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionInfoBuilder.java b/src/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionInfoBuilder.java index d149d3af1a..0674305b22 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionInfoBuilder.java +++ b/src/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionInfoBuilder.java @@ -16,8 +16,6 @@ ==================================================================== */ package org.apache.poi.poifs.crypt.agile; -import static org.apache.poi.ooxml.POIXMLTypeLoader.DEFAULT_XML_OPTIONS; - import java.io.IOException; import java.io.InputStream; @@ -29,12 +27,13 @@ import org.apache.poi.poifs.crypt.EncryptionInfoBuilder; import org.apache.poi.poifs.crypt.EncryptionMode; import org.apache.poi.poifs.crypt.HashAlgorithm; import org.apache.poi.util.LittleEndianInput; -import org.apache.xmlbeans.XmlException; - -import com.microsoft.schemas.office.x2006.encryption.EncryptionDocument; +import org.apache.poi.util.XMLHelper; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; public class AgileEncryptionInfoBuilder implements EncryptionInfoBuilder { - + @Override public void initialize(EncryptionInfo info, LittleEndianInput dis) throws IOException { EncryptionDocument ed = parseDescriptor((InputStream)dis); @@ -90,19 +89,22 @@ public class AgileEncryptionInfoBuilder implements EncryptionInfoBuilder { enc.setEncryptionInfo(info); info.setEncryptor(enc); } - + protected static EncryptionDocument parseDescriptor(String descriptor) { - try { - return EncryptionDocument.Factory.parse(descriptor, DEFAULT_XML_OPTIONS); - } catch (XmlException e) { - throw new EncryptedDocumentException("Unable to parse encryption descriptor", e); - } + return parseDescriptor(new InputSource(descriptor)); } protected static EncryptionDocument parseDescriptor(InputStream descriptor) { + return parseDescriptor(new InputSource(descriptor)); + } + + private static EncryptionDocument parseDescriptor(InputSource descriptor) { try { - return EncryptionDocument.Factory.parse(descriptor, DEFAULT_XML_OPTIONS); - } catch (Exception e) { + Document doc = XMLHelper.newDocumentBuilder().parse(descriptor); + EncryptionDocument ed = new EncryptionDocument(); + ed.parse(doc); + return ed; + } catch (SAXException|IOException e) { throw new EncryptedDocumentException("Unable to parse encryption descriptor", e); } } diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionVerifier.java b/src/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionVerifier.java index 4535b4bbec..6699b543c4 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionVerifier.java +++ b/src/java/org/apache/poi/poifs/crypt/agile/AgileEncryptionVerifier.java @@ -16,12 +16,6 @@ ==================================================================== */ package org.apache.poi.poifs.crypt.agile; -import java.util.Iterator; - -import com.microsoft.schemas.office.x2006.encryption.CTKeyEncryptor; -import com.microsoft.schemas.office.x2006.encryption.EncryptionDocument; -import com.microsoft.schemas.office.x2006.encryption.STCipherChaining; -import com.microsoft.schemas.office.x2006.keyEncryptor.password.CTPasswordKeyEncryptor; import org.apache.poi.EncryptedDocumentException; import org.apache.poi.poifs.crypt.ChainingMode; import org.apache.poi.poifs.crypt.CipherAlgorithm; @@ -42,29 +36,27 @@ public class AgileEncryptionVerifier extends EncryptionVerifier { } protected AgileEncryptionVerifier(EncryptionDocument ed) { - Iterator<CTKeyEncryptor> encList = ed.getEncryption().getKeyEncryptors().getKeyEncryptorList().iterator(); - CTPasswordKeyEncryptor keyData; - try { - keyData = encList.next().getEncryptedPasswordKey(); - if (keyData == null) { - throw new NullPointerException("encryptedKey not set"); + PasswordKeyEncryptor keyData = null; + for (KeyEncryptor ke : ed.getKeyEncryptors()) { + keyData = ke.getPasswordKeyEncryptor(); + if (keyData != null) { + break; } - } catch (Exception e) { - throw new EncryptedDocumentException("Unable to parse keyData", e); } - int kb = (int)keyData.getKeyBits(); - CipherAlgorithm ca = CipherAlgorithm.fromXmlId(keyData.getCipherAlgorithm().toString(), kb); - setCipherAlgorithm(ca); + if (keyData == null) { + throw new NullPointerException("encryptedKey not set"); + } - setKeySize(kb); + setCipherAlgorithm(keyData.getCipherAlgorithm()); + setKeySize(keyData.getKeyBits()); int blockSize = keyData.getBlockSize(); setBlockSize(blockSize); int hashSize = keyData.getHashSize(); - HashAlgorithm ha = HashAlgorithm.fromEcmaId(keyData.getHashAlgorithm().toString()); + HashAlgorithm ha = keyData.getHashAlgorithm(); setHashAlgorithm(ha); if (getHashAlgorithm().hashSize != hashSize) { @@ -83,15 +75,9 @@ public class AgileEncryptionVerifier extends EncryptionVerifier { throw new EncryptedDocumentException("Invalid salt size"); } - switch (keyData.getCipherChaining().intValue()) { - case STCipherChaining.INT_CHAINING_MODE_CBC: - setChainingMode(ChainingMode.cbc); - break; - case STCipherChaining.INT_CHAINING_MODE_CFB: - setChainingMode(ChainingMode.cfb); - break; - default: - throw new EncryptedDocumentException("Unsupported chaining mode - "+ keyData.getCipherChaining()); + setChainingMode(keyData.getCipherChaining()); + if (keyData.getCipherChaining() != ChainingMode.cbc && keyData.getCipherChaining() != ChainingMode.cfb) { + throw new EncryptedDocumentException("Unsupported chaining mode - "+ keyData.getCipherChaining()); } } @@ -111,7 +97,7 @@ public class AgileEncryptionVerifier extends EncryptionVerifier { } @Override - protected void setSalt(byte[] salt) { + public void setSalt(byte[] salt) { if (salt == null || salt.length != getCipherAlgorithm().blockSize) { throw new EncryptedDocumentException("invalid verifier salt"); } @@ -120,19 +106,19 @@ public class AgileEncryptionVerifier extends EncryptionVerifier { // make method visible for this package @Override - protected void setEncryptedVerifier(byte[] encryptedVerifier) { + public void setEncryptedVerifier(byte[] encryptedVerifier) { super.setEncryptedVerifier(encryptedVerifier); } // make method visible for this package @Override - protected void setEncryptedVerifierHash(byte[] encryptedVerifierHash) { + public void setEncryptedVerifierHash(byte[] encryptedVerifierHash) { super.setEncryptedVerifierHash(encryptedVerifierHash); } // make method visible for this package @Override - protected void setEncryptedKey(byte[] encryptedKey) { + public void setEncryptedKey(byte[] encryptedKey) { super.setEncryptedKey(encryptedKey); } @@ -169,7 +155,7 @@ public class AgileEncryptionVerifier extends EncryptionVerifier { * * @param keyBits the keysize (in bits) */ - protected void setKeySize(int keyBits) { + public void setKeySize(int keyBits) { this.keyBits = keyBits; for (int allowedBits : getCipherAlgorithm().allowedKeySize) { if (allowedBits == keyBits) { @@ -185,12 +171,12 @@ public class AgileEncryptionVerifier extends EncryptionVerifier { * * @param blockSize the blockSize (in bytes) */ - protected void setBlockSize(int blockSize) { + public void setBlockSize(int blockSize) { this.blockSize = blockSize; } @Override - protected final void setCipherAlgorithm(CipherAlgorithm cipherAlgorithm) { + public final void setCipherAlgorithm(CipherAlgorithm cipherAlgorithm) { super.setCipherAlgorithm(cipherAlgorithm); if (cipherAlgorithm.allowedKeySize.length == 1) { setKeySize(cipherAlgorithm.defaultKeySize); diff --git a/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java b/src/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java index 05ab2755a1..9200fb3830 100644 --- a/src/ooxml/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java +++ b/src/java/org/apache/poi/poifs/crypt/agile/AgileEncryptor.java @@ -21,6 +21,7 @@ import static org.apache.poi.poifs.crypt.CryptoFunctions.getCipher; import static org.apache.poi.poifs.crypt.CryptoFunctions.getMessageDigest; import static org.apache.poi.poifs.crypt.CryptoFunctions.hashPassword; import static org.apache.poi.poifs.crypt.DataSpaceMapUtils.createEncryptionEntry; +import static org.apache.poi.poifs.crypt.EncryptionInfo.ENCRYPTION_INFO_ENTRY; import static org.apache.poi.poifs.crypt.agile.AgileDecryptor.getNextBlockSize; import static org.apache.poi.poifs.crypt.agile.AgileDecryptor.hashInput; import static org.apache.poi.poifs.crypt.agile.AgileDecryptor.kCryptoKeyBlock; @@ -29,35 +30,26 @@ import static org.apache.poi.poifs.crypt.agile.AgileDecryptor.kIntegrityKeyBlock import static org.apache.poi.poifs.crypt.agile.AgileDecryptor.kIntegrityValueBlock; import static org.apache.poi.poifs.crypt.agile.AgileDecryptor.kVerifierInputBlock; -import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.nio.charset.StandardCharsets; import java.security.GeneralSecurityException; import java.security.MessageDigest; import java.security.SecureRandom; -import java.util.HashMap; -import java.util.Map; import java.util.Random; import javax.crypto.Cipher; import javax.crypto.Mac; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerException; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; -import com.microsoft.schemas.office.x2006.encryption.CTDataIntegrity; -import com.microsoft.schemas.office.x2006.encryption.CTEncryption; -import com.microsoft.schemas.office.x2006.encryption.CTKeyData; -import com.microsoft.schemas.office.x2006.encryption.CTKeyEncryptor; -import com.microsoft.schemas.office.x2006.encryption.CTKeyEncryptors; -import com.microsoft.schemas.office.x2006.encryption.EncryptionDocument; -import com.microsoft.schemas.office.x2006.encryption.STCipherAlgorithm; -import com.microsoft.schemas.office.x2006.encryption.STCipherChaining; -import com.microsoft.schemas.office.x2006.encryption.STHashAlgorithm; -import com.microsoft.schemas.office.x2006.keyEncryptor.password.CTPasswordKeyEncryptor; import org.apache.poi.EncryptedDocumentException; import org.apache.poi.poifs.crypt.ChunkedCipherOutputStream; import org.apache.poi.poifs.crypt.CryptoFunctions; @@ -70,7 +62,8 @@ import org.apache.poi.util.IOUtils; import org.apache.poi.util.LittleEndian; import org.apache.poi.util.LittleEndianByteArrayOutputStream; import org.apache.poi.util.LittleEndianConsts; -import org.apache.xmlbeans.XmlOptions; +import org.apache.poi.util.XMLHelper; +import org.w3c.dom.Document; public class AgileEncryptor extends Encryptor { @@ -261,21 +254,19 @@ public class AgileEncryptor extends Encryptor { header.setEncryptedHmacValue(encryptedHmacValue); } - private final CTKeyEncryptor.Uri.Enum passwordUri = - CTKeyEncryptor.Uri.HTTP_SCHEMAS_MICROSOFT_COM_OFFICE_2006_KEY_ENCRYPTOR_PASSWORD; - protected EncryptionDocument createEncryptionDocument() { AgileEncryptionVerifier ver = (AgileEncryptionVerifier)getEncryptionInfo().getVerifier(); AgileEncryptionHeader header = (AgileEncryptionHeader)getEncryptionInfo().getHeader(); - EncryptionDocument ed = EncryptionDocument.Factory.newInstance(); - CTEncryption edRoot = ed.addNewEncryption(); + EncryptionDocument ed = new EncryptionDocument(); + KeyData keyData = new KeyData(); + ed.setKeyData(keyData); + + KeyEncryptor keyEnc = new KeyEncryptor(); + ed.getKeyEncryptors().add(keyEnc); - CTKeyData keyData = edRoot.addNewKeyData(); - CTKeyEncryptors keyEncList = edRoot.addNewKeyEncryptors(); - CTKeyEncryptor keyEnc = keyEncList.addNewKeyEncryptor(); - keyEnc.setUri(passwordUri); - CTPasswordKeyEncryptor keyPass = keyEnc.addNewEncryptedPasswordKey(); + PasswordKeyEncryptor keyPass = new PasswordKeyEncryptor(); + keyEnc.setPasswordKeyEncryptor(keyPass); keyPass.setSpinCount(ver.getSpinCount()); @@ -295,28 +286,15 @@ public class AgileEncryptor extends Encryptor { if (!header.getCipherAlgorithm().xmlId.equals(ver.getCipherAlgorithm().xmlId)) { throw new EncryptedDocumentException("Cipher algorithm of header and verifier have to match"); } - STCipherAlgorithm.Enum xmlCipherAlgo = STCipherAlgorithm.Enum.forString(header.getCipherAlgorithm().xmlId); - if (xmlCipherAlgo == null) { - throw new EncryptedDocumentException("CipherAlgorithm "+header.getCipherAlgorithm()+" not supported."); - } - keyData.setCipherAlgorithm(xmlCipherAlgo); - keyPass.setCipherAlgorithm(xmlCipherAlgo); - - switch (header.getChainingMode()) { - case cbc: - keyData.setCipherChaining(STCipherChaining.CHAINING_MODE_CBC); - keyPass.setCipherChaining(STCipherChaining.CHAINING_MODE_CBC); - break; - case cfb: - keyData.setCipherChaining(STCipherChaining.CHAINING_MODE_CFB); - keyPass.setCipherChaining(STCipherChaining.CHAINING_MODE_CFB); - break; - default: - throw new EncryptedDocumentException("ChainingMode "+header.getChainingMode()+" not supported."); - } - keyData.setHashAlgorithm(mapHashAlgorithm(header.getHashAlgorithm())); - keyPass.setHashAlgorithm(mapHashAlgorithm(ver.getHashAlgorithm())); + keyData.setCipherAlgorithm(header.getCipherAlgorithm()); + keyPass.setCipherAlgorithm(header.getCipherAlgorithm()); + + keyData.setCipherChaining(header.getChainingMode()); + keyPass.setCipherChaining(header.getChainingMode()); + + keyData.setHashAlgorithm(header.getHashAlgorithm()); + keyPass.setHashAlgorithm(ver.getHashAlgorithm()); keyData.setSaltValue(header.getKeySalt()); keyPass.setSaltValue(ver.getSalt()); @@ -324,40 +302,26 @@ public class AgileEncryptor extends Encryptor { keyPass.setEncryptedVerifierHashValue(ver.getEncryptedVerifierHash()); keyPass.setEncryptedKeyValue(ver.getEncryptedKey()); - CTDataIntegrity hmacData = edRoot.addNewDataIntegrity(); + DataIntegrity hmacData = new DataIntegrity(); + ed.setDataIntegrity(hmacData); hmacData.setEncryptedHmacKey(header.getEncryptedHmacKey()); hmacData.setEncryptedHmacValue(header.getEncryptedHmacValue()); return ed; } - private static STHashAlgorithm.Enum mapHashAlgorithm(HashAlgorithm hashAlgo) { - STHashAlgorithm.Enum xmlHashAlgo = STHashAlgorithm.Enum.forString(hashAlgo.ecmaString); - if (xmlHashAlgo == null) { - throw new EncryptedDocumentException("HashAlgorithm "+hashAlgo+" not supported."); - } - return xmlHashAlgo; - } - protected void marshallEncryptionDocument(EncryptionDocument ed, LittleEndianByteArrayOutputStream os) { - XmlOptions xo = new XmlOptions(); - xo.setCharacterEncoding("UTF-8"); - Map<String,String> nsMap = new HashMap<>(); - nsMap.put(passwordUri.toString(),"p"); - xo.setUseDefaultNamespace(); - xo.setSaveSuggestedPrefixes(nsMap); - xo.setSaveNamespacesFirst(); - xo.setSaveAggressiveNamespaces(); - - // setting standalone doesn't work with xmlbeans-2.3 & 2.6 - // ed.documentProperties().setStandalone(true); - xo.setSaveNoXmlDecl(); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + Document doc = XMLHelper.newDocumentBuilder().newDocument(); + ed.write(doc); + try { - bos.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n".getBytes(StandardCharsets.UTF_8)); - ed.save(bos, xo); - bos.writeTo(os); - } catch (IOException e) { + Transformer trans = XMLHelper.newTransformer(); + trans.setOutputProperty(OutputKeys.METHOD, "xml"); + trans.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); + trans.setOutputProperty(OutputKeys.INDENT, "no"); + trans.setOutputProperty(OutputKeys.STANDALONE, "yes"); + trans.transform(new DOMSource(doc), new StreamResult(os)); + } catch (TransformerException e) { throw new EncryptedDocumentException("error marshalling encryption info document", e); } } @@ -399,7 +363,7 @@ public class AgileEncryptor extends Encryptor { protected void createEncryptionInfoEntry(DirectoryNode dir, File tmpFile) throws IOException { DataSpaceMapUtils.addDefaultDataSpace(dir); - createEncryptionEntry(dir, "EncryptionInfo", this::marshallEncryptionRecord); + createEncryptionEntry(dir, ENCRYPTION_INFO_ENTRY, this::marshallEncryptionRecord); } private void marshallEncryptionRecord(LittleEndianByteArrayOutputStream bos) { diff --git a/src/java/org/apache/poi/poifs/crypt/agile/CertificateKeyEncryptor.java b/src/java/org/apache/poi/poifs/crypt/agile/CertificateKeyEncryptor.java new file mode 100644 index 0000000000..938b04f466 --- /dev/null +++ b/src/java/org/apache/poi/poifs/crypt/agile/CertificateKeyEncryptor.java @@ -0,0 +1,95 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +package org.apache.poi.poifs.crypt.agile; + +import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.getBinAttr; +import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.setBinAttr; + +import org.apache.poi.EncryptedDocumentException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +public class CertificateKeyEncryptor { + + /** + * A base64-encoded value that specifies the encrypted form of the intermediate key, + * which is encrypted with the public key contained within the X509Certificate attribute. + */ + private byte[] encryptedKeyValue; + + /** + * A base64-encoded value that specifies a DER-encoded X.509 certificate (1) used to encrypt the intermediate key. + * The certificate (1) MUST contain only the public portion of the public-private key pair. + */ + private byte[] x509Certificate; + + /** + * A base64-encoded value that specifies the HMAC of the binary data obtained by base64-decoding the X509Certificate + * attribute. The hashing algorithm used to derive the HMAC MUST be the hashing algorithm specified for the + * Encryption.keyData element. The secret key used to derive the HMAC MUST be the intermediate key. If the + * intermediate key is reset, any CertificateKeyEncryptor elements are also reset to contain the new intermediate + * key, except that the certVerifier attribute MUST match the value calculated using the current intermediate key, + * to verify that the CertificateKeyEncryptor element actually encrypted the current intermediate key. If a + * CertificateKeyEncryptor element does not have a correct certVerifier attribute, it MUST be discarded. + */ + private byte[] certVerifier; + + public CertificateKeyEncryptor(Element certificateKey) { + if (certificateKey == null) { + throw new EncryptedDocumentException("Unable to parse encryption descriptor"); + } + encryptedKeyValue = getBinAttr(certificateKey, "encryptedKeyValue"); + x509Certificate = getBinAttr(certificateKey, "X509Certificate"); + certVerifier = getBinAttr(certificateKey, "certVerifier"); + } + + void write(Element encryption) { + Document doc = encryption.getOwnerDocument(); + Element keyEncryptor = (Element) encryption.appendChild(doc.createElement("keyEncryptor")); + keyEncryptor.setAttribute("uri", KeyEncryptor.CERT_NS); + Element encryptedKey = (Element) keyEncryptor.appendChild(doc.createElement("c:encryptedKey")); + + setBinAttr(encryptedKey, "encryptedKeyValue", encryptedKeyValue); + setBinAttr(encryptedKey, "x509Certificate", x509Certificate); + setBinAttr(encryptedKey, "certVerifier", certVerifier); + } + + public byte[] getEncryptedKeyValue() { + return encryptedKeyValue; + } + + public void setEncryptedKeyValue(byte[] encryptedKeyValue) { + this.encryptedKeyValue = encryptedKeyValue; + } + + public byte[] getX509Certificate() { + return x509Certificate; + } + + public void setX509Certificate(byte[] x509Certificate) { + this.x509Certificate = x509Certificate; + } + + public byte[] getCertVerifier() { + return certVerifier; + } + + public void setCertVerifier(byte[] certVerifier) { + this.certVerifier = certVerifier; + } +} diff --git a/src/java/org/apache/poi/poifs/crypt/agile/DataIntegrity.java b/src/java/org/apache/poi/poifs/crypt/agile/DataIntegrity.java new file mode 100644 index 0000000000..5d067b0232 --- /dev/null +++ b/src/java/org/apache/poi/poifs/crypt/agile/DataIntegrity.java @@ -0,0 +1,82 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +package org.apache.poi.poifs.crypt.agile; + +import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.ENC_NS; +import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.getBinAttr; +import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.getTag; +import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.setBinAttr; + +import org.apache.poi.EncryptedDocumentException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + + +/** + * A complex type that specifies data used to verify whether the encrypted data passes an integrity check. + * It MUST be generated using the method specified in section 2.3.4.14 + * + * @see <a href="http://msdn.microsoft.com/en-us/library/dd924068(v=office.12).aspx">DataIntegrity Generation</a> + */ +public class DataIntegrity { + /** + * A base64-encoded value that specifies an encrypted key used in calculating the encryptedHmacValue. + */ + private byte[] encryptedHmacKey; + + /** + * A base64-encoded value that specifies an HMAC derived from encryptedHmacKey and the encrypted data. + */ + private byte[] encryptedHmacValue; + + public DataIntegrity() { + + } + + public DataIntegrity(Element parent) { + Element dataIntegrity = getTag(parent, ENC_NS, "dataIntegrity"); + if (dataIntegrity == null) { + throw new EncryptedDocumentException("Unable to parse encryption descriptor"); + } + encryptedHmacKey = getBinAttr(dataIntegrity, "encryptedHmacKey"); + encryptedHmacValue = getBinAttr(dataIntegrity, "encryptedHmacValue"); + } + + void write(Element encryption) { + Document doc = encryption.getOwnerDocument(); + Element dataIntegrity = (Element)encryption.appendChild(doc.createElement("dataIntegrity")); + setBinAttr(dataIntegrity, "encryptedHmacKey", encryptedHmacKey); + setBinAttr(dataIntegrity, "encryptedHmacValue", encryptedHmacValue); + } + + public byte[] getEncryptedHmacKey() { + return encryptedHmacKey; + } + + public void setEncryptedHmacKey(byte[] encryptedHmacKey) { + this.encryptedHmacKey = encryptedHmacKey; + } + + public byte[] getEncryptedHmacValue() { + return encryptedHmacValue; + } + + public void setEncryptedHmacValue(byte[] encryptedHmacValue) { + this.encryptedHmacValue = encryptedHmacValue; + } +} diff --git a/src/java/org/apache/poi/poifs/crypt/agile/EncryptionDocument.java b/src/java/org/apache/poi/poifs/crypt/agile/EncryptionDocument.java new file mode 100644 index 0000000000..07004d05a5 --- /dev/null +++ b/src/java/org/apache/poi/poifs/crypt/agile/EncryptionDocument.java @@ -0,0 +1,150 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +package org.apache.poi.poifs.crypt.agile; + +import java.util.ArrayList; +import java.util.List; + +import javax.xml.XMLConstants; + +import org.apache.commons.codec.binary.Base64; +import org.apache.poi.EncryptedDocumentException; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +public class EncryptionDocument { + static final String ENC_NS = "http://schemas.microsoft.com/office/2006/encryption"; + + private KeyData keyData; + + /** + * All ECMA-376 documents [ECMA-376] encrypted by Microsoft Office using agile encryption will have a DataIntegrity + * element present. The schema allows for a DataIntegrity element to not be present because the encryption schema + * can be used by applications that do not create ECMA-376 documents [ECMA-376]. + */ + private DataIntegrity dataIntegrity; + + private final List<KeyEncryptor> keyEncryptors = new ArrayList<>(); + + public EncryptionDocument() { + + } + + public void parse(Document doc) { + Element encryption = doc.getDocumentElement(); + if (!ENC_NS.equals(encryption.getNamespaceURI()) || !"encryption".equals(encryption.getLocalName())) { + throw new EncryptedDocumentException("Unable to parse encryption descriptor"); + } + keyData = new KeyData(encryption); + dataIntegrity = new DataIntegrity(encryption); + + // The KeyEncryptor element, which MUST be used when encrypting password-protected agile encryption documents, + // is either a PasswordKeyEncryptor or a CertificateKeyEncryptor. Exactly one PasswordKeyEncryptor MUST be + // present. Zero or more CertificateKeyEncryptor elements are contained within the KeyEncryptors element. + Element keyEncryptors = getTag(encryption, ENC_NS, "keyEncryptors"); + if (keyEncryptors == null) { + throw new EncryptedDocumentException("Unable to parse encryption descriptor"); + } + NodeList ke = keyEncryptors.getElementsByTagNameNS(ENC_NS, "keyEncryptor"); + for (int i=0; i<ke.getLength(); i++) { + this.keyEncryptors.add(new KeyEncryptor((Element)ke.item(i))); + } + } + + public void write(Document doc) { + doc.setXmlStandalone(true); + Element encryption = (Element)doc.appendChild(doc.createElementNS(ENC_NS, "encryption")); + if (keyData != null) { + keyData.write(encryption); + } + if (dataIntegrity != null) { + dataIntegrity.write(encryption); + } + Element keyEncryptors = (Element)encryption.appendChild(doc.createElement("keyEncryptors")); + boolean hasPass = false; + boolean hasCert = false; + for (KeyEncryptor ke : this.keyEncryptors) { + ke.write(keyEncryptors); + hasPass |= ke.getPasswordKeyEncryptor() != null; + hasCert |= ke.getCertificateKeyEncryptor() != null; + } + if (hasPass) { + encryption.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:p", KeyEncryptor.PASS_NS); + } + if (hasCert) { + encryption.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:c", KeyEncryptor.CERT_NS); + } + + } + + + public KeyData getKeyData() { + return keyData; + } + + public void setKeyData(KeyData keyData) { + this.keyData = keyData; + } + + public DataIntegrity getDataIntegrity() { + return dataIntegrity; + } + + public void setDataIntegrity(DataIntegrity dataIntegrity) { + this.dataIntegrity = dataIntegrity; + } + + public List<KeyEncryptor> getKeyEncryptors() { + return keyEncryptors; + } + + static Element getTag(Element el, String ns, String name) { + if (el == null) { + return null; + } + NodeList nl = el.getElementsByTagNameNS(ns, name); + return (nl.getLength() > 0) ? (Element)nl.item(0) : null; + } + + static Integer getIntAttr(Element el, String name) { + String at = el.getAttribute(name); + return (at.isEmpty()) ? null : Integer.valueOf(at); + } + + static byte[] getBinAttr(Element el, String name) { + String at = el.getAttribute(name); + return (at.isEmpty()) ? null : Base64.decodeBase64(at); + } + + static void setIntAttr(Element el, String name, Integer val) { + setAttr(el, name, val == null ? null : val.toString()); + } + + static void setAttr(Element el, String name, String val) { + if (val != null) { + el.setAttribute(name, val); + } + } + + static void setBinAttr(Element el, String name, byte[] val) { + if (val != null) { + setAttr(el, name, Base64.encodeBase64String(val)); + } + } +} diff --git a/src/java/org/apache/poi/poifs/crypt/agile/KeyData.java b/src/java/org/apache/poi/poifs/crypt/agile/KeyData.java new file mode 100644 index 0000000000..fba57eb2c4 --- /dev/null +++ b/src/java/org/apache/poi/poifs/crypt/agile/KeyData.java @@ -0,0 +1,148 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +package org.apache.poi.poifs.crypt.agile; + +import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.ENC_NS; +import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.getBinAttr; +import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.getIntAttr; +import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.getTag; +import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.setAttr; +import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.setBinAttr; +import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.setIntAttr; + +import org.apache.poi.EncryptedDocumentException; +import org.apache.poi.poifs.crypt.ChainingMode; +import org.apache.poi.poifs.crypt.CipherAlgorithm; +import org.apache.poi.poifs.crypt.HashAlgorithm; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +/** + * A complex type that specifies the encryption used within this element. The saltValue attribute is a base64-encoded + * binary value that is randomly generated. The number of bytes required to decode the saltValue attribute MUST be equal + * to the value of the saltSize attribute. + */ +public class KeyData { + private Integer saltSize; + private Integer blockSize; + private Integer keyBits; + private Integer hashSize; + private CipherAlgorithm cipherAlgorithm; + private ChainingMode cipherChaining; + private HashAlgorithm hashAlgorithm; + private byte[] saltValue; + + public KeyData() { + + } + + public KeyData(Element parent) { + Element keyData = getTag(parent, ENC_NS, "keyData"); + if (keyData == null) { + throw new EncryptedDocumentException("Unable to parse encryption descriptor"); + } + saltSize = getIntAttr(keyData, "saltSize"); + blockSize = getIntAttr(keyData, "blockSize"); + keyBits = getIntAttr(keyData, "keyBits"); + hashSize = getIntAttr(keyData, "hashSize"); + cipherAlgorithm = CipherAlgorithm.fromXmlId(keyData.getAttribute("cipherAlgorithm"), keyBits); + cipherChaining = ChainingMode.fromXmlId(keyData.getAttribute("cipherChaining")); + hashAlgorithm = HashAlgorithm.fromEcmaId(keyData.getAttribute("hashAlgorithm")); + if (cipherAlgorithm == null || cipherChaining == null || hashAlgorithm == null) { + throw new EncryptedDocumentException("Cipher algorithm, chaining mode or hash algorithm was null"); + } + saltValue = getBinAttr(keyData, "saltValue"); + } + + void write(Element encryption) { + Document doc = encryption.getOwnerDocument(); + Element keyData = (Element)encryption.appendChild(doc.createElement("keyData")); + setIntAttr(keyData, "saltSize", saltSize); + setIntAttr(keyData, "blockSize", blockSize); + setIntAttr(keyData, "keyBits", keyBits); + setIntAttr(keyData, "hashSize", hashSize); + setAttr(keyData, "cipherAlgorithm", cipherAlgorithm == null ? null : cipherAlgorithm.xmlId); + setAttr(keyData, "cipherChaining", cipherChaining == null ? null : cipherChaining.xmlId); + setAttr(keyData, "hashAlgorithm", hashAlgorithm == null ? null : hashAlgorithm.ecmaString); + setBinAttr(keyData, "saltValue", saltValue); + } + + public Integer getSaltSize() { + return saltSize; + } + + public void setSaltSize(Integer saltSize) { + this.saltSize = saltSize; + } + + public Integer getBlockSize() { + return blockSize; + } + + public void setBlockSize(Integer blockSize) { + this.blockSize = blockSize; + } + + public Integer getKeyBits() { + return keyBits; + } + + public void setKeyBits(Integer keyBits) { + this.keyBits = keyBits; + } + + public Integer getHashSize() { + return hashSize; + } + + public void setHashSize(Integer hashSize) { + this.hashSize = hashSize; + } + + public CipherAlgorithm getCipherAlgorithm() { + return cipherAlgorithm; + } + + public void setCipherAlgorithm(CipherAlgorithm cipherAlgorithm) { + this.cipherAlgorithm = cipherAlgorithm; + } + + public ChainingMode getCipherChaining() { + return cipherChaining; + } + + public void setCipherChaining(ChainingMode cipherChaining) { + this.cipherChaining = cipherChaining; + } + + public HashAlgorithm getHashAlgorithm() { + return hashAlgorithm; + } + + public void setHashAlgorithm(HashAlgorithm hashAlgorithm) { + this.hashAlgorithm = hashAlgorithm; + } + + public byte[] getSaltValue() { + return saltValue; + } + + public void setSaltValue(byte[] saltValue) { + this.saltValue = (saltValue == null) ? null : saltValue.clone(); + } +} diff --git a/src/java/org/apache/poi/poifs/crypt/agile/KeyEncryptor.java b/src/java/org/apache/poi/poifs/crypt/agile/KeyEncryptor.java new file mode 100644 index 0000000000..c7e591d160 --- /dev/null +++ b/src/java/org/apache/poi/poifs/crypt/agile/KeyEncryptor.java @@ -0,0 +1,81 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +package org.apache.poi.poifs.crypt.agile; + +import org.apache.poi.EncryptedDocumentException; +import org.w3c.dom.Element; +import org.w3c.dom.NodeList; + +/** + * A sequence of KeyEncryptor elements. Exactly one KeyEncryptors element MUST be present, and the KeyEncryptors element + * MUST contain at least one KeyEncryptor. + */ +public class KeyEncryptor { + static final String PASS_NS = "http://schemas.microsoft.com/office/2006/keyEncryptor/password"; + static final String CERT_NS = "http://schemas.microsoft.com/office/2006/keyEncryptor/certificate"; + + private PasswordKeyEncryptor passwordKeyEncryptor; + private CertificateKeyEncryptor certificateKeyEncryptor; + + public KeyEncryptor() { + + } + + public KeyEncryptor(Element keyEncryptor) { + if (keyEncryptor == null) { + throw new EncryptedDocumentException("Unable to parse encryption descriptor"); + } + NodeList nl = keyEncryptor.getElementsByTagNameNS("*", "encryptedKey"); + // usually only one encryptor is set, so iterate and overwrite the encryptor members + for (int i=0; i<nl.getLength(); i++) { + Element el = (Element)nl.item(i); + String nsUri = el.getNamespaceURI(); + if (PASS_NS.equals(nsUri)) { + passwordKeyEncryptor = new PasswordKeyEncryptor(el); + } else if (CERT_NS.equals(nsUri)) { + certificateKeyEncryptor = new CertificateKeyEncryptor(el); + } + } + } + + void write(Element keyEncryptors) { + if (passwordKeyEncryptor != null) { + passwordKeyEncryptor.write(keyEncryptors); + } else if (certificateKeyEncryptor != null) { + certificateKeyEncryptor.write(keyEncryptors); + } + } + + + + public PasswordKeyEncryptor getPasswordKeyEncryptor() { + return passwordKeyEncryptor; + } + + public void setPasswordKeyEncryptor(PasswordKeyEncryptor passwordKeyEncryptor) { + this.passwordKeyEncryptor = passwordKeyEncryptor; + } + + public CertificateKeyEncryptor getCertificateKeyEncryptor() { + return certificateKeyEncryptor; + } + + public void setCertificateKeyEncryptor(CertificateKeyEncryptor certificateKeyEncryptor) { + this.certificateKeyEncryptor = certificateKeyEncryptor; + } +} diff --git a/src/java/org/apache/poi/poifs/crypt/agile/PasswordKeyEncryptor.java b/src/java/org/apache/poi/poifs/crypt/agile/PasswordKeyEncryptor.java new file mode 100644 index 0000000000..1e3f8640ff --- /dev/null +++ b/src/java/org/apache/poi/poifs/crypt/agile/PasswordKeyEncryptor.java @@ -0,0 +1,241 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +package org.apache.poi.poifs.crypt.agile; + +import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.getBinAttr; +import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.getIntAttr; +import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.setAttr; +import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.setBinAttr; +import static org.apache.poi.poifs.crypt.agile.EncryptionDocument.setIntAttr; + +import org.apache.poi.EncryptedDocumentException; +import org.apache.poi.poifs.crypt.ChainingMode; +import org.apache.poi.poifs.crypt.CipherAlgorithm; +import org.apache.poi.poifs.crypt.HashAlgorithm; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +public class PasswordKeyEncryptor { + + /** + * An unsigned integer that specifies the number of bytes used by a salt. It MUST be at least 1 and no greater than 65,536. + */ + private Integer saltSize; + + /** + * An unsigned integer that specifies the number of bytes used to encrypt one block of data. + * It MUST be at least 2, no greater than 4096, and a multiple of 2. + */ + private Integer blockSize; + + /** + * An unsigned integer that specifies the number of bits used by an encryption algorithm. + * It MUST be at least 8 and a multiple of 8. + */ + private Integer keyBits; + + /** + * An unsigned integer that specifies the number of bytes used by a hash value. + * It MUST be at least 1, no greater than 65,536, and the same number of bytes as the hash algorithm emits. + */ + private Integer hashSize; + + /** + * A CipherAlgorithm that specifies the cipher algorithm for a PasswordKeyEncryptor. + * The cipher algorithm specified MUST be the same as the cipher algorithm specified for the Encryption.keyData element. + */ + private CipherAlgorithm cipherAlgorithm; + + /** + * A CipherChaining that specifies the cipher chaining mode for a PasswordKeyEncryptor. + */ + private ChainingMode cipherChaining; + + /** + * A HashAlgorithm that specifies the hashing algorithm for a PasswordKeyEncryptor. + * The hashing algorithm specified MUST be the same as the hashing algorithm specified for the Encryption.keyData element. + */ + private HashAlgorithm hashAlgorithm; + + /** + * A base64-encoded binary byte array that specifies the salt value for a PasswordKeyEncryptor. + * The number of bytes required by the decoded form of this element MUST be saltSize. + */ + private byte[] saltValue; + + /** + * A SpinCount that specifies the spin count for a PasswordKeyEncryptor. + */ + private Integer spinCount; + + /** + * A base64-encoded value that specifies the encrypted verifier hash input for a + * PasswordKeyEncryptor used in password verification. + */ + private byte[] encryptedVerifierHashInput; + + /** + * A base64-encoded value that specifies the encrypted verifier hash value for a + * PasswordKeyEncryptor used in password verification. + */ + private byte[] encryptedVerifierHashValue; + + /** + * A base64-encoded value that specifies the encrypted form of the intermediate key. + */ + private byte[] encryptedKeyValue; + + public PasswordKeyEncryptor() { + + } + + public PasswordKeyEncryptor(Element passwordKey) { + if (passwordKey == null) { + throw new EncryptedDocumentException("Unable to parse encryption descriptor"); + } + saltSize = getIntAttr(passwordKey, "saltSize"); + blockSize = getIntAttr(passwordKey, "blockSize"); + keyBits = getIntAttr(passwordKey, "keyBits"); + hashSize = getIntAttr(passwordKey, "hashSize"); + cipherAlgorithm = CipherAlgorithm.fromXmlId(passwordKey.getAttribute("cipherAlgorithm"), keyBits); + cipherChaining = ChainingMode.fromXmlId(passwordKey.getAttribute("cipherChaining")); + hashAlgorithm = HashAlgorithm.fromEcmaId(passwordKey.getAttribute("hashAlgorithm")); + saltValue = getBinAttr(passwordKey, "saltValue"); + spinCount = getIntAttr(passwordKey, "spinCount"); + encryptedVerifierHashInput = getBinAttr(passwordKey, "encryptedVerifierHashInput"); + encryptedVerifierHashValue = getBinAttr(passwordKey, "encryptedVerifierHashValue"); + encryptedKeyValue = getBinAttr(passwordKey, "encryptedKeyValue"); + } + + void write(Element encryption) { + Document doc = encryption.getOwnerDocument(); + Element keyEncryptor = (Element) encryption.appendChild(doc.createElement("keyEncryptor")); + keyEncryptor.setAttribute("uri", KeyEncryptor.PASS_NS); + Element encryptedKey = (Element) keyEncryptor.appendChild(doc.createElement("p:encryptedKey")); + + setIntAttr(encryptedKey, "saltSize", saltSize); + setIntAttr(encryptedKey, "blockSize", blockSize); + setIntAttr(encryptedKey, "keyBits", keyBits); + setIntAttr(encryptedKey, "hashSize", hashSize); + setAttr(encryptedKey, "cipherAlgorithm", cipherAlgorithm == null ? null : cipherAlgorithm.xmlId); + setAttr(encryptedKey, "cipherChaining", cipherChaining == null ? null : cipherChaining.xmlId); + setAttr(encryptedKey, "hashAlgorithm", hashAlgorithm == null ? null : hashAlgorithm.ecmaString); + setBinAttr(encryptedKey, "saltValue", saltValue); + setIntAttr(encryptedKey, "spinCount", spinCount); + setBinAttr(encryptedKey, "encryptedVerifierHashInput", encryptedVerifierHashInput); + setBinAttr(encryptedKey, "encryptedVerifierHashValue", encryptedVerifierHashValue); + setBinAttr(encryptedKey, "encryptedKeyValue", encryptedKeyValue); + + } + + public Integer getSaltSize() { + return saltSize; + } + + public void setSaltSize(Integer saltSize) { + this.saltSize = saltSize; + } + + public Integer getBlockSize() { + return blockSize; + } + + public void setBlockSize(Integer blockSize) { + this.blockSize = blockSize; + } + + public Integer getKeyBits() { + return keyBits; + } + + public void setKeyBits(Integer keyBits) { + this.keyBits = keyBits; + } + + public Integer getHashSize() { + return hashSize; + } + + public void setHashSize(Integer hashSize) { + this.hashSize = hashSize; + } + + public CipherAlgorithm getCipherAlgorithm() { + return cipherAlgorithm; + } + + public void setCipherAlgorithm(CipherAlgorithm cipherAlgorithm) { + this.cipherAlgorithm = cipherAlgorithm; + } + + public ChainingMode getCipherChaining() { + return cipherChaining; + } + + public void setCipherChaining(ChainingMode cipherChaining) { + this.cipherChaining = cipherChaining; + } + + public HashAlgorithm getHashAlgorithm() { + return hashAlgorithm; + } + + public void setHashAlgorithm(HashAlgorithm hashAlgorithm) { + this.hashAlgorithm = hashAlgorithm; + } + + public byte[] getSaltValue() { + return saltValue; + } + + public void setSaltValue(byte[] saltValue) { + this.saltValue = saltValue; + } + + public Integer getSpinCount() { + return spinCount; + } + + public void setSpinCount(Integer spinCount) { + this.spinCount = spinCount; + } + + public byte[] getEncryptedVerifierHashInput() { + return encryptedVerifierHashInput; + } + + public void setEncryptedVerifierHashInput(byte[] encryptedVerifierHashInput) { + this.encryptedVerifierHashInput = encryptedVerifierHashInput; + } + + public byte[] getEncryptedVerifierHashValue() { + return encryptedVerifierHashValue; + } + + public void setEncryptedVerifierHashValue(byte[] encryptedVerifierHashValue) { + this.encryptedVerifierHashValue = encryptedVerifierHashValue; + } + + public byte[] getEncryptedKeyValue() { + return encryptedKeyValue; + } + + public void setEncryptedKeyValue(byte[] encryptedKeyValue) { + this.encryptedKeyValue = encryptedKeyValue; + } +} diff --git a/src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4EncryptionVerifier.java b/src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4EncryptionVerifier.java index 689c06932d..f771b77550 100644 --- a/src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4EncryptionVerifier.java +++ b/src/java/org/apache/poi/poifs/crypt/binaryrc4/BinaryRC4EncryptionVerifier.java @@ -57,7 +57,7 @@ public class BinaryRC4EncryptionVerifier extends EncryptionVerifier implements E } @Override - protected void setSalt(byte[] salt) { + public void setSalt(byte[] salt) { if (salt == null || salt.length != 16) { throw new EncryptedDocumentException("invalid verifier salt"); } @@ -66,12 +66,12 @@ public class BinaryRC4EncryptionVerifier extends EncryptionVerifier implements E } @Override - protected void setEncryptedVerifier(byte[] encryptedVerifier) { + public void setEncryptedVerifier(byte[] encryptedVerifier) { super.setEncryptedVerifier(encryptedVerifier); } @Override - protected void setEncryptedVerifierHash(byte[] encryptedVerifierHash) { + public void setEncryptedVerifierHash(byte[] encryptedVerifierHash) { super.setEncryptedVerifierHash(encryptedVerifierHash); } diff --git a/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIEncryptionVerifier.java b/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIEncryptionVerifier.java index c54b9851d0..f2c00410b3 100644 --- a/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIEncryptionVerifier.java +++ b/src/java/org/apache/poi/poifs/crypt/cryptoapi/CryptoAPIEncryptionVerifier.java @@ -41,17 +41,17 @@ public class CryptoAPIEncryptionVerifier extends StandardEncryptionVerifier { } @Override - protected void setSalt(byte[] salt) { + public void setSalt(byte[] salt) { super.setSalt(salt); } @Override - protected void setEncryptedVerifier(byte[] encryptedVerifier) { + public void setEncryptedVerifier(byte[] encryptedVerifier) { super.setEncryptedVerifier(encryptedVerifier); } @Override - protected void setEncryptedVerifierHash(byte[] encryptedVerifierHash) { + public void setEncryptedVerifierHash(byte[] encryptedVerifierHash) { super.setEncryptedVerifierHash(encryptedVerifierHash); } diff --git a/src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptionVerifier.java b/src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptionVerifier.java index 4c5f2e0d3d..d30fe998b2 100644 --- a/src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptionVerifier.java +++ b/src/java/org/apache/poi/poifs/crypt/standard/StandardEncryptionVerifier.java @@ -74,7 +74,7 @@ public class StandardEncryptionVerifier extends EncryptionVerifier implements En // make method visible for this package @Override - protected void setSalt(byte[] salt) { + public void setSalt(byte[] salt) { if (salt == null || salt.length != 16) { throw new EncryptedDocumentException("invalid verifier salt"); } @@ -83,13 +83,13 @@ public class StandardEncryptionVerifier extends EncryptionVerifier implements En // make method visible for this package @Override - protected void setEncryptedVerifier(byte[] encryptedVerifier) { + public void setEncryptedVerifier(byte[] encryptedVerifier) { super.setEncryptedVerifier(encryptedVerifier); } // make method visible for this package @Override - protected void setEncryptedVerifierHash(byte[] encryptedVerifierHash) { + public void setEncryptedVerifierHash(byte[] encryptedVerifierHash) { super.setEncryptedVerifierHash(encryptedVerifierHash); } @@ -121,7 +121,7 @@ public class StandardEncryptionVerifier extends EncryptionVerifier implements En bos.write(encryptedVerifierHash); } - protected int getVerifierHashSize() { + public int getVerifierHashSize() { return verifierHashSize; } diff --git a/src/java/org/apache/poi/poifs/crypt/xor/XOREncryptionVerifier.java b/src/java/org/apache/poi/poifs/crypt/xor/XOREncryptionVerifier.java index 8d6482b31c..5f583a7f2c 100644 --- a/src/java/org/apache/poi/poifs/crypt/xor/XOREncryptionVerifier.java +++ b/src/java/org/apache/poi/poifs/crypt/xor/XOREncryptionVerifier.java @@ -64,12 +64,12 @@ public class XOREncryptionVerifier extends EncryptionVerifier implements Encrypt } @Override - protected final void setEncryptedVerifier(byte[] encryptedVerifier) { + public final void setEncryptedVerifier(byte[] encryptedVerifier) { super.setEncryptedVerifier(encryptedVerifier); } @Override - protected final void setEncryptedKey(byte[] encryptedKey) { + public final void setEncryptedKey(byte[] encryptedKey) { super.setEncryptedKey(encryptedKey); } } diff --git a/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java b/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java index 4019855854..c3e2693213 100644 --- a/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java +++ b/src/java/org/apache/poi/sl/draw/DrawTextParagraph.java @@ -685,7 +685,7 @@ public class DrawTextParagraph implements Drawable { // handle (b) and (c) attList.add(new AttributedStringData(TextAttribute.FAMILY, fontMapped.getFontName(Locale.ROOT), beginIndex+partBegin, beginIndex+partEnd)); if (LOG.check(POILogger.DEBUG)) { - LOG.log(POILogger.DEBUG, "mapped: ",fontMapped.getFontName(Locale.ROOT)," ",(beginIndex+partBegin)," ",(beginIndex+partEnd)," - ",runText.substring(beginIndex+partBegin, beginIndex+partEnd)); + LOG.log(POILogger.DEBUG, "mapped: ",fontMapped.getFontName(Locale.ROOT)," ",(beginIndex+partBegin)," ",(beginIndex+partEnd)," - ",runText.substring(partBegin, partEnd)); } } @@ -697,7 +697,7 @@ public class DrawTextParagraph implements Drawable { // handle (a) and (b) attList.add(new AttributedStringData(TextAttribute.FAMILY, fontFallback.getFontName(Locale.ROOT), beginIndex+partBegin, beginIndex+partEnd)); if (LOG.check(POILogger.DEBUG)) { - LOG.log(POILogger.DEBUG, "fallback: ",fontFallback.getFontName(Locale.ROOT)," ",(beginIndex+partBegin)," ",(beginIndex+partEnd)," - ",runText.substring(beginIndex+partBegin, beginIndex+partEnd)); + LOG.log(POILogger.DEBUG, "fallback: ",fontFallback.getFontName(Locale.ROOT)," ",(beginIndex+partBegin)," ",(beginIndex+partEnd)," - ",runText.substring(partBegin, partEnd)); } } } diff --git a/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java b/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java index ad5a8446ea..25f5cde753 100644 --- a/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java +++ b/src/java/org/apache/poi/ss/usermodel/WorkbookFactory.java @@ -16,53 +16,46 @@ ==================================================================== */ package org.apache.poi.ss.usermodel; +import static org.apache.poi.poifs.crypt.EncryptionInfo.ENCRYPTION_INFO_ENTRY; + import java.io.BufferedInputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.ServiceLoader; +import org.apache.poi.EmptyFileException; import org.apache.poi.EncryptedDocumentException; -import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.poifs.crypt.Decryptor; import org.apache.poi.poifs.filesystem.DirectoryNode; -import org.apache.poi.poifs.filesystem.DocumentFactoryHelper; import org.apache.poi.poifs.filesystem.FileMagic; -import org.apache.poi.poifs.filesystem.OfficeXmlFileException; import org.apache.poi.poifs.filesystem.POIFSFileSystem; -import org.apache.poi.util.IOUtils; -import org.apache.poi.util.Removal; /** * Factory for creating the appropriate kind of Workbook * (be it {@link HSSFWorkbook} or XSSFWorkbook), * by auto-detecting from the supplied input. */ -public abstract class WorkbookFactory { - - protected interface CreateWorkbook0 { - Workbook apply() throws IOException; - } +public final class WorkbookFactory { - protected interface CreateWorkbook1<T> { - Workbook apply(T t) throws IOException; + private static class Singleton { + private static final WorkbookFactory INSTANCE = new WorkbookFactory(); } - protected interface CreateWorkbook2<T, U> { - Workbook apply(T t, U u) throws IOException; + private interface ProviderMethod { + Workbook create(WorkbookProvider prov) throws IOException; } - private static final Object hssfLock = new Object(); - private static final Object xssfLock = new Object(); + private final List<WorkbookProvider> provider = new ArrayList<>(); - protected static CreateWorkbook0 createHssfFromScratch; - protected static CreateWorkbook1<DirectoryNode> createHssfByNode; + private WorkbookFactory() { + ServiceLoader.load(WorkbookProvider.class).forEach(provider::add); + } - protected static CreateWorkbook0 createXssfFromScratch; - protected static CreateWorkbook1<InputStream> createXssfByStream; - protected static CreateWorkbook1<Object> createXssfByPackage; - protected static CreateWorkbook2<File,Boolean> createXssfByFile; /** * Create a new empty Workbook, either XSSF or HSSF depending @@ -75,13 +68,7 @@ public abstract class WorkbookFactory { * @throws IOException if an error occurs while creating the objects */ public static Workbook create(boolean xssf) throws IOException { - if(xssf) { - initXssf(); - return createXssfFromScratch.apply(); - } else { - initHssf(); - return createHssfFromScratch.apply(); - } + return wp(xssf ? FileMagic.OOXML : FileMagic.OLE2, WorkbookProvider::create); } /** @@ -144,62 +131,13 @@ public abstract class WorkbookFactory { public static Workbook create(final DirectoryNode root, String password) throws IOException { // Encrypted OOXML files go inside OLE2 containers, is this one? if (root.hasEntry(Decryptor.DEFAULT_POIFS_ENTRY)) { - InputStream stream = null; - try { - stream = DocumentFactoryHelper.getDecryptedStream(root, password); - initXssf(); - return createXssfByStream.apply(stream); - } finally { - IOUtils.closeQuietly(stream); - - // as we processed the full stream already, we can close the filesystem here - // otherwise file handles are leaked - root.getFileSystem().close(); - } - } - - // If we get here, it isn't an encrypted PPTX file - // So, treat it as a regular HSLF PPT one - boolean passwordSet = false; - if (password != null) { - Biff8EncryptionKey.setCurrentUserPassword(password); - passwordSet = true; - } - try { - initHssf(); - return createHssfByNode.apply(root); - } finally { - if (passwordSet) { - Biff8EncryptionKey.setCurrentUserPassword(null); - } + return wp(FileMagic.OOXML, w -> w.create(root, password)); + } else { + return wp(FileMagic.OLE2, w -> w.create(root, password)); } } /** - * Creates a XSSFWorkbook from the given OOXML Package. - * As the WorkbookFactory is located in the POI module, which doesn't know about the OOXML formats, - * this can be only achieved by using an Object reference to the OPCPackage. - * - * <p>Note that in order to properly release resources the - * Workbook should be closed after use.</p> - * - * @param pkg The org.apache.poi.openxml4j.opc.OPCPackage opened for reading data. - * - * @return The created Workbook - * - * @throws IOException if an error occurs while reading the data - * - * @deprecated use {@link #create(File)}, {@link #create(InputStream)} or - * XSSFWorkbookFactory.create(OPCPackage) instead. - */ - @Deprecated - @Removal(version = "4.2.0") - public static Workbook create(Object pkg) throws IOException { - initXssf(); - return createXssfByPackage.apply(pkg); - } - - /** * Creates the appropriate HSSFWorkbook / XSSFWorkbook from * the given InputStream. * @@ -248,18 +186,26 @@ public abstract class WorkbookFactory { */ public static Workbook create(InputStream inp, String password) throws IOException, EncryptedDocumentException { InputStream is = FileMagic.prepareToCheckMagic(inp); - FileMagic fm = FileMagic.valueOf(is); - - switch (fm) { - case OLE2: - POIFSFileSystem fs = new POIFSFileSystem(is); - return create(fs, password); - case OOXML: - initXssf(); - return createXssfByStream.apply(is); - default: - throw new IOException("Your InputStream was neither an OLE2 stream, nor an OOXML stream"); + byte[] emptyFileCheck = new byte[1]; + is.mark(emptyFileCheck.length); + if (is.read(emptyFileCheck) < emptyFileCheck.length) { + throw new EmptyFileException(); + } + is.reset(); + + final FileMagic fm = FileMagic.valueOf(is); + if (FileMagic.OOXML == fm) { + return wp(fm, w -> w.create(is)); + } + + if (FileMagic.OLE2 != fm) { + throw new IOException("Can't open workbook - unsupported file type: "+fm); } + + POIFSFileSystem poifs = new POIFSFileSystem(is); + boolean isOOXML = poifs.getRoot().hasEntry(ENCRYPTION_INFO_ENTRY); + + return wp(isOOXML ? FileMagic.OOXML : fm, w -> w.create(poifs.getRoot(), password)); } /** @@ -320,58 +266,33 @@ public abstract class WorkbookFactory { throw new FileNotFoundException(file.toString()); } - POIFSFileSystem fs = null; - try { - fs = new POIFSFileSystem(file, readOnly); - return create(fs, password); - } catch(OfficeXmlFileException e) { - IOUtils.closeQuietly(fs); - initXssf(); - return createXssfByFile.apply(file, readOnly); - } catch(RuntimeException e) { - IOUtils.closeQuietly(fs); - throw e; + if (file.length() == 0) { + throw new EmptyFileException(); } - } - private static void initXssf() throws IOException { - if (createXssfFromScratch == null) { - synchronized (xssfLock) { - if (createXssfFromScratch == null) { - String factoryClass = "org.apache.poi.xssf.usermodel.XSSFWorkbookFactory"; - Class<?> cls = initFactory(factoryClass, "poi-ooxml-*.jar"); - try { - cls.getMethod("init").invoke(null); - } catch (Exception e) { - throw new IOException(factoryClass+" failed to init."); - } - } + FileMagic fm = FileMagic.valueOf(file); + if (fm == FileMagic.OOXML) { + return wp(fm, w -> w.create(file, password, readOnly)); + } else if (fm == FileMagic.OLE2) { + boolean ooxmlEnc = false; + try (POIFSFileSystem fs = new POIFSFileSystem(file, true)) { + ooxmlEnc = fs.getRoot().hasEntry(Decryptor.DEFAULT_POIFS_ENTRY); } + return wp(ooxmlEnc ? FileMagic.OOXML : fm, w -> w.create(file, password, readOnly)); } - } - private static void initHssf() throws IOException { - if (createHssfFromScratch == null) { - // HSSF is part of the main jar, so this shouldn't fail ... - synchronized (hssfLock) { - if (createHssfFromScratch == null) { - String factoryClass = "org.apache.poi.hssf.usermodel.HSSFWorkbookFactory"; - Class<?> cls = initFactory(factoryClass, "poi-*.jar"); - try { - cls.getMethod("init").invoke(null); - } catch (Exception e) { - throw new IOException(factoryClass+" failed to init."); - } - } - } - } + return null; } - private static Class<?> initFactory(String factoryClass, String jar) throws IOException { - try { - return Class.forName(factoryClass, true, WorkbookFactory.class.getClassLoader()); - } catch (ClassNotFoundException e) { - throw new IOException(factoryClass+" not found - check if " + jar + " is on the classpath."); + + private static Workbook wp(FileMagic fm, ProviderMethod fun) throws IOException { + + for (WorkbookProvider prov : Singleton.INSTANCE.provider) { + if (prov.accepts(fm)) { + return fun.create(prov); + } } + throw new IOException("Your InputStream was neither an OLE2 stream, nor an OOXML stream " + + "or you haven't provide the poi-ooxml*.jar in the classpath/modulepath - FileMagic: "+fm); } } diff --git a/src/java/org/apache/poi/ss/usermodel/WorkbookProvider.java b/src/java/org/apache/poi/ss/usermodel/WorkbookProvider.java new file mode 100644 index 0000000000..12b8cc8dee --- /dev/null +++ b/src/java/org/apache/poi/ss/usermodel/WorkbookProvider.java @@ -0,0 +1,39 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +package org.apache.poi.ss.usermodel; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; + +import org.apache.poi.poifs.filesystem.DirectoryNode; +import org.apache.poi.poifs.filesystem.FileMagic; + +public interface WorkbookProvider { + boolean accepts(FileMagic fm); + + Workbook create(); + + Workbook create(InputStream inp) throws IOException; + + Workbook create(InputStream inp, String password) throws IOException; + + Workbook create(DirectoryNode root, String password) throws IOException; + + Workbook create(File file, String password, boolean readOnly) throws IOException; +} diff --git a/src/java/org/apache/poi/util/DefaultTempFileCreationStrategy.java b/src/java/org/apache/poi/util/DefaultTempFileCreationStrategy.java index 5a17d04a1d..0252b4b684 100644 --- a/src/java/org/apache/poi/util/DefaultTempFileCreationStrategy.java +++ b/src/java/org/apache/poi/util/DefaultTempFileCreationStrategy.java @@ -17,18 +17,18 @@ package org.apache.poi.util; +import static org.apache.poi.util.TempFile.JAVA_IO_TMPDIR; + import java.io.File; import java.io.IOException; import java.security.SecureRandom; -import static org.apache.poi.util.TempFile.JAVA_IO_TMPDIR; - /** * Default implementation of the {@link TempFileCreationStrategy} used by {@link TempFile}: * Files are collected into one directory and by default are deleted on exit from the VM. * Files may be manually deleted by user prior to JVM exit. * Files can be kept by defining the system property {@link #KEEP_FILES}. - * + * * Each file is registered for deletion with the JVM and the temporary directory is not deleted * after the JVM exits. Files that are created in the poifiles directory outside * the control of DefaultTempFileCreationStrategy are not deleted. @@ -36,37 +36,37 @@ import static org.apache.poi.util.TempFile.JAVA_IO_TMPDIR; * processes or limited temporary storage. */ public class DefaultTempFileCreationStrategy implements TempFileCreationStrategy { - /*package*/ static final String POIFILES = "poifiles"; - + public static final String POIFILES = "poifiles"; + /** To keep files after JVM exit, set the <code>-Dpoi.keep.tmp.files</code> JVM property */ public static final String KEEP_FILES = "poi.keep.tmp.files"; - + /** random number generator to generate unique filenames */ private static final SecureRandom random = new SecureRandom(); - + /** The directory where the temporary files will be created (<code>null</code> to use the default directory). */ private File dir; - + /** * Creates the strategy so that it creates the temporary files in the default directory. - * + * * @see File#createTempFile(String, String) */ public DefaultTempFileCreationStrategy() { this(null); } - + /** - * Creates the strategy allowing to set the + * Creates the strategy allowing to set the * * @param dir The directory where the temporary files will be created (<code>null</code> to use the default directory). - * + * * @see File#createTempFile(String, String, File) */ public DefaultTempFileCreationStrategy(File dir) { this.dir = dir; } - + private void createPOIFilesDirectory() throws IOException { // Identify and create our temp dir, if needed // The directory is not deleted, even if it was created by this TempFileCreationStrategy @@ -77,10 +77,10 @@ public class DefaultTempFileCreationStrategy implements TempFileCreationStrategy } dir = new File(tmpDir, POIFILES); } - + createTempDirectory(dir); } - + /** * Attempt to create a directory, including any necessary parent directories. * Does nothing if directory already exists. @@ -92,7 +92,7 @@ public class DefaultTempFileCreationStrategy implements TempFileCreationStrategy private synchronized void createTempDirectory(File directory) throws IOException { // create directory if it doesn't exist final boolean dirExists = (directory.exists() || directory.mkdirs()); - + if (!dirExists) { throw new IOException("Could not create temporary directory '" + directory + "'"); } @@ -100,13 +100,13 @@ public class DefaultTempFileCreationStrategy implements TempFileCreationStrategy throw new IOException("Could not create temporary directory. '" + directory + "' exists but is not a directory."); } } - + @Override public File createTempFile(String prefix, String suffix) throws IOException { // Identify and create our temp dir, if needed createPOIFilesDirectory(); - - // Generate a unique new filename + + // Generate a unique new filename File newFile = File.createTempFile(prefix, suffix, dir); // Set the delete on exit flag, unless explicitly disabled @@ -123,7 +123,7 @@ public class DefaultTempFileCreationStrategy implements TempFileCreationStrategy public File createTempDirectory(String prefix) throws IOException { // Identify and create our temp dir, if needed createPOIFilesDirectory(); - + // Generate a unique new filename // FIXME: Java 7+: use java.nio.Files#createTempDirectory final long n = random.nextLong(); diff --git a/src/multimodule/examples/java9/module-info.class b/src/multimodule/examples/java9/module-info.class Binary files differnew file mode 100644 index 0000000000..1b5faa4b37 --- /dev/null +++ b/src/multimodule/examples/java9/module-info.class diff --git a/src/multimodule/examples/java9/module-info.java b/src/multimodule/examples/java9/module-info.java new file mode 100644 index 0000000000..68b580e3ee --- /dev/null +++ b/src/multimodule/examples/java9/module-info.java @@ -0,0 +1,40 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +module org.apache.poi.examples { + + requires transitive org.apache.poi.ooxml; + requires transitive org.apache.poi.scratchpad; + requires java.xml; + + exports org.apache.poi.examples.crypt; + exports org.apache.poi.examples.hpsf; + exports org.apache.poi.examples.hslf; + exports org.apache.poi.examples.hsmf; + exports org.apache.poi.examples.hssf.eventusermodel; + exports org.apache.poi.examples.hssf.usermodel; + exports org.apache.poi.examples.hwpf; + exports org.apache.poi.examples.ss; + exports org.apache.poi.examples.ss.formula; + exports org.apache.poi.examples.ss.html; + exports org.apache.poi.examples.util; + exports org.apache.poi.examples.xslf; + exports org.apache.poi.examples.xssf.eventusermodel; + exports org.apache.poi.examples.xssf.streaming; + exports org.apache.poi.examples.xssf.usermodel; + exports org.apache.poi.examples.xwpf.usermodel; +}
\ No newline at end of file diff --git a/src/multimodule/excelant/java9/module-info.class b/src/multimodule/excelant/java9/module-info.class Binary files differnew file mode 100644 index 0000000000..5218a9bc92 --- /dev/null +++ b/src/multimodule/excelant/java9/module-info.class diff --git a/src/testcases/org/apache/poi/sl/TestCommonSL.java b/src/multimodule/excelant/java9/module-info.java index 2911b12e42..43b64560a7 100644 --- a/src/testcases/org/apache/poi/sl/TestCommonSL.java +++ b/src/multimodule/excelant/java9/module-info.java @@ -14,25 +14,15 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.sl; -import java.awt.Color; +module org.apache.poi.excelant { -import org.apache.poi.sl.draw.DrawPaint; -import org.apache.poi.sl.usermodel.PaintStyle; -import org.apache.poi.sl.usermodel.PaintStyle.SolidPaint; -import org.junit.Ignore; + requires ant; + requires org.apache.poi.ooxml; + requires org.apache.poi.scratchpad; -/** - * Currently only contains helper methods - */ -@Ignore -public class TestCommonSL { + exports org.apache.poi.ss.excelant; + exports org.apache.poi.ss.excelant.util; - public static Color getColor(PaintStyle paintActual) { - return (paintActual instanceof SolidPaint) - ? DrawPaint.applyColorTransform(((SolidPaint)paintActual).getSolidColor()) - : null; - } - -} + opens org.apache.poi.ss.excelant; +}
\ No newline at end of file diff --git a/src/multimodule/excelant/test9/module-info.class b/src/multimodule/excelant/test9/module-info.class Binary files differnew file mode 100644 index 0000000000..5218a9bc92 --- /dev/null +++ b/src/multimodule/excelant/test9/module-info.class diff --git a/src/multimodule/ooxml-security/java9/module-info.java b/src/multimodule/excelant/test9/module-info.java index ac902c3df9..43b64560a7 100644 --- a/src/multimodule/ooxml-security/java9/module-info.java +++ b/src/multimodule/excelant/test9/module-info.java @@ -15,18 +15,14 @@ limitations under the License. ==================================================================== */ +module org.apache.poi.excelant { -open module org.apache.poi.ooxml.security { - requires transitive xmlbeans; - requires java.xml; - exports com.microsoft.schemas.office.x2006.digsig; - exports com.microsoft.schemas.office.x2006.encryption; - exports com.microsoft.schemas.office.x2006.keyEncryptor.certificate; - exports com.microsoft.schemas.office.x2006.keyEncryptor.password; - exports org.etsi.uri.x01903.v13; - exports org.etsi.uri.x01903.v14; - exports org.openxmlformats.schemas.xpackage.x2006.digitalSignature; - exports org.openxmlformats.schemas.xpackage.x2006.relationships; - exports org.w3.x2000.x09.xmldsig; - // opens schemaorg_apache_xmlbeans.system.OoxmlSecurity to xmlbeans; + requires ant; + requires org.apache.poi.ooxml; + requires org.apache.poi.scratchpad; + + exports org.apache.poi.ss.excelant; + exports org.apache.poi.ss.excelant.util; + + opens org.apache.poi.ss.excelant; }
\ No newline at end of file diff --git a/src/multimodule/integration/java9/module-info.java b/src/multimodule/integration/java9/module-info.java new file mode 100644 index 0000000000..51d730c132 --- /dev/null +++ b/src/multimodule/integration/java9/module-info.java @@ -0,0 +1,27 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +module org.apache.poi.stress { + requires junit; + requires net.bytebuddy; + requires java.desktop; + + requires org.apache.poi.examples; + + exports org.apache.poi.stress; + +}
\ No newline at end of file diff --git a/src/multimodule/ooxml-lite-agent/java9/module-info.class b/src/multimodule/ooxml-lite-agent/java9/module-info.class Binary files differnew file mode 100644 index 0000000000..fb79979654 --- /dev/null +++ b/src/multimodule/ooxml-lite-agent/java9/module-info.class diff --git a/src/multimodule/ooxml-lite-agent/java9/module-info.java b/src/multimodule/ooxml-lite-agent/java9/module-info.java new file mode 100644 index 0000000000..04058f1cfc --- /dev/null +++ b/src/multimodule/ooxml-lite-agent/java9/module-info.java @@ -0,0 +1,22 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +module org.apache.poi.ooxml_lite { + requires java.instrument; + + exports org.apache.poi.ooxml.lite; +}
\ No newline at end of file diff --git a/src/multimodule/ooxml-lite/java9/module-info.class b/src/multimodule/ooxml-lite/java9/module-info.class Binary files differnew file mode 100644 index 0000000000..78ddc1f012 --- /dev/null +++ b/src/multimodule/ooxml-lite/java9/module-info.class diff --git a/src/multimodule/ooxml-lite/java9/module-info.java b/src/multimodule/ooxml-lite/java9/module-info.java new file mode 100644 index 0000000000..77a3bb34b3 --- /dev/null +++ b/src/multimodule/ooxml-lite/java9/module-info.java @@ -0,0 +1,47 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + + +open module org.apache.poi.ooxml.schemas { + // this still throws "requires transitive directive for an automatic module" in JDK 14 + // see https://bugs.openjdk.java.net/browse/JDK-8240847 + requires transitive org.apache.xmlbeans; + requires java.xml; + + exports com.microsoft.schemas.compatibility; + exports com.microsoft.schemas.office.excel; + exports com.microsoft.schemas.office.office; + exports com.microsoft.schemas.office.visio.x2012.main; + exports com.microsoft.schemas.office.x2006.digsig; + exports com.microsoft.schemas.vml; + exports org.apache.poi.schemas.ooxml.system.ooxml; + exports org.etsi.uri.x01903.v13; + exports org.openxmlformats.schemas.drawingml.x2006.chart; + exports org.openxmlformats.schemas.drawingml.x2006.main; + exports org.openxmlformats.schemas.drawingml.x2006.picture; + exports org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing; + exports org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing; + exports org.openxmlformats.schemas.officeDocument.x2006.customProperties; + exports org.openxmlformats.schemas.officeDocument.x2006.docPropsVTypes; + exports org.openxmlformats.schemas.officeDocument.x2006.extendedProperties; + exports org.openxmlformats.schemas.officeDocument.x2006.relationships; + exports org.openxmlformats.schemas.presentationml.x2006.main; + exports org.openxmlformats.schemas.spreadsheetml.x2006.main; + exports org.openxmlformats.schemas.wordprocessingml.x2006.main; + exports org.openxmlformats.schemas.xpackage.x2006.digitalSignature; + exports org.w3.x2000.x09.xmldsig; +}
\ No newline at end of file diff --git a/src/multimodule/ooxml-schemas/java9/module-info.class b/src/multimodule/ooxml-schemas/java9/module-info.class Binary files differindex 83a16f01ec..339c9d793e 100644 --- a/src/multimodule/ooxml-schemas/java9/module-info.class +++ b/src/multimodule/ooxml-schemas/java9/module-info.class diff --git a/src/multimodule/ooxml-schemas/java9/module-info.java b/src/multimodule/ooxml-schemas/java9/module-info.java index cd746371ae..974467061f 100644 --- a/src/multimodule/ooxml-schemas/java9/module-info.java +++ b/src/multimodule/ooxml-schemas/java9/module-info.java @@ -17,7 +17,9 @@ open module org.apache.poi.ooxml.schemas { - requires transitive xmlbeans; + // this still throws "requires transitive directive for an automatic module" in JDK 14 + // see https://bugs.openjdk.java.net/browse/JDK-8240847 + requires transitive org.apache.xmlbeans; requires java.xml; exports com.microsoft.schemas.compatibility; exports com.microsoft.schemas.office.excel; @@ -47,5 +49,11 @@ open module org.apache.poi.ooxml.schemas { exports org.openxmlformats.schemas.schemaLibrary.x2006.main; exports org.openxmlformats.schemas.spreadsheetml.x2006.main; exports org.openxmlformats.schemas.wordprocessingml.x2006.main; - // opens schemaorg_apache_xmlbeans.system.OoxmlSchemas to xmlbeans; + + exports com.microsoft.schemas.office.x2006.digsig; + exports org.etsi.uri.x01903.v13; + exports org.etsi.uri.x01903.v14; + exports org.openxmlformats.schemas.xpackage.x2006.digitalSignature; + exports org.openxmlformats.schemas.xpackage.x2006.relationships; + exports org.w3.x2000.x09.xmldsig; }
\ No newline at end of file diff --git a/src/multimodule/ooxml-security/java9/module-info.class b/src/multimodule/ooxml-security/java9/module-info.class Binary files differdeleted file mode 100644 index ce9793c57b..0000000000 --- a/src/multimodule/ooxml-security/java9/module-info.class +++ /dev/null diff --git a/src/multimodule/ooxml/java9/module-info.class b/src/multimodule/ooxml/java9/module-info.class Binary files differnew file mode 100644 index 0000000000..8dd7fcb574 --- /dev/null +++ b/src/multimodule/ooxml/java9/module-info.class diff --git a/src/multimodule/ooxml/java9/module-info.java b/src/multimodule/ooxml/java9/module-info.java new file mode 100644 index 0000000000..794e086e4e --- /dev/null +++ b/src/multimodule/ooxml/java9/module-info.java @@ -0,0 +1,87 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +module org.apache.poi.ooxml { + requires transitive org.apache.poi.poi; + requires transitive org.apache.xmlbeans; + requires transitive org.apache.poi.ooxml.schemas; + requires org.apache.commons.collections4; + requires org.apache.commons.codec; + requires commons.math3; + requires SparseBitSet; + requires commons.logging; + requires java.logging; + requires java.desktop; + requires java.security.jgss; + + provides org.apache.poi.ss.usermodel.WorkbookProvider with org.apache.poi.xssf.usermodel.XSSFWorkbookFactory; + + exports org.apache.poi.xwpf.extractor; + exports org.apache.poi.xwpf.usermodel; + exports org.apache.poi.xwpf.model; + exports org.apache.poi.xdgf.extractor; + exports org.apache.poi.xdgf.exceptions; + exports org.apache.poi.xdgf.usermodel; + exports org.apache.poi.xdgf.usermodel.section; + exports org.apache.poi.xdgf.usermodel.section.geometry; + exports org.apache.poi.xdgf.usermodel.shape; + exports org.apache.poi.xdgf.usermodel.shape.exceptions; + exports org.apache.poi.xdgf.xml; + exports org.apache.poi.xdgf.util; + exports org.apache.poi.xdgf.geom; + exports org.apache.poi.ooxml; + exports org.apache.poi.ooxml.dev; + exports org.apache.poi.ooxml.extractor; + exports org.apache.poi.ooxml.util; + exports org.apache.poi.xddf.usermodel; + exports org.apache.poi.xddf.usermodel.text; + exports org.apache.poi.xddf.usermodel.chart; + exports org.apache.poi.openxml4j.exceptions; + exports org.apache.poi.openxml4j.opc; + exports org.apache.poi.openxml4j.opc.internal; + exports org.apache.poi.openxml4j.opc.internal.marshallers; + exports org.apache.poi.openxml4j.opc.internal.unmarshallers; + exports org.apache.poi.openxml4j.util; + exports org.apache.poi.xssf; + exports org.apache.poi.xssf.extractor; + exports org.apache.poi.xssf.eventusermodel; + exports org.apache.poi.xssf.usermodel; + exports org.apache.poi.xssf.usermodel.helpers; + exports org.apache.poi.xssf.usermodel.extensions; + exports org.apache.poi.xssf.binary; + exports org.apache.poi.xssf.model; + exports org.apache.poi.xssf.streaming; + exports org.apache.poi.xssf.util; + exports org.apache.poi.xslf.draw; + exports org.apache.poi.xslf.usermodel; + exports org.apache.poi.xslf.model; + exports org.apache.poi.xslf.util; + exports org.apache.poi.poifs.crypt.dsig; + exports org.apache.poi.poifs.crypt.dsig.facets; + exports org.apache.poi.poifs.crypt.dsig.services; + exports org.apache.poi.poifs.crypt.temp; + + opens org.apache.poi.openxml4j.opc to org.apache.poi.poi; + + + /* optional dependencies for xml signatures - you need to add a require entry your module-info + * or add them via the --add-modules JVM argument */ + requires java.xml.crypto; + requires static org.apache.santuario.xmlsec; + requires static org.bouncycastle.provider; + requires static org.bouncycastle.pkix; +}
\ No newline at end of file diff --git a/src/multimodule/ooxml/test9/module-info.class b/src/multimodule/ooxml/test9/module-info.class Binary files differnew file mode 100644 index 0000000000..8d3730adb6 --- /dev/null +++ b/src/multimodule/ooxml/test9/module-info.class diff --git a/src/multimodule/ooxml/test9/module-info.java b/src/multimodule/ooxml/test9/module-info.java new file mode 100644 index 0000000000..36427adde4 --- /dev/null +++ b/src/multimodule/ooxml/test9/module-info.java @@ -0,0 +1,114 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +module org.apache.poi.ooxml { + requires transitive org.apache.poi.poi; + requires transitive org.apache.xmlbeans; + requires transitive org.apache.poi.ooxml.schemas; + requires org.apache.commons.collections4; + requires org.apache.commons.codec; + requires commons.math3; + requires SparseBitSet; + requires commons.logging; + requires java.logging; + requires java.desktop; + requires java.security.jgss; + + provides org.apache.poi.ss.usermodel.WorkbookProvider with org.apache.poi.xssf.usermodel.XSSFWorkbookFactory; + + exports org.apache.poi.xwpf.extractor; + exports org.apache.poi.xwpf.usermodel; + exports org.apache.poi.xwpf.model; + exports org.apache.poi.xdgf.extractor; + exports org.apache.poi.xdgf.exceptions; + exports org.apache.poi.xdgf.usermodel; + exports org.apache.poi.xdgf.usermodel.section; + exports org.apache.poi.xdgf.usermodel.section.geometry; + exports org.apache.poi.xdgf.usermodel.shape; + exports org.apache.poi.xdgf.usermodel.shape.exceptions; + exports org.apache.poi.xdgf.xml; + exports org.apache.poi.xdgf.util; + exports org.apache.poi.xdgf.geom; + exports org.apache.poi.ooxml; + exports org.apache.poi.ooxml.dev; + exports org.apache.poi.ooxml.extractor; + exports org.apache.poi.ooxml.util; + exports org.apache.poi.xddf.usermodel; + exports org.apache.poi.xddf.usermodel.text; + exports org.apache.poi.xddf.usermodel.chart; + exports org.apache.poi.openxml4j.exceptions; + exports org.apache.poi.openxml4j.opc; + exports org.apache.poi.openxml4j.opc.internal; + exports org.apache.poi.openxml4j.opc.internal.marshallers; + exports org.apache.poi.openxml4j.opc.internal.unmarshallers; + exports org.apache.poi.openxml4j.util; + exports org.apache.poi.xssf; + exports org.apache.poi.xssf.extractor; + exports org.apache.poi.xssf.eventusermodel; + exports org.apache.poi.xssf.usermodel; + exports org.apache.poi.xssf.usermodel.helpers; + exports org.apache.poi.xssf.usermodel.extensions; + exports org.apache.poi.xssf.binary; + exports org.apache.poi.xssf.model; + exports org.apache.poi.xssf.streaming; + exports org.apache.poi.xssf.util; + exports org.apache.poi.xslf.draw; + exports org.apache.poi.xslf.usermodel; + exports org.apache.poi.xslf.model; + exports org.apache.poi.xslf.util; + exports org.apache.poi.poifs.crypt.dsig; + exports org.apache.poi.poifs.crypt.dsig.facets; + exports org.apache.poi.poifs.crypt.dsig.services; + exports org.apache.poi.poifs.crypt.temp; + + opens org.apache.poi.openxml4j.opc to org.apache.poi.poi; + + + /* optional dependencies for xml signatures - you need to add a require entry your module-info + * or add them via the --add-modules JVM argument */ + requires java.xml.crypto; + requires org.apache.santuario.xmlsec; + requires org.bouncycastle.provider; + requires org.bouncycastle.pkix; + + + // test specific exports + requires junit; + requires com.google.common; + + exports org.apache.poi.extractor.ooxml to junit; + exports org.apache.poi.openxml4j.opc.compliance to junit; + exports org.apache.poi.poifs.crypt.tests to junit; + exports org.apache.poi.sl.tests to junit; + exports org.apache.poi.sl.tests.draw to junit; + exports org.apache.poi.ss.tests to junit; + exports org.apache.poi.ss.tests.extractor to junit; + exports org.apache.poi.ss.tests.format to junit; + exports org.apache.poi.ss.tests.formula to junit; + exports org.apache.poi.ss.tests.formula.eval to junit; + exports org.apache.poi.ss.tests.formula.functions to junit; + exports org.apache.poi.ss.tests.usermodel to junit; + exports org.apache.poi.ss.tests.util to junit; + exports org.apache.poi.util.tests to junit; + exports org.apache.poi.xslf to junit; + exports org.apache.poi.xslf.extractor to junit; + exports org.apache.poi.xssf.io to junit; + exports org.apache.poi.xssf.usermodel.charts to junit; + exports org.apache.poi.xwpf to junit; + + +}
\ No newline at end of file diff --git a/src/multimodule/poi/java9/module-info.class b/src/multimodule/poi/java9/module-info.class Binary files differnew file mode 100644 index 0000000000..7e09b989a9 --- /dev/null +++ b/src/multimodule/poi/java9/module-info.class diff --git a/src/multimodule/poi/java9/module-info.java b/src/multimodule/poi/java9/module-info.java index 65e100a014..50a41b014f 100644 --- a/src/multimodule/poi/java9/module-info.java +++ b/src/multimodule/poi/java9/module-info.java @@ -21,8 +21,16 @@ module org.apache.poi.poi { requires commons.math3; requires SparseBitSet; requires commons.logging; + requires java.logging; + requires java.desktop; + uses org.apache.poi.ss.usermodel.WorkbookProvider; + provides org.apache.poi.ss.usermodel.WorkbookProvider with org.apache.poi.hssf.usermodel.HSSFWorkbookFactory; + + exports org.apache.poi; + exports org.apache.poi.common; + exports org.apache.poi.common.usermodel; exports org.apache.poi.common.usermodel.fonts; exports org.apache.poi.ddf; exports org.apache.poi.extractor; @@ -49,6 +57,7 @@ module org.apache.poi.poi { exports org.apache.poi.hssf.util; exports org.apache.poi.poifs.common; exports org.apache.poi.poifs.crypt; + exports org.apache.poi.poifs.crypt.agile; exports org.apache.poi.poifs.crypt.binaryrc4; exports org.apache.poi.poifs.crypt.cryptoapi; exports org.apache.poi.poifs.crypt.standard; diff --git a/src/multimodule/poi/test9/module-info.class b/src/multimodule/poi/test9/module-info.class Binary files differnew file mode 100644 index 0000000000..01d4a48243 --- /dev/null +++ b/src/multimodule/poi/test9/module-info.class diff --git a/src/multimodule/poi/test9/module-info.java b/src/multimodule/poi/test9/module-info.java new file mode 100644 index 0000000000..26579cd98d --- /dev/null +++ b/src/multimodule/poi/test9/module-info.java @@ -0,0 +1,101 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +module org.apache.poi.poi { + requires org.apache.commons.collections4; + requires org.apache.commons.codec; + requires commons.math3; + requires SparseBitSet; + requires commons.logging; + requires java.logging; + requires java.desktop; + + uses org.apache.poi.ss.usermodel.WorkbookProvider; + + provides org.apache.poi.ss.usermodel.WorkbookProvider with org.apache.poi.hssf.usermodel.HSSFWorkbookFactory; + + exports org.apache.poi; + exports org.apache.poi.common; + exports org.apache.poi.common.usermodel; + exports org.apache.poi.common.usermodel.fonts; + exports org.apache.poi.ddf; + exports org.apache.poi.extractor; + exports org.apache.poi.hpsf; + exports org.apache.poi.hpsf.extractor; + exports org.apache.poi.hpsf.wellknown; + exports org.apache.poi.hssf; + exports org.apache.poi.hssf.dev; + exports org.apache.poi.hssf.eventmodel; + exports org.apache.poi.hssf.eventusermodel; + exports org.apache.poi.hssf.eventusermodel.dummyrecord; + exports org.apache.poi.hssf.extractor; + exports org.apache.poi.hssf.model; + exports org.apache.poi.hssf.record; + exports org.apache.poi.hssf.record.aggregates; + exports org.apache.poi.hssf.record.cf; + exports org.apache.poi.hssf.record.chart; + exports org.apache.poi.hssf.record.common; + exports org.apache.poi.hssf.record.cont; + exports org.apache.poi.hssf.record.crypto; + exports org.apache.poi.hssf.record.pivottable; + exports org.apache.poi.hssf.usermodel; + exports org.apache.poi.hssf.usermodel.helpers; + exports org.apache.poi.hssf.util; + exports org.apache.poi.poifs.common; + exports org.apache.poi.poifs.crypt; + exports org.apache.poi.poifs.crypt.agile; + exports org.apache.poi.poifs.crypt.binaryrc4; + exports org.apache.poi.poifs.crypt.cryptoapi; + exports org.apache.poi.poifs.crypt.standard; + exports org.apache.poi.poifs.crypt.xor; + exports org.apache.poi.poifs.dev; + exports org.apache.poi.poifs.eventfilesystem; + exports org.apache.poi.poifs.filesystem; + exports org.apache.poi.poifs.macros; + exports org.apache.poi.poifs.nio; + exports org.apache.poi.poifs.property; + exports org.apache.poi.poifs.storage; + exports org.apache.poi.sl.draw; + exports org.apache.poi.sl.draw.geom; + exports org.apache.poi.sl.extractor; + exports org.apache.poi.sl.image; + exports org.apache.poi.sl.usermodel; + exports org.apache.poi.ss; + exports org.apache.poi.ss.extractor; + exports org.apache.poi.ss.format; + exports org.apache.poi.ss.formula; + exports org.apache.poi.ss.formula.atp; + exports org.apache.poi.ss.formula.constant; + exports org.apache.poi.ss.formula.eval; + exports org.apache.poi.ss.formula.eval.forked; + exports org.apache.poi.ss.formula.function; + exports org.apache.poi.ss.formula.functions; + exports org.apache.poi.ss.formula.ptg; + exports org.apache.poi.ss.formula.udf; + exports org.apache.poi.ss.usermodel; + exports org.apache.poi.ss.usermodel.helpers; + exports org.apache.poi.ss.util; + exports org.apache.poi.ss.util.cellwalk; + exports org.apache.poi.util; + exports org.apache.poi.wp.usermodel; + + // test specific exports + requires junit; + requires net.bytebuddy; + opens org.apache.poi.hpsf.basic to junit; + opens org.apache.poi.hssf.record.pivot to junit; +}
\ No newline at end of file diff --git a/src/multimodule/scratchpad/java9/module-info.class b/src/multimodule/scratchpad/java9/module-info.class Binary files differnew file mode 100644 index 0000000000..879d58efd6 --- /dev/null +++ b/src/multimodule/scratchpad/java9/module-info.class diff --git a/src/multimodule/scratchpad/java9/module-info.java b/src/multimodule/scratchpad/java9/module-info.java new file mode 100644 index 0000000000..df7ea261e5 --- /dev/null +++ b/src/multimodule/scratchpad/java9/module-info.java @@ -0,0 +1,79 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +module org.apache.poi.scratchpad { + requires transitive org.apache.poi.poi; + requires java.desktop; + requires commons.math3; + + exports org.apache.poi.hmef; + exports org.apache.poi.hmef.dev; + exports org.apache.poi.hmef.extractor; + exports org.apache.poi.hmef.attribute; + exports org.apache.poi.hdgf; + exports org.apache.poi.hdgf.dev; + exports org.apache.poi.hdgf.streams; + exports org.apache.poi.hdgf.extractor; + exports org.apache.poi.hdgf.pointers; + exports org.apache.poi.hdgf.exceptions; + exports org.apache.poi.hdgf.chunks; + exports org.apache.poi.hwpf; + exports org.apache.poi.hwpf.dev; + exports org.apache.poi.hwpf.sprm; + exports org.apache.poi.hwpf.converter; + exports org.apache.poi.hwpf.extractor; + exports org.apache.poi.hwpf.usermodel; + exports org.apache.poi.hwpf.model; + exports org.apache.poi.hwpf.model.io; + exports org.apache.poi.hwpf.model.types; + // exports org.apache.poi.hwmf; + exports org.apache.poi.hwmf.record; + exports org.apache.poi.hwmf.draw; + exports org.apache.poi.hwmf.usermodel; + // exports org.apache.poi.extractor; + exports org.apache.poi.extractor.ole2; + exports org.apache.poi.hpbf; + exports org.apache.poi.hpbf.dev; + exports org.apache.poi.hpbf.extractor; + exports org.apache.poi.hpbf.model; + exports org.apache.poi.hpbf.model.qcbits; + // exports org.apache.poi.hslf; + exports org.apache.poi.hslf.dev; + exports org.apache.poi.hslf.record; + exports org.apache.poi.hslf.extractor; + exports org.apache.poi.hslf.exceptions; + exports org.apache.poi.hslf.usermodel; + exports org.apache.poi.hslf.blip; + exports org.apache.poi.hslf.model; + exports org.apache.poi.hslf.model.textproperties; + exports org.apache.poi.hslf.util; + // exports org.apache.poi.hssf; + exports org.apache.poi.hssf.converter; + // exports org.apache.poi.hssf.usermodel; + exports org.apache.poi.hsmf; + exports org.apache.poi.hsmf.dev; + exports org.apache.poi.hsmf.datatypes; + exports org.apache.poi.hsmf.extractor; + exports org.apache.poi.hsmf.exceptions; + exports org.apache.poi.hsmf.parsers; + // exports org.apache.poi.hemf; + // exports org.apache.poi.hemf.record; + exports org.apache.poi.hemf.record.emf; + exports org.apache.poi.hemf.record.emfplus; + exports org.apache.poi.hemf.draw; + exports org.apache.poi.hemf.usermodel; +}
\ No newline at end of file diff --git a/src/multimodule/scratchpad/test9/module-info.class b/src/multimodule/scratchpad/test9/module-info.class Binary files differnew file mode 100644 index 0000000000..86ad206e1a --- /dev/null +++ b/src/multimodule/scratchpad/test9/module-info.class diff --git a/src/multimodule/scratchpad/test9/module-info.java b/src/multimodule/scratchpad/test9/module-info.java new file mode 100644 index 0000000000..9360d6f5fe --- /dev/null +++ b/src/multimodule/scratchpad/test9/module-info.java @@ -0,0 +1,84 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + +module org.apache.poi.scratchpad { + requires transitive org.apache.poi.poi; + requires java.desktop; + requires commons.math3; + + exports org.apache.poi.hmef; + exports org.apache.poi.hmef.dev; + exports org.apache.poi.hmef.extractor; + exports org.apache.poi.hmef.attribute; + exports org.apache.poi.hdgf; + exports org.apache.poi.hdgf.dev; + exports org.apache.poi.hdgf.streams; + exports org.apache.poi.hdgf.extractor; + exports org.apache.poi.hdgf.pointers; + exports org.apache.poi.hdgf.exceptions; + exports org.apache.poi.hdgf.chunks; + exports org.apache.poi.hwpf; + exports org.apache.poi.hwpf.dev; + exports org.apache.poi.hwpf.sprm; + exports org.apache.poi.hwpf.converter; + exports org.apache.poi.hwpf.extractor; + exports org.apache.poi.hwpf.usermodel; + exports org.apache.poi.hwpf.model; + exports org.apache.poi.hwpf.model.io; + exports org.apache.poi.hwpf.model.types; + exports org.apache.poi.hwmf.record; + exports org.apache.poi.hwmf.draw; + exports org.apache.poi.hwmf.usermodel; + exports org.apache.poi.extractor.ole2; + exports org.apache.poi.hpbf; + exports org.apache.poi.hpbf.dev; + exports org.apache.poi.hpbf.extractor; + exports org.apache.poi.hpbf.model; + exports org.apache.poi.hpbf.model.qcbits; + exports org.apache.poi.hslf.dev; + exports org.apache.poi.hslf.record; + exports org.apache.poi.hslf.extractor; + exports org.apache.poi.hslf.exceptions; + exports org.apache.poi.hslf.usermodel; + exports org.apache.poi.hslf.blip; + exports org.apache.poi.hslf.model; + exports org.apache.poi.hslf.model.textproperties; + exports org.apache.poi.hslf.util; + exports org.apache.poi.hssf.converter; + exports org.apache.poi.hsmf; + exports org.apache.poi.hsmf.dev; + exports org.apache.poi.hsmf.datatypes; + exports org.apache.poi.hsmf.extractor; + exports org.apache.poi.hsmf.exceptions; + exports org.apache.poi.hsmf.parsers; + exports org.apache.poi.hemf.record.emf; + exports org.apache.poi.hemf.record.emfplus; + exports org.apache.poi.hemf.draw; + exports org.apache.poi.hemf.usermodel; + + + // test specific exports + requires junit; + requires org.mockito; + + exports org.apache.poi.hemf.hemfplus.extractor to junit; + exports org.apache.poi.hslf to junit; + exports org.apache.poi.hwmf to junit; + + opens org.apache.poi.hwpf.model to org.mockito; + opens org.apache.poi.hwpf.model.types to org.mockito; +}
\ No newline at end of file diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbookFactory.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbookFactory.java index 78fc0805e2..725c941864 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbookFactory.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbookFactory.java @@ -25,20 +25,20 @@ import org.apache.poi.EncryptedDocumentException; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackageAccess; -import org.apache.poi.openxml4j.opc.ZipPackage; -import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.apache.poi.poifs.filesystem.DirectoryNode; +import org.apache.poi.poifs.filesystem.DocumentFactoryHelper; +import org.apache.poi.poifs.filesystem.FileMagic; +import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookProvider; +import org.apache.poi.util.Internal; -public class XSSFWorkbookFactory extends WorkbookFactory { +@Internal +public class XSSFWorkbookFactory implements WorkbookProvider { - static { - init(); - } - - public static void init() { - WorkbookFactory.createXssfFromScratch = XSSFWorkbookFactory::createWorkbook; - WorkbookFactory.createXssfByStream = XSSFWorkbookFactory::createWorkbook; - WorkbookFactory.createXssfByPackage = o -> XSSFWorkbookFactory.createWorkbook((OPCPackage)o); - WorkbookFactory.createXssfByFile = XSSFWorkbookFactory::createWorkbook; + @Override + public boolean accepts(FileMagic fm) { + return fm == FileMagic.OOXML; } /** @@ -46,41 +46,62 @@ public class XSSFWorkbookFactory extends WorkbookFactory { * * @return The created workbook */ - public static XSSFWorkbook createWorkbook() { + @Override + public XSSFWorkbook create() { return new XSSFWorkbook(); } - /** - * Creates a XSSFWorkbook from the given OOXML Package. - * This is a convenience method to go along the create-methods of the super class. - * - * <p>Note that in order to properly release resources the - * Workbook should be closed after use.</p> - * - * @param pkg The {@link OPCPackage} opened for reading data. - * - * @return The created Workbook - * - * @throws IOException if an error occurs while reading the data - */ - public static XSSFWorkbook create(OPCPackage pkg) throws IOException { - return createWorkbook(pkg); + @Override + public XSSFWorkbook create(DirectoryNode root, String password) throws IOException { + try (InputStream stream = DocumentFactoryHelper.getDecryptedStream(root, password)) { + return create(stream); + } finally { + // as we processed the full stream already, we can close the filesystem here + // otherwise file handles are leaked + root.getFileSystem().close(); + } + } + + @Override + public Workbook create(InputStream inp, String password) throws IOException { + InputStream bufInp = FileMagic.prepareToCheckMagic(inp); + FileMagic fm = FileMagic.valueOf(bufInp); + + if (fm == FileMagic.OLE2) { + try (POIFSFileSystem poifs = new POIFSFileSystem(bufInp); + InputStream stream = DocumentFactoryHelper.getDecryptedStream(poifs.getRoot(), password)) { + return create(stream); + } + } + + if (fm == FileMagic.OOXML) { + return create(bufInp); + } + + return null; } /** - * Creates a XSSFWorkbook from the given OOXML Package + * Creates a XSSFWorkbook from the given InputStream * * <p>Note that in order to properly release resources the - * Workbook should be closed after use.</p> + * Workbook should be closed after use.</p> * - * @param pkg The {@link ZipPackage} opened for reading data. + * @param stream The {@link InputStream} to read data from. * - * @return The created Workbook + * @return The created Workbook * - * @throws IOException if an error occurs while reading the data + * @throws IOException if an error occurs while reading the data */ - public static XSSFWorkbook createWorkbook(ZipPackage pkg) throws IOException { - return createWorkbook((OPCPackage)pkg); + @SuppressWarnings("resource") + @Override + public XSSFWorkbook create(InputStream stream) throws IOException { + try { + OPCPackage pkg = OPCPackage.open(stream); + return createWorkbook(pkg); + } catch (InvalidFormatException e) { + throw new IOException(e); + } } /** @@ -122,31 +143,18 @@ public class XSSFWorkbookFactory extends WorkbookFactory { * @throws EncryptedDocumentException If the wrong password is given for a protected file */ @SuppressWarnings("resource") - public static XSSFWorkbook createWorkbook(File file, boolean readOnly) throws IOException { - try { - OPCPackage pkg = OPCPackage.open(file, readOnly ? PackageAccess.READ : PackageAccess.READ_WRITE); - return createWorkbook(pkg); - } catch (InvalidFormatException e) { - throw new IOException(e); + public XSSFWorkbook create(File file, String password, boolean readOnly) throws IOException { + FileMagic fm = FileMagic.valueOf(file); + + if (fm == FileMagic.OLE2) { + try (POIFSFileSystem poifs = new POIFSFileSystem(file, true); + InputStream stream = DocumentFactoryHelper.getDecryptedStream(poifs.getRoot(), password)) { + return create(stream); + } } - } - /** - * Creates a XSSFWorkbook from the given InputStream - * - * <p>Note that in order to properly release resources the - * Workbook should be closed after use.</p> - * - * @param stream The {@link InputStream} to read data from. - * - * @return The created Workbook - * - * @throws IOException if an error occurs while reading the data - */ - @SuppressWarnings("resource") - public static XSSFWorkbook createWorkbook(InputStream stream) throws IOException { try { - OPCPackage pkg = OPCPackage.open(stream); + OPCPackage pkg = OPCPackage.open(file, readOnly ? PackageAccess.READ : PackageAccess.READ_WRITE); return createWorkbook(pkg); } catch (InvalidFormatException e) { throw new IOException(e); diff --git a/src/ooxml/testcases/org/apache/poi/TestDetectAsOOXML.java b/src/ooxml/testcases/org/apache/poi/ooxml/TestDetectAsOOXML.java index 09ade054f2..6ab773d37b 100644 --- a/src/ooxml/testcases/org/apache/poi/TestDetectAsOOXML.java +++ b/src/ooxml/testcases/org/apache/poi/ooxml/TestDetectAsOOXML.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi; +package org.apache.poi.ooxml; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; @@ -42,7 +42,7 @@ public class TestDetectAsOOXML { public void testOpensProperly() throws IOException, InvalidFormatException { OPCPackage.open(HSSFTestDataSamples.openSampleFileStream("sample.xlsx")).close(); } - + @Test public void testDetectAsPOIFS() throws IOException { Object[][] fileAndMagic = { @@ -55,7 +55,7 @@ public class TestDetectAsOOXML { InputStream is = HSSFTestDataSamples.openSampleFileStream((String)fm[0]); is = FileMagic.prepareToCheckMagic(is); FileMagic act = FileMagic.valueOf(is); - + assertEquals("OOXML files should be detected, others not", act == FileMagic.OOXML, DocumentFactoryHelper.hasOOXMLHeader(is)); @@ -63,17 +63,17 @@ public class TestDetectAsOOXML { is.close(); } } - + @Test public void testFileCorruption() throws Exception { // create test InputStream byte[] testData = { 1, 2, 3 }; ByteArrayInputStream testInput = new ByteArrayInputStream(testData); InputStream is = FileMagic.prepareToCheckMagic(testInput); - + // detect header assertFalse(DocumentFactoryHelper.hasOOXMLHeader(is)); - + // check if InputStream is still intact byte[] act = IOUtils.toByteArray(is); assertArrayEquals(testData, act); diff --git a/src/ooxml/testcases/org/apache/poi/TestEmbedded.java b/src/ooxml/testcases/org/apache/poi/ooxml/TestEmbedded.java index 26ba8067a3..f7bd526170 100644 --- a/src/ooxml/testcases/org/apache/poi/TestEmbedded.java +++ b/src/ooxml/testcases/org/apache/poi/ooxml/TestEmbedded.java @@ -17,13 +17,13 @@ ==================================================================== */ -package org.apache.poi; +package org.apache.poi.ooxml; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import org.apache.poi.ooxml.POIXMLDocument; +import org.apache.poi.POIDataSamples; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackagePart; import org.apache.poi.util.IOUtils; diff --git a/src/ooxml/testcases/org/apache/poi/TestXMLPropertiesTextExtractor.java b/src/ooxml/testcases/org/apache/poi/ooxml/TestXMLPropertiesTextExtractor.java index 7186d64e70..6a8091cf8e 100644 --- a/src/ooxml/testcases/org/apache/poi/TestXMLPropertiesTextExtractor.java +++ b/src/ooxml/testcases/org/apache/poi/ooxml/TestXMLPropertiesTextExtractor.java @@ -14,13 +14,14 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi; +package org.apache.poi.ooxml; import static org.apache.poi.POITestCase.assertContains; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import org.apache.poi.POIDataSamples; import org.apache.poi.ooxml.extractor.POIXMLPropertiesTextExtractor; import org.apache.poi.ooxml.util.PackageHelper; import org.apache.poi.openxml4j.opc.OPCPackage; diff --git a/src/ooxml/testcases/org/apache/poi/ooxml/util/OOXMLLiteAgent.java b/src/ooxml/testcases/org/apache/poi/ooxml/lite/OOXMLLiteAgent.java index 1c7d5d6e35..21c7f28786 100644 --- a/src/ooxml/testcases/org/apache/poi/ooxml/util/OOXMLLiteAgent.java +++ b/src/ooxml/testcases/org/apache/poi/ooxml/lite/OOXMLLiteAgent.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ooxml.util; +package org.apache.poi.ooxml.lite; import java.io.IOException; import java.lang.instrument.ClassFileTransformer; diff --git a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java b/src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java index e997a0029e..a4e977c148 100644 --- a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSignatureInfo.java +++ b/src/ooxml/testcases/org/apache/poi/poifs/crypt/dsig/TestSignatureInfo.java @@ -21,7 +21,7 @@ http://code.google.com/p/eid-applet/source/browse/trunk/README.txt Copyright (C) 2008-2014 FedICT. ================================================================= */ -package org.apache.poi.poifs.crypt; +package org.apache.poi.poifs.crypt.dsig; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -81,9 +81,8 @@ import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackageAccess; import org.apache.poi.openxml4j.opc.PackageRelationshipTypes; -import org.apache.poi.poifs.crypt.dsig.SignatureConfig; -import org.apache.poi.poifs.crypt.dsig.SignatureInfo; -import org.apache.poi.poifs.crypt.dsig.SignaturePart; +import org.apache.poi.poifs.crypt.CryptoFunctions; +import org.apache.poi.poifs.crypt.HashAlgorithm; import org.apache.poi.poifs.crypt.dsig.facets.EnvelopedSignatureFacet; import org.apache.poi.poifs.crypt.dsig.facets.KeyInfoSignatureFacet; import org.apache.poi.poifs.crypt.dsig.facets.OOXMLSignatureFacet; diff --git a/src/ooxml/testcases/org/apache/poi/poifs/crypt/AllPOIFSCryptoTests.java b/src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/AllPOIFSCryptoTests.java index ffdbdff9f9..1e3fb4208f 100644 --- a/src/ooxml/testcases/org/apache/poi/poifs/crypt/AllPOIFSCryptoTests.java +++ b/src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/AllPOIFSCryptoTests.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.poifs.crypt; +package org.apache.poi.poifs.crypt.tests; import org.junit.runner.RunWith; import org.junit.runners.Suite; diff --git a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestAgileEncryptionParameters.java b/src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/TestAgileEncryptionParameters.java index 6c8cc16686..a892b9b550 100644 --- a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestAgileEncryptionParameters.java +++ b/src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/TestAgileEncryptionParameters.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.poifs.crypt; +package org.apache.poi.poifs.crypt.tests; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertTrue; @@ -30,6 +30,13 @@ import java.util.List; import javax.crypto.Cipher; import org.apache.poi.POIDataSamples; +import org.apache.poi.poifs.crypt.ChainingMode; +import org.apache.poi.poifs.crypt.CipherAlgorithm; +import org.apache.poi.poifs.crypt.Decryptor; +import org.apache.poi.poifs.crypt.EncryptionInfo; +import org.apache.poi.poifs.crypt.EncryptionMode; +import org.apache.poi.poifs.crypt.Encryptor; +import org.apache.poi.poifs.crypt.HashAlgorithm; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.util.IOUtils; import org.junit.Assume; @@ -44,7 +51,7 @@ import org.junit.runners.Parameterized.Parameters; public class TestAgileEncryptionParameters { static byte[] testData; - + @Parameter(value = 0) public CipherAlgorithm ca; @Parameter(value = 1) @@ -66,22 +73,22 @@ public class TestAgileEncryptionParameters { } } } - + return data; } - + @BeforeClass public static void initTestData() throws Exception { InputStream testFile = POIDataSamples.getDocumentInstance().openResourceAsStream("SampleDoc.docx"); testData = IOUtils.toByteArray(testFile); testFile.close(); } - + @Test public void testAgileEncryptionModes() throws Exception { int maxKeyLen = Cipher.getMaxAllowedKeyLength(ca.jceId); Assume.assumeTrue("Please install JCE Unlimited Strength Jurisdiction Policy files", maxKeyLen >= ca.defaultKeySize); - + ByteArrayOutputStream bos = new ByteArrayOutputStream(); POIFSFileSystem fsEnc = new POIFSFileSystem(); @@ -94,7 +101,7 @@ public class TestAgileEncryptionParameters { bos.reset(); fsEnc.writeFilesystem(bos); fsEnc.close(); - + POIFSFileSystem fsDec = new POIFSFileSystem(new ByteArrayInputStream(bos.toByteArray())); EncryptionInfo infoDec = new EncryptionInfo(fsDec); Decryptor dec = infoDec.getDecryptor(); diff --git a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestDecryptor.java b/src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/TestDecryptor.java index 3979518e05..7c06982b71 100644 --- a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestDecryptor.java +++ b/src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/TestDecryptor.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.poifs.crypt; +package org.apache.poi.poifs.crypt.tests; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -34,6 +34,8 @@ import javax.crypto.Cipher; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; import org.apache.poi.POIDataSamples; +import org.apache.poi.poifs.crypt.Decryptor; +import org.apache.poi.poifs.crypt.EncryptionInfo; import org.apache.poi.poifs.filesystem.DirectoryNode; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.util.IOUtils; @@ -177,5 +179,5 @@ public class TestDecryptor { assertTrue(d.verifyPassword("Test001!!")); zipOk(fs.getRoot(), d); } - } + } } diff --git a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestEncryptionInfo.java b/src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/TestEncryptionInfo.java index 0b4e3d2702..bbdad4d9c1 100644 --- a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestEncryptionInfo.java +++ b/src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/TestEncryptionInfo.java @@ -14,14 +14,19 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.poifs.crypt; +package org.apache.poi.poifs.crypt.tests; import static org.junit.Assert.assertEquals; import java.io.IOException; import org.apache.poi.POIDataSamples; +import org.apache.poi.poifs.crypt.CipherAlgorithm; +import org.apache.poi.poifs.crypt.CipherProvider; +import org.apache.poi.poifs.crypt.EncryptionInfo; +import org.apache.poi.poifs.crypt.HashAlgorithm; import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import org.junit.Assert; import org.junit.Test; public class TestEncryptionInfo { @@ -34,16 +39,16 @@ public class TestEncryptionInfo { assertEquals(3, info.getVersionMajor()); assertEquals(2, info.getVersionMinor()); - assertEquals(CipherAlgorithm.aes128, info.getHeader().getCipherAlgorithm()); - assertEquals(HashAlgorithm.sha1, info.getHeader().getHashAlgorithm()); + Assert.assertEquals(CipherAlgorithm.aes128, info.getHeader().getCipherAlgorithm()); + Assert.assertEquals(HashAlgorithm.sha1, info.getHeader().getHashAlgorithm()); assertEquals(128, info.getHeader().getKeySize()); assertEquals(32, info.getVerifier().getEncryptedVerifierHash().length); - assertEquals(CipherProvider.aes, info.getHeader().getCipherProvider()); + Assert.assertEquals(CipherProvider.aes, info.getHeader().getCipherProvider()); assertEquals("Microsoft Enhanced RSA and AES Cryptographic Provider", info.getHeader().getCspName()); - + fs.close(); } - + @Test public void testEncryptionInfoSHA512() throws Exception { POIFSFileSystem fs = new POIFSFileSystem(POIDataSamples.getPOIFSInstance().openResourceAsStream("protected_sha512.xlsx")); @@ -57,9 +62,9 @@ public class TestEncryptionInfo { assertEquals(HashAlgorithm.sha512, info.getHeader().getHashAlgorithm()); assertEquals(256, info.getHeader().getKeySize()); assertEquals(64, info.getVerifier().getEncryptedVerifierHash().length); - assertEquals(CipherProvider.aes, info.getHeader().getCipherProvider()); + assertEquals(CipherProvider.aes, info.getHeader().getCipherProvider()); // assertEquals("Microsoft Enhanced RSA and AES Cryptographic Provider", info.getHeader().getCspName()); - + fs.close(); } } diff --git a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestEncryptor.java b/src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/TestEncryptor.java index 55314125f0..bcf60b90c9 100644 --- a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestEncryptor.java +++ b/src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/TestEncryptor.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.poifs.crypt; +package org.apache.poi.poifs.crypt.tests; import static org.apache.poi.poifs.crypt.CryptoFunctions.getMessageDigest; import static org.junit.Assert.assertArrayEquals; @@ -41,6 +41,13 @@ import javax.crypto.Cipher; import org.apache.poi.POIDataSamples; import org.apache.poi.openxml4j.opc.ContentTypes; import org.apache.poi.openxml4j.opc.OPCPackage; +import org.apache.poi.poifs.crypt.CipherAlgorithm; +import org.apache.poi.poifs.crypt.Decryptor; +import org.apache.poi.poifs.crypt.EncryptionInfo; +import org.apache.poi.poifs.crypt.EncryptionMode; +import org.apache.poi.poifs.crypt.EncryptionVerifier; +import org.apache.poi.poifs.crypt.Encryptor; +import org.apache.poi.poifs.crypt.HashAlgorithm; import org.apache.poi.poifs.crypt.agile.AgileDecryptor; import org.apache.poi.poifs.crypt.agile.AgileEncryptionHeader; import org.apache.poi.poifs.crypt.agile.AgileEncryptionVerifier; diff --git a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestHxxFEncryption.java b/src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/TestHxxFEncryption.java index 25443d786f..487e16dfbe 100644 --- a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestHxxFEncryption.java +++ b/src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/TestHxxFEncryption.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.poifs.crypt; +package org.apache.poi.poifs.crypt.tests; import static org.apache.poi.POIDataSamples.getDocumentInstance; import static org.apache.poi.POIDataSamples.getSlideShowInstance; @@ -39,6 +39,7 @@ import org.apache.poi.extractor.POITextExtractor; import org.apache.poi.hssf.record.crypto.Biff8EncryptionKey; import org.apache.poi.ooxml.extractor.ExtractorFactory; import org.apache.poi.openxml4j.exceptions.OpenXML4JException; +import org.apache.poi.poifs.crypt.EncryptionInfo; import org.apache.poi.poifs.crypt.cryptoapi.CryptoAPIEncryptionHeader; import org.apache.poi.poifs.storage.RawDataUtil; import org.apache.xmlbeans.XmlException; @@ -100,17 +101,17 @@ public class TestHxxFEncryption { Biff8EncryptionKey.setCurrentUserPassword(null); } } - + @Test public void changePassword() throws IOException, OpenXML4JException, XmlException { newPassword("test"); } - + @Test public void removePassword() throws IOException, OpenXML4JException, XmlException { newPassword(null); } - + private void newPassword(String newPass) throws IOException, OpenXML4JException, XmlException { File f = sampleDir.getFile(file); Biff8EncryptionKey.setCurrentUserPassword(password); diff --git a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSecureTempZip.java b/src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/TestSecureTempZip.java index 6244cec2f7..f939257997 100644 --- a/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestSecureTempZip.java +++ b/src/ooxml/testcases/org/apache/poi/poifs/crypt/tests/TestSecureTempZip.java @@ -15,21 +15,24 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.poifs.crypt; +package org.apache.poi.poifs.crypt.tests; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import javax.crypto.Cipher; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.security.GeneralSecurityException; +import javax.crypto.Cipher; + import org.apache.poi.openxml4j.exceptions.OpenXML4JException; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.util.ZipEntrySource; +import org.apache.poi.poifs.crypt.Decryptor; +import org.apache.poi.poifs.crypt.EncryptionInfo; import org.apache.poi.poifs.crypt.temp.AesZipFileZipEntrySource; import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.xssf.XSSFTestDataSamples; @@ -56,27 +59,27 @@ public class TestSecureTempZip { boolean passOk = dec.verifyPassword("tika"); assertTrue(passOk); - // extract encrypted ooxml file and write to custom encrypted zip file + // extract encrypted ooxml file and write to custom encrypted zip file InputStream is = dec.getDataStream(poifs); - + // provide ZipEntrySource to poi which decrypts on the fly ZipEntrySource source = AesZipFileZipEntrySource.createZipEntrySource(is); // test the source OPCPackage opc = OPCPackage.open(source); String expected = "This is an Encrypted Excel spreadsheet."; - + XSSFEventBasedExcelExtractor extractor = new XSSFEventBasedExcelExtractor(opc); extractor.setIncludeSheetNames(false); String txt = extractor.getText(); assertEquals(expected, txt.trim()); - + XSSFWorkbook wb = new XSSFWorkbook(opc); txt = wb.getSheetAt(0).getRow(0).getCell(0).getStringCellValue(); assertEquals(expected, txt); extractor.close(); - + wb.close(); opc.close(); source.close(); diff --git a/src/ooxml/testcases/org/apache/poi/sl/SLCommonUtils.java b/src/ooxml/testcases/org/apache/poi/sl/tests/SLCommonUtils.java index 1b2b1829cc..3c3d243db8 100644 --- a/src/ooxml/testcases/org/apache/poi/sl/SLCommonUtils.java +++ b/src/ooxml/testcases/org/apache/poi/sl/tests/SLCommonUtils.java @@ -17,7 +17,7 @@ * ==================================================================== */ -package org.apache.poi.sl; +package org.apache.poi.sl.tests; import java.io.IOException; import java.io.InputStream; @@ -28,7 +28,7 @@ import org.apache.poi.sl.usermodel.SlideShowFactory; public class SLCommonUtils { private static POIDataSamples _slTests = POIDataSamples.getSlideShowInstance(); - + /** a generic way to open a sample slideshow document **/ public static SlideShow<?,?> openSampleSlideshow(String sampleName) throws IOException { try (InputStream is = _slTests.openResourceAsStream(sampleName)) { @@ -40,9 +40,9 @@ public class SLCommonUtils { /** * Tests, if the scratchpad classes are on the classpath - * + * * @return true, if only xslf is on the classpath, and false, if both classpaths - * (XSLF and HSLF) can be used/referenced + * (XSLF and HSLF) can be used/referenced */ public static boolean xslfOnly() { try { diff --git a/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java b/src/ooxml/testcases/org/apache/poi/sl/tests/TestFonts.java index 0590e8d7a2..2b9963ecd7 100644 --- a/src/ooxml/testcases/org/apache/poi/sl/TestFonts.java +++ b/src/ooxml/testcases/org/apache/poi/sl/tests/TestFonts.java @@ -15,9 +15,9 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.sl; +package org.apache.poi.sl.tests; -import static org.apache.poi.sl.SLCommonUtils.xslfOnly; +import static org.apache.poi.sl.tests.SLCommonUtils.xslfOnly; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeFalse; diff --git a/src/ooxml/testcases/org/apache/poi/sl/TestHeadersFooters.java b/src/ooxml/testcases/org/apache/poi/sl/tests/TestHeadersFooters.java index a4b50bf082..ceb65d6881 100644 --- a/src/ooxml/testcases/org/apache/poi/sl/TestHeadersFooters.java +++ b/src/ooxml/testcases/org/apache/poi/sl/tests/TestHeadersFooters.java @@ -17,9 +17,9 @@ * ==================================================================== */ -package org.apache.poi.sl; +package org.apache.poi.sl.tests; -import static org.apache.poi.sl.SLCommonUtils.openSampleSlideshow; +import static org.apache.poi.sl.tests.SLCommonUtils.openSampleSlideshow; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -40,10 +40,10 @@ public class TestHeadersFooters { testSlideShow(ppt); ppt.close(); } - + private void testSlideShow(SlideShow<?,?> ppt) { Slide<?,?> sl = ppt.getSlides().get(0); - + List<? extends Shape<?,?>> shapes = sl.getShapes(); TextShape<?,?> ts0 = (TextShape<?,?>)shapes.get(0); assertEquals("Test file", ts0.getText()); diff --git a/src/ooxml/testcases/org/apache/poi/sl/TestOleShape.java b/src/ooxml/testcases/org/apache/poi/sl/tests/TestOleShape.java index 44f901d5e0..f652bcc0e0 100644 --- a/src/ooxml/testcases/org/apache/poi/sl/TestOleShape.java +++ b/src/ooxml/testcases/org/apache/poi/sl/tests/TestOleShape.java @@ -15,9 +15,9 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.sl; +package org.apache.poi.sl.tests; -import static org.apache.poi.sl.SLCommonUtils.xslfOnly; +import static org.apache.poi.sl.tests.SLCommonUtils.xslfOnly; import static org.apache.poi.sl.usermodel.ObjectMetaData.Application.EXCEL_V12; import static org.apache.poi.sl.usermodel.ObjectMetaData.Application.EXCEL_V8; import static org.apache.poi.sl.usermodel.ObjectMetaData.Application.PDF; @@ -94,7 +94,7 @@ public class TestOleShape { "2RK9pwE9DkJLLDioDACbOSCfAQGSEYkqhGJCGw8hKJ+xgSCgvogoN8hPldsBCM+mzZ9P0wE9pZwof8V92MD" + "jHkKLEAUFMA+04XC1EzX6UdMAALxcERgK444+wB0Go1CA3jANCNRGdj1UoyIZhlpPsMobf48GmkeI1Pp8xi" + "Nsm0eo9O3/mAoAvIFEKIQ58wPgrAtK+oJwyjAmL0+bBEPBugzGsUoiKAKhSQGmYjD4y3trXD/AmBc9IeqBwAA"; - + enum Api { HSLF, XSLF } @@ -103,15 +103,15 @@ public class TestOleShape { @Parameter(value = 1) public ObjectMetaData.Application app; - + private static File pictureFile; @BeforeClass public static void initPicture() { pictureFile = POIDataSamples.getSlideShowInstance().getFile("wrench.emf"); } - - + + @Parameters(name="{0} {1}") public static Collection<Object[]> data() { return Arrays.asList(new Object[][] { @@ -123,7 +123,7 @@ public class TestOleShape { { Api.XSLF, PDF }, }); } - + @Test public void embedData() throws IOException, InvalidFormatException, ReflectiveOperationException { final ByteArrayInputStream pptBytes; @@ -146,7 +146,7 @@ public class TestOleShape { } } } - + private SlideShow<?,?> createSlideShow() throws ReflectiveOperationException { if (api == Api.XSLF) { return new XMLSlideShow(); @@ -186,7 +186,7 @@ public class TestOleShape { break; } } - + private void validateOleData(final InputStream in) throws IOException, InvalidFormatException, ReflectiveOperationException { switch (app) { case EXCEL_V8: @@ -218,6 +218,6 @@ public class TestOleShape { fail("not implemented"); break; } - + } } diff --git a/src/ooxml/testcases/org/apache/poi/sl/TestSlide.java b/src/ooxml/testcases/org/apache/poi/sl/tests/TestSlide.java index 60a8a3691d..47494b3407 100644 --- a/src/ooxml/testcases/org/apache/poi/sl/TestSlide.java +++ b/src/ooxml/testcases/org/apache/poi/sl/tests/TestSlide.java @@ -17,9 +17,9 @@ * ==================================================================== */ -package org.apache.poi.sl; +package org.apache.poi.sl.tests; -import static org.apache.poi.sl.SLCommonUtils.xslfOnly; +import static org.apache.poi.sl.tests.SLCommonUtils.xslfOnly; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assume.assumeFalse; @@ -43,30 +43,30 @@ public class TestSlide { hideSlide(ppt1); ppt1.close(); } - + @Test public void hideXSLF() throws IOException { SlideShow<?,?> ppt1 = new XMLSlideShow(); hideSlide(ppt1); ppt1.close(); } - + private void hideSlide(SlideShow<?,?> ppt1) throws IOException { ppt1.createSlide().setHidden(true); ppt1.createSlide(); - + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ppt1.write(bos); ppt1.close(); - + InputStream is = new ByteArrayInputStream(bos.toByteArray()); SlideShow<?,?> ppt2 = SlideShowFactory.create(is); Boolean[] hiddenState = ppt2.getSlides().stream().map(e -> e.isHidden()).toArray(Boolean[]::new); - + assertTrue(hiddenState[0]); assertFalse(hiddenState[1]); - + ppt2.close(); } }
\ No newline at end of file diff --git a/src/ooxml/testcases/org/apache/poi/sl/TestTable.java b/src/ooxml/testcases/org/apache/poi/sl/tests/TestTable.java index 7c040475fd..fd31762b8d 100644 --- a/src/ooxml/testcases/org/apache/poi/sl/TestTable.java +++ b/src/ooxml/testcases/org/apache/poi/sl/tests/TestTable.java @@ -17,10 +17,10 @@ * ==================================================================== */ -package org.apache.poi.sl; +package org.apache.poi.sl.tests; -import static org.apache.poi.sl.SLCommonUtils.openSampleSlideshow; -import static org.apache.poi.sl.SLCommonUtils.xslfOnly; +import static org.apache.poi.sl.tests.SLCommonUtils.openSampleSlideshow; +import static org.apache.poi.sl.tests.SLCommonUtils.xslfOnly; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -44,7 +44,7 @@ import org.apache.poi.xslf.usermodel.XMLSlideShow; import org.junit.Test; public class TestTable { - + @Test public void colWidthRowHeight() throws IOException { assumeFalse(xslfOnly()); @@ -56,33 +56,33 @@ public class TestTable { SlideShow<?,?> pptx = openSampleSlideshow("table_test.pptx"); TableShape<?,?> tsx = (TableShape<?,?>)pptx.getSlides().get(0).getShapes().get(0); - + // assume table shape should be equal to itself confirmTableShapeEqual(ts, ts); confirmTableShapeEqual(tsx, tsx); - + // assert ppt and pptx versions of the same table have the same shape confirmTableShapeEqual(ts, tsx); - + // change row height and validate again tsx.setRowHeight(1, 50); ts.setRowHeight(1, 50); confirmTableShapeEqual(ts, tsx); - + pptx.close(); ppt.close(); } - + private void confirmTableShapeEqual(TableShape<?,?> tableA, TableShape<?,?> tableB) { int cols = tableA.getNumberOfColumns(); int rows = tableA.getNumberOfRows(); - + int colsx = tableB.getNumberOfColumns(); int rowsx = tableB.getNumberOfRows(); - + assertEquals("tables should have same number of columns", cols, colsx); assertEquals("tables should have same number of rows", rows, rowsx); - + for (int i=0; i<cols; i++) { assertEquals("Width of column " + i + " should be equal", tableA.getColumnWidth(i), tableB.getColumnWidth(i), 0.2); @@ -101,14 +101,14 @@ public class TestTable { testTextDirection(ppt1); ppt1.close(); } - + @Test public void directionXSLF() throws IOException { SlideShow<?,?> ppt1 = new XMLSlideShow(); testTextDirection(ppt1); ppt1.close(); } - + private void testTextDirection(SlideShow<?,?> ppt1) throws IOException { TextDirection[] tds = { @@ -117,10 +117,10 @@ public class TestTable { TextDirection.VERTICAL_270, // TextDirection.STACKED is not supported on HSLF }; - + TableShape<?,?> tbl1 = ppt1.createSlide().createTable(1, 3); tbl1.setAnchor(new Rectangle2D.Double(50, 50, 200, 200)); - + int col = 0; for (TextDirection td : tds) { TableCell<?,?> c = tbl1.getCell(0, col++); @@ -129,15 +129,15 @@ public class TestTable { c.setText("bla"); } } - + ByteArrayOutputStream bos = new ByteArrayOutputStream(); ppt1.write(bos); ppt1.close(); - + InputStream is = new ByteArrayInputStream(bos.toByteArray()); SlideShow<?,?> ppt2 = SlideShowFactory.create(is); TableShape<?,?> tbl2 = (TableShape<?,?>)ppt2.getSlides().get(0).getShapes().get(0); - + col = 0; for (TextDirection td : tds) { TableCell<?,?> c = tbl2.getCell(0, col++); @@ -145,7 +145,7 @@ public class TestTable { } ppt2.close(); } - + @Test public void tableSpan() throws IOException { String[] files = (xslfOnly()) ? new String[]{"bug60993.pptx"} : new String[]{"bug60993.pptx", "bug60993.ppt"}; diff --git a/src/ooxml/testcases/org/apache/poi/sl/draw/TestDrawPictureShape.java b/src/ooxml/testcases/org/apache/poi/sl/tests/draw/TestDrawPictureShape.java index 8534610eb8..944ff42791 100644 --- a/src/ooxml/testcases/org/apache/poi/sl/draw/TestDrawPictureShape.java +++ b/src/ooxml/testcases/org/apache/poi/sl/tests/draw/TestDrawPictureShape.java @@ -16,7 +16,7 @@ * limitations under the License. * ==================================================================== */ -package org.apache.poi.sl.draw; +package org.apache.poi.sl.tests.draw; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -28,6 +28,7 @@ import java.io.IOException; import java.io.InputStream; import org.apache.poi.POIDataSamples; +import org.apache.poi.sl.draw.DrawPictureShape; import org.apache.poi.sl.usermodel.PictureData; import org.apache.poi.sl.usermodel.PictureShape; import org.apache.poi.sl.usermodel.RectAlign; diff --git a/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java b/src/ooxml/testcases/org/apache/poi/ss/tests/TestWorkbookFactory.java index 731f581ea2..9f2dc299b9 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/TestWorkbookFactory.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/TestWorkbookFactory.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss; +package org.apache.poi.ss.tests; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertFalse; @@ -123,7 +123,7 @@ public final class TestWorkbookFactory { assertCloseDoesNotModifyFile(xls, wb); // Package -> xssf - wb = XSSFWorkbookFactory.create( + wb = XSSFWorkbookFactory.createWorkbook( OPCPackage.open( HSSFTestDataSamples.openSampleFileStream(xlsx)) ); @@ -396,7 +396,7 @@ public final class TestWorkbookFactory { * See Bugzilla bug #62831 - #WorkbookFactory.create(File) needs * to work for sub-classes of File too, eg JFileChooser */ - @Test(expected = ClassCastException.class) + @Test public void testFileSubclass() throws Exception { File normalXLS = HSSFTestDataSamples.getSampleFile(xls); File normalXLSX = HSSFTestDataSamples.getSampleFile(xlsx); @@ -405,21 +405,17 @@ public final class TestWorkbookFactory { assertTrue(altXLS.exists()); assertTrue(altXLSX.exists()); - Workbook wb = WorkbookFactory.create(altXLS); - assertNotNull(wb); - assertTrue(wb instanceof HSSFWorkbook); - closeOrRevert(wb); - - wb = WorkbookFactory.create(altXLSX); - assertNotNull(wb); - assertTrue(wb instanceof XSSFWorkbook); - closeOrRevert(wb); - - // check what happens if the file is passed as "Object" + try (Workbook wb = WorkbookFactory.create(altXLS)) { + assertNotNull(wb); + assertTrue(wb instanceof HSSFWorkbook); + closeOrRevert(wb); + } - //noinspection deprecation - WorkbookFactory.create((Object)altXLSX); - // expected a ClassCastException here because create() in this case expects an object of type "OPCPackage" + try (Workbook wb = WorkbookFactory.create(altXLSX)) { + assertNotNull(wb); + assertTrue(wb instanceof XSSFWorkbook); + closeOrRevert(wb); + } } private static class TestFile extends File { diff --git a/src/ooxml/testcases/org/apache/poi/ss/extractor/TestEmbeddedExtractor.java b/src/ooxml/testcases/org/apache/poi/ss/tests/extractor/TestEmbeddedExtractor.java index 0b755b91d6..d5d0c47623 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/extractor/TestEmbeddedExtractor.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/extractor/TestEmbeddedExtractor.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.extractor; +package org.apache.poi.ss.tests.extractor; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -33,6 +33,8 @@ import org.apache.poi.POIDataSamples; import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +import org.apache.poi.ss.extractor.EmbeddedData; +import org.apache.poi.ss.extractor.EmbeddedExtractor; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; diff --git a/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java b/src/ooxml/testcases/org/apache/poi/ss/tests/format/TestCellFormatPart.java index 2ddbb2470e..824fe4ba15 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/format/TestCellFormatPart.java @@ -14,12 +14,11 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.ss.format; +package org.apache.poi.ss.tests.format; import static java.awt.Color.ORANGE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import java.awt.Color; import java.io.IOException; @@ -27,12 +26,12 @@ import java.util.Locale; import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Stream; import javax.swing.JLabel; -import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.ss.ITestDataProvider; +import org.apache.poi.ss.format.CellFormat; +import org.apache.poi.ss.format.CellFormatPart; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; @@ -41,7 +40,6 @@ import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.util.LocaleUtil; import org.apache.poi.xssf.XSSFITestDataProvider; import org.junit.AfterClass; -import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -156,14 +154,6 @@ public class TestCellFormatPart { runFormatTests("FormatConditionTests.xlsx", Cell::getNumericCellValue); } - @Test - public void testNamedColors() { - assertTrue(CellFormatPart.NAMED_COLORS.size() >= HSSFColor.HSSFColorPredefined.values().length); - Stream.of("GREEN","Green","RED","Red","BLUE","Blue","YELLOW","Yellow") - .map(CellFormatPart.NAMED_COLORS::get) - .forEach(Assert::assertNotNull); - } - private double extractNumber(String str) { Matcher m = NUMBER_EXTRACT_FMT.matcher(str); if (!m.find()) { diff --git a/src/ooxml/testcases/org/apache/poi/ss/formula/TestFormulaParser.java b/src/ooxml/testcases/org/apache/poi/ss/tests/formula/TestFormulaParser.java index 36c96011d2..01c2f13ff0 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/formula/TestFormulaParser.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/formula/TestFormulaParser.java @@ -16,17 +16,19 @@ * limitations under the License. * ==================================================================== */ -package org.apache.poi.ss.formula; +package org.apache.poi.ss.tests.formula; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import java.io.IOException; - import org.apache.poi.hssf.usermodel.HSSFEvaluationWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.formula.FormulaParseException; +import org.apache.poi.ss.formula.FormulaParser; +import org.apache.poi.ss.formula.FormulaParsingWorkbook; +import org.apache.poi.ss.formula.FormulaType; import org.apache.poi.ss.formula.ptg.AbstractFunctionPtg; import org.apache.poi.ss.formula.ptg.NameXPxg; import org.apache.poi.ss.formula.ptg.Ptg; @@ -41,7 +43,7 @@ import org.junit.Test; /** * Test {@link FormulaParser}'s handling of row numbers at the edge of the * HSSF/XSSF ranges. - * + * * @author David North */ public class TestFormulaParser { @@ -63,13 +65,13 @@ public class TestFormulaParser { FormulaParsingWorkbook workbook = HSSFEvaluationWorkbook.create(wb); FormulaParser.parse(formula, workbook, FormulaType.CELL, 0); IOUtils.closeQuietly(wb); - } + } private static void checkXSSFFormula(String formula) { XSSFWorkbook wb = new XSSFWorkbook(); FormulaParsingWorkbook workbook = XSSFEvaluationWorkbook.create(wb); FormulaParser.parse(formula, workbook, FormulaType.CELL, 0); IOUtils.closeQuietly(wb); - } + } private static void checkFormula(String formula) { checkHSSFFormula(formula); checkXSSFFormula(formula); @@ -96,7 +98,7 @@ public class TestFormulaParser { // expected here } } - + // copied from org.apache.poi.hssf.model.TestFormulaParser @Test public void testMacroFunction() throws Exception { @@ -150,7 +152,7 @@ public class TestFormulaParser { */ } } - + @Test public void testParserErrors() throws Exception { try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("testNames.xlsm")) { @@ -165,11 +167,11 @@ public class TestFormulaParser { parseExpectedException("myFunc(", workbook); //no closing paren } } - + private static void parseExpectedException(String formula) { parseExpectedException(formula, null); } - + /** confirm formula has invalid syntax and parsing the formula results in FormulaParseException */ private static void parseExpectedException(String formula, FormulaParsingWorkbook wb) { @@ -181,7 +183,7 @@ public class TestFormulaParser { assertNotNull(e.getMessage()); } } - + // trivial case for bug 60219: FormulaParser can't parse external references when sheet name is quoted @Test public void testParseExternalReferencesWithUnquotedSheetName() throws Exception { @@ -198,7 +200,7 @@ public class TestFormulaParser { assertEquals("Column", 0, pxg.getColumn()); wb.close(); } - + // bug 60219: FormulaParser can't parse external references when sheet name is quoted @Test public void testParseExternalReferencesWithQuotedSheetName() throws Exception { diff --git a/src/ooxml/testcases/org/apache/poi/ss/formula/TestStructuredReferences.java b/src/ooxml/testcases/org/apache/poi/ss/tests/formula/TestStructuredReferences.java index 547555dce7..aa239a19b2 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/formula/TestStructuredReferences.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/formula/TestStructuredReferences.java @@ -15,14 +15,13 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.formula; +package org.apache.poi.ss.tests.formula; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CellValue; @@ -58,11 +57,11 @@ public class TestStructuredReferences { assertTrue("Valid structured reference syntax didn't match expression", Table.isStructuredReference.matcher("\\[col1]").matches()); assertTrue("Valid structured reference syntax didn't match expression", Table.isStructuredReference.matcher("\\[#This Row]").matches()); assertTrue("Valid structured reference syntax didn't match expression", Table.isStructuredReference.matcher("\\[ [col1], [col2] ]").matches()); - + // can't have a space between the table name and open bracket assertFalse("Invalid structured reference syntax didn't fail expression", Table.isStructuredReference.matcher("\\abc [ [col1], [col2] ]").matches()); } - + @Test public void testTableFormulas() throws Exception { try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("StructuredReferences.xlsx")) { diff --git a/src/ooxml/testcases/org/apache/poi/ss/formula/eval/TestXSSFCircularReferences.java b/src/ooxml/testcases/org/apache/poi/ss/tests/formula/eval/TestXSSFCircularReferences.java index 0b8c9fcb1e..114f70a13e 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/formula/eval/TestXSSFCircularReferences.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/formula/eval/TestXSSFCircularReferences.java @@ -15,8 +15,9 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.formula.eval; +package org.apache.poi.ss.tests.formula.eval; +import org.apache.poi.ss.formula.eval.BaseTestCircularReferences; import org.apache.poi.xssf.XSSFITestDataProvider; /** diff --git a/src/ooxml/testcases/org/apache/poi/ss/formula/functions/CountifsTests.java b/src/ooxml/testcases/org/apache/poi/ss/tests/formula/functions/CountifsTests.java index 3b3d71465e..45318e4b0e 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/formula/functions/CountifsTests.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/formula/functions/CountifsTests.java @@ -16,7 +16,7 @@ ==================================================================== */ -package org.apache.poi.ss.formula.functions; +package org.apache.poi.ss.tests.formula.functions; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -42,7 +42,7 @@ import org.junit.Test; public class CountifsTests { private Workbook workbook; - + /** * initialize a workbook */ @@ -52,7 +52,7 @@ public class CountifsTests { // in OOXML, it was introduced with Office 2007 workbook = new HSSFWorkbook(); } - + /** * Close the workbook if needed */ @@ -60,7 +60,7 @@ public class CountifsTests { public void after() { IOUtils.closeQuietly(workbook); } - + /** * Basic call */ @@ -105,7 +105,7 @@ public class CountifsTests { evaluate = evaluator.evaluate(cellA1); assertEquals(15, evaluate.getErrorValue()); } - + /** * the bug returned the wrong count, this verifies the fix * @throws Exception if the file can't be read diff --git a/src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestProper.java b/src/ooxml/testcases/org/apache/poi/ss/tests/formula/functions/TestProper.java index 89fdb5247f..963fda3d01 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestProper.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/formula/functions/TestProper.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.formula.functions; +package org.apache.poi.ss.tests.formula.functions; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -24,6 +24,7 @@ import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.formula.eval.StringEval; import org.apache.poi.ss.formula.eval.ValueEval; +import org.apache.poi.ss.formula.functions.TextFunction; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CellValue; diff --git a/src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestSumifsXSSF.java b/src/ooxml/testcases/org/apache/poi/ss/tests/formula/functions/TestSumifsXSSF.java index 7929a95669..4963148ffd 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestSumifsXSSF.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/formula/functions/TestSumifsXSSF.java @@ -17,10 +17,12 @@ * ==================================================================== */ -package org.apache.poi.ss.formula.functions; +package org.apache.poi.ss.tests.formula.functions; import static org.junit.Assert.assertEquals; +import java.io.IOException; + import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.FormulaEvaluator; import org.apache.poi.ss.usermodel.Sheet; @@ -28,8 +30,6 @@ import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.XSSFTestDataSamples; import org.junit.Test; -import java.io.IOException; - /** * */ diff --git a/src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestVlookup.java b/src/ooxml/testcases/org/apache/poi/ss/tests/formula/functions/TestVlookup.java index 0dc0655a1f..34bc8501cf 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/formula/functions/TestVlookup.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/formula/functions/TestVlookup.java @@ -15,7 +15,12 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.formula.functions; +package org.apache.poi.ss.tests.formula.functions; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import java.io.IOException; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; @@ -29,11 +34,6 @@ import org.apache.poi.xssf.XSSFTestDataSamples; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.junit.Test; -import java.io.IOException; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; - /** * Test the VLOOKUP function */ diff --git a/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXCell.java b/src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/BaseTestXCell.java index 46d7d6319e..f3eb74475e 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXCell.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/BaseTestXCell.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.usermodel; +package org.apache.poi.ss.tests.usermodel; import static org.junit.Assert.assertEquals; @@ -23,6 +23,11 @@ import java.io.IOException; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.ss.ITestDataProvider; +import org.apache.poi.ss.usermodel.BaseTestCell; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.streaming.SXSSFCell; import org.apache.poi.xssf.usermodel.XSSFCell; import org.junit.Test; diff --git a/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXRow.java b/src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/BaseTestXRow.java index a4b21001e5..b4f2bef2e8 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXRow.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/BaseTestXRow.java @@ -15,19 +15,20 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.usermodel; +package org.apache.poi.ss.tests.usermodel; import java.io.IOException; import org.apache.poi.ss.ITestDataProvider; +import org.apache.poi.ss.usermodel.BaseTestRow; import org.apache.poi.xssf.streaming.SXSSFRow; import org.apache.poi.xssf.usermodel.XSSFRow; import org.junit.Test; /** - * Class for combined testing of XML-specific functionality of + * Class for combined testing of XML-specific functionality of * {@link XSSFRow} and {@link SXSSFRow}. - * + * * Any test that is applicable for {@link org.apache.poi.hssf.usermodel.HSSFRow} as well should go into * the common base class {@link BaseTestRow}. */ diff --git a/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXSheet.java b/src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/BaseTestXSheet.java index f6e1bffde8..ae68cace8c 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXSheet.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/BaseTestXSheet.java @@ -15,16 +15,17 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.usermodel; +package org.apache.poi.ss.tests.usermodel; import org.apache.poi.ss.ITestDataProvider; +import org.apache.poi.ss.usermodel.BaseTestSheet; import org.apache.poi.xssf.streaming.SXSSFSheet; import org.apache.poi.xssf.usermodel.XSSFSheet; /** - * Class for combined testing of XML-specific functionality of + * Class for combined testing of XML-specific functionality of * {@link XSSFSheet} and {@link SXSSFSheet}. - * + * * Any test that is applicable for {@link org.apache.poi.hssf.usermodel.HSSFSheet} as well should go into * the common base class {@link BaseTestSheet}. */ diff --git a/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXWorkbook.java b/src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/BaseTestXWorkbook.java index 9c7fe3a09a..49ea01f697 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/usermodel/BaseTestXWorkbook.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/BaseTestXWorkbook.java @@ -15,16 +15,17 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.usermodel; +package org.apache.poi.ss.tests.usermodel; import org.apache.poi.ss.ITestDataProvider; +import org.apache.poi.ss.usermodel.BaseTestWorkbook; import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; /** - * Class for combined testing of XML-specific functionality of + * Class for combined testing of XML-specific functionality of * {@link XSSFWorkbook} and {@link SXSSFWorkbook}. - * + * * Any test that is applicable for {@link org.apache.poi.hssf.usermodel.HSSFWorkbook} as well should go into * the common base class {@link BaseTestWorkbook}. */ diff --git a/src/ooxml/testcases/org/apache/poi/ss/usermodel/ConditionalFormattingEvalTest.java b/src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/ConditionalFormattingEvalTest.java index c889eb8471..e4e859bb36 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/usermodel/ConditionalFormattingEvalTest.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/ConditionalFormattingEvalTest.java @@ -15,16 +15,22 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.usermodel; +package org.apache.poi.ss.tests.usermodel; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; + import java.io.IOException; import java.util.Date; import java.util.List; import org.apache.poi.ss.formula.ConditionalFormattingEvaluator; import org.apache.poi.ss.formula.EvaluationConditionalFormatRule; -import org.apache.poi.ss.formula.eval.NotImplementedException; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Color; +import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.util.CellReference; import org.apache.poi.xssf.XSSFTestDataSamples; import org.apache.poi.xssf.usermodel.XSSFColor; @@ -34,8 +40,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.*; - public class ConditionalFormattingEvalTest { private XSSFWorkbook wb; @@ -51,7 +55,7 @@ public class ConditionalFormattingEvalTest { formulaEval = new XSSFFormulaEvaluator(wb); cfe = new ConditionalFormattingEvaluator(wb, formulaEval); } - + @After public void closeWB() { formulaEval = null; @@ -69,21 +73,21 @@ public class ConditionalFormattingEvalTest { @Test public void testFormattingEvaluation() { sheet = wb.getSheet("Products1"); - + getRulesFor(12, 1); assertEquals("wrong # of rules for " + ref, 1, rules.size()); assertEquals("wrong bg color for " + ref, "FFFFEB9C", getColor(rules.get(0).getRule().getPatternFormatting().getFillBackgroundColorColor())); assertFalse("should not be italic " + ref, rules.get(0).getRule().getFontFormatting().isItalic()); - + getRulesFor(16, 3); assertEquals("wrong # of rules for " + ref, 1, rules.size()); assertEquals("wrong bg color for " + ref, 0.7999816888943144d, getTint(rules.get(0).getRule().getPatternFormatting().getFillBackgroundColorColor()), 0.000000000000001); - + getRulesFor(12, 3); assertEquals("wrong # of rules for " + ref, 0, rules.size()); - + sheet = wb.getSheet("Products2"); - + getRulesFor(15,1); assertEquals("wrong # of rules for " + ref, 1, rules.size()); assertEquals("wrong bg color for " + ref, "FFFFEB9C", getColor(rules.get(0).getRule().getPatternFormatting().getFillBackgroundColorColor())); @@ -100,24 +104,24 @@ public class ConditionalFormattingEvalTest { formulaEval.notifyUpdateCell(cell); // need to throw away all evaluations, since we don't know how value changes may have affected format formulas cfe.clearAllCachedValues(); - + // test that the conditional validation evaluations changed getRulesFor(15,1); assertEquals("wrong # of rules for " + ref, 0, rules.size()); - + getRulesFor(20,3); assertEquals("wrong # of rules for " + ref, 1, rules.size()); assertEquals("wrong bg color for " + ref, 0.7999816888943144d, getTint(rules.get(0).getRule().getPatternFormatting().getFillBackgroundColorColor()), 0.000000000000001); - + getRulesFor(20,1); assertEquals("wrong # of rules for " + ref, 1, rules.size()); assertEquals("wrong bg color for " + ref, "FFFFEB9C", getColor(rules.get(0).getRule().getPatternFormatting().getFillBackgroundColorColor())); - + sheet = wb.getSheet("Book tour"); - + getRulesFor(8,2); assertEquals("wrong # of rules for " + ref, 1, rules.size()); - + sheet = wb.getSheet("Compare to totals"); getRulesFor(3, 2); assertEquals("wrong # of rules for " + ref, 1, rules.size()); @@ -129,7 +133,7 @@ public class ConditionalFormattingEvalTest { getRulesFor(16, 1); assertEquals("wrong # of rules for " + ref, 1, rules.size()); assertEquals("wrong fg color for " + ref, "FFFF0000", getColor(rules.get(0).getRule().getFontFormatting().getFontColor())); - + sheet = wb.getSheet("Products3"); sheet.getRow(8).getCell(0).setCellValue(new Date()); getRulesFor(8, 0); @@ -153,7 +157,7 @@ public class ConditionalFormattingEvalTest { assertNotEquals("No rules for " + ref, 0, rules.size()); assertEquals("wrong bg color for " + ref, "FFFFFF00", getColor(rules.get(0).getRule().getPatternFormatting().getFillBackgroundColorColor())); } - + @Test public void testRepeatedEval() throws Exception { wb = XSSFTestDataSamples.openSampleWorkbook("test_conditional_formatting.xlsx"); @@ -164,9 +168,9 @@ public class ConditionalFormattingEvalTest { assertEquals("no rules should apply", 0, getRulesFor(2, 1).size()); assertEquals("no rules should apply", 0, getRulesFor(2, 1).size()); - + } - + @Test public void testCellValueIsWrongType() throws Exception { wb = XSSFTestDataSamples.openSampleWorkbook("conditional_formatting_cell_is.xlsx"); @@ -174,18 +178,18 @@ public class ConditionalFormattingEvalTest { cfe = new ConditionalFormattingEvaluator(wb, formulaEval); sheet = wb.getSheetAt(1); - + assertEquals("wrong # of matching rules", 1, getRulesFor(3, 1).size()); } - + @Test public void testRangeCondition() throws Exception { wb = XSSFTestDataSamples.openSampleWorkbook("conditional_formatting_multiple_ranges.xlsx"); formulaEval = new XSSFFormulaEvaluator(wb); cfe = new ConditionalFormattingEvaluator(wb, formulaEval); - + sheet = wb.getSheetAt(0); - + assertEquals("wrong # of matching rules", 0, getRulesFor(0, 0).size()); assertEquals("wrong # of matching rules", 0, getRulesFor(1, 0).size()); assertEquals("wrong # of matching rules", 0, getRulesFor(2, 0).size()); @@ -201,12 +205,12 @@ public class ConditionalFormattingEvalTest { assertEquals("wrong # of matching rules", 0, getRulesFor(3, 6).size()); assertEquals("wrong # of matching rules", 0, getRulesFor(2, 6).size()); } - + private List<EvaluationConditionalFormatRule> getRulesFor(int row, int col) { ref = new CellReference(sheet.getSheetName(), row, col, false, false); return rules = cfe.getConditionalFormattingForCell(ref); } - + private String getColor(Color color) { final XSSFColor c = XSSFColor.toXSSFColor(color); return c.getARGBHex(); diff --git a/src/ooxml/testcases/org/apache/poi/ss/usermodel/TestEmbedOLEPackage.java b/src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/TestEmbedOLEPackage.java index 0be9f1fb0f..f184b01516 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/usermodel/TestEmbedOLEPackage.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/TestEmbedOLEPackage.java @@ -15,9 +15,9 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.usermodel; +package org.apache.poi.ss.tests.usermodel; -import static org.apache.poi.sl.SLCommonUtils.xslfOnly; +import static org.apache.poi.sl.tests.SLCommonUtils.xslfOnly; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -52,6 +52,12 @@ import org.apache.poi.sl.usermodel.Slide; import org.apache.poi.sl.usermodel.SlideShow; import org.apache.poi.ss.extractor.EmbeddedData; import org.apache.poi.ss.extractor.EmbeddedExtractor; +import org.apache.poi.ss.usermodel.ClientAnchor; +import org.apache.poi.ss.usermodel.Drawing; +import org.apache.poi.ss.usermodel.ObjectData; +import org.apache.poi.ss.usermodel.Shape; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xslf.usermodel.XMLSlideShow; import org.apache.poi.xssf.XSSFTestDataSamples; import org.apache.poi.xssf.usermodel.XSSFObjectData; diff --git a/src/ooxml/testcases/org/apache/poi/ss/usermodel/TestXSSFBorderStyle.java b/src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/TestXSSFBorderStyle.java index 2e9334b1ab..d191c7ab7c 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/usermodel/TestXSSFBorderStyle.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/TestXSSFBorderStyle.java @@ -15,14 +15,15 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.usermodel; +package org.apache.poi.ss.tests.usermodel; +import org.apache.poi.ss.usermodel.BaseTestBorderStyle; import org.apache.poi.xssf.XSSFITestDataProvider; /** * @author Yegor Kozlov */ -public final class TestXSSFBorderStyle extends BaseTestBorderStyle { +public final class TestXSSFBorderStyle extends BaseTestBorderStyle { public TestXSSFBorderStyle() { super(XSSFITestDataProvider.instance); diff --git a/src/ooxml/testcases/org/apache/poi/ss/usermodel/TestXSSFRangeCopier.java b/src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/TestXSSFRangeCopier.java index 35f8911293..858014e6ed 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/usermodel/TestXSSFRangeCopier.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/usermodel/TestXSSFRangeCopier.java @@ -17,10 +17,15 @@ * ==================================================================== */ -package org.apache.poi.ss.usermodel; +package org.apache.poi.ss.tests.usermodel; import static org.junit.Assert.assertEquals; +import java.io.IOException; + +import org.apache.poi.ss.usermodel.BaseTestRangeCopier; +import org.apache.poi.ss.usermodel.CellCopyPolicy; +import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.XSSFITestDataProvider; import org.apache.poi.xssf.XSSFTestDataSamples; import org.apache.poi.xssf.usermodel.XSSFRangeCopier; @@ -30,9 +35,7 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import java.io.IOException; - -public class TestXSSFRangeCopier extends TestRangeCopier { +public class TestXSSFRangeCopier extends BaseTestRangeCopier { public TestXSSFRangeCopier() { super(); workbook = new XSSFWorkbook(); diff --git a/src/ooxml/testcases/org/apache/poi/ss/util/TestSXSSFCellUtil.java b/src/ooxml/testcases/org/apache/poi/ss/tests/util/TestSXSSFCellUtil.java index 70c5fae448..33406376b5 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/util/TestSXSSFCellUtil.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/util/TestSXSSFCellUtil.java @@ -5,9 +5,9 @@ The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,8 +15,9 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.util; +package org.apache.poi.ss.tests.util; +import org.apache.poi.ss.util.BaseTestCellUtil; import org.apache.poi.xssf.SXSSFITestDataProvider; public class TestSXSSFCellUtil extends BaseTestCellUtil { diff --git a/src/ooxml/testcases/org/apache/poi/ss/util/TestXSSFCellUtil.java b/src/ooxml/testcases/org/apache/poi/ss/tests/util/TestXSSFCellUtil.java index c58ebe90d9..50fc0cfde5 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/util/TestXSSFCellUtil.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/util/TestXSSFCellUtil.java @@ -5,9 +5,9 @@ The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - + http://www.apache.org/licenses/LICENSE-2.0 - + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -15,8 +15,9 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.util; +package org.apache.poi.ss.tests.util; +import org.apache.poi.ss.util.BaseTestCellUtil; import org.apache.poi.xssf.XSSFITestDataProvider; public class TestXSSFCellUtil extends BaseTestCellUtil { diff --git a/src/ooxml/testcases/org/apache/poi/ss/util/TestXSSFPropertyTemplate.java b/src/ooxml/testcases/org/apache/poi/ss/tests/util/TestXSSFPropertyTemplate.java index b1055e1631..36d0e5b9bd 100644 --- a/src/ooxml/testcases/org/apache/poi/ss/util/TestXSSFPropertyTemplate.java +++ b/src/ooxml/testcases/org/apache/poi/ss/tests/util/TestXSSFPropertyTemplate.java @@ -15,7 +15,7 @@ limitations under the License. ==================================================================== */ -package org.apache.poi.ss.util; +package org.apache.poi.ss.tests.util; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotSame; @@ -30,11 +30,13 @@ import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.PropertyTemplate; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.junit.Test; public class TestXSSFPropertyTemplate { - + @Test public void applyBorders() throws IOException { CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2); @@ -42,10 +44,10 @@ public class TestXSSFPropertyTemplate { PropertyTemplate pt = new PropertyTemplate(); Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet(); - + pt.drawBorders(a1c3, BorderStyle.THIN, IndexedColors.RED.getIndex(), BorderExtent.ALL); pt.applyBorders(sheet); - + for (Row row: sheet) { for (Cell cell: row) { CellStyle cs = cell.getCellStyle(); @@ -59,10 +61,10 @@ public class TestXSSFPropertyTemplate { assertEquals(IndexedColors.RED.getIndex(), cs.getRightBorderColor()); } } - + pt.drawBorders(b2, BorderStyle.NONE, BorderExtent.ALL); pt.applyBorders(sheet); - + for (Row row: sheet) { for (Cell cell: row) { CellStyle cs = cell.getCellStyle(); @@ -92,10 +94,10 @@ public class TestXSSFPropertyTemplate { } } } - + wb.close(); } - + @Test public void clonePropertyTemplate() throws IOException { CellRangeAddress a1c3 = new CellRangeAddress(0, 2, 0, 2); @@ -109,14 +111,14 @@ public class TestXSSFPropertyTemplate { assertEquals(4, pt2.getNumBorderColors(i, j)); } } - + CellRangeAddress b2 = new CellRangeAddress(1,1,1,1); pt2.drawBorders(b2, BorderStyle.THIN, BorderExtent.ALL); - + Workbook wb = new XSSFWorkbook(); Sheet sheet = wb.createSheet(); pt.applyBorders(sheet); - + for (Row row : sheet) { for (Cell cell : row) { CellStyle cs = cell.getCellStyle(); @@ -130,7 +132,7 @@ public class TestXSSFPropertyTemplate { assertEquals(IndexedColors.RED.getIndex(), cs.getRightBorderColor()); } } - + wb.close(); } }
\ No newline at end of file diff --git a/src/ooxml/testcases/org/apache/poi/util/TestIdentifierManager.java b/src/ooxml/testcases/org/apache/poi/util/tests/TestIdentifierManager.java index 8b7b6dc759..86973654d1 100644 --- a/src/ooxml/testcases/org/apache/poi/util/TestIdentifierManager.java +++ b/src/ooxml/testcases/org/apache/poi/util/tests/TestIdentifierManager.java @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.util; +package org.apache.poi.util.tests; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/src/ooxml/testcases/org/apache/poi/util/TestTempFileThreaded.java b/src/ooxml/testcases/org/apache/poi/util/tests/TestTempFileThreaded.java index 5b6e18ce4d..8c203e69b9 100644 --- a/src/ooxml/testcases/org/apache/poi/util/TestTempFileThreaded.java +++ b/src/ooxml/testcases/org/apache/poi/util/tests/TestTempFileThreaded.java @@ -14,15 +14,11 @@ See the License for the specific language governing permissions and limitations under the License. ==================================================================== */ -package org.apache.poi.util; +package org.apache.poi.util.tests; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.xssf.streaming.SXSSFSheet; -import org.apache.poi.xssf.streaming.SXSSFWorkbook; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import static org.apache.poi.util.DefaultTempFileCreationStrategy.POIFILES; +import static org.apache.poi.util.TempFile.JAVA_IO_TMPDIR; +import static org.junit.Assert.assertEquals; import java.io.File; import java.io.FileOutputStream; @@ -34,9 +30,15 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import static org.apache.poi.util.DefaultTempFileCreationStrategy.POIFILES; -import static org.apache.poi.util.TempFile.JAVA_IO_TMPDIR; -import static org.junit.Assert.assertEquals; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.util.TempFile; +import org.apache.poi.util.TempFileCreationStrategy; +import org.apache.poi.xssf.streaming.SXSSFSheet; +import org.apache.poi.xssf.streaming.SXSSFWorkbook; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; public class TestTempFileThreaded { private static final int NUMBER_OF_THREADS = 10; diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java index cdb3dc4182..7c4ee09445 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFSlide.java @@ -16,7 +16,7 @@ ==================================================================== */ package org.apache.poi.xslf.usermodel; -import static org.apache.poi.sl.TestCommonSL.getColor; +import static org.apache.poi.sl.usermodel.BaseTestSlideShow.getColor; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java index a5b2dc8e1b..1a1396bdfe 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextParagraph.java @@ -16,7 +16,7 @@ ==================================================================== */ package org.apache.poi.xslf.usermodel; -import static org.apache.poi.sl.TestCommonSL.getColor; +import static org.apache.poi.sl.usermodel.BaseTestSlideShow.getColor; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java index 8d26fc62e5..dfa1d572ab 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextRun.java @@ -18,7 +18,7 @@ */ package org.apache.poi.xslf.usermodel; -import static org.apache.poi.sl.TestCommonSL.getColor; +import static org.apache.poi.sl.usermodel.BaseTestSlideShow.getColor; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; @@ -29,7 +29,6 @@ import java.io.IOException; import java.io.InputStream; import org.apache.poi.POIDataSamples; -import org.apache.poi.ooxml.POIXMLDocumentPart; import org.apache.poi.sl.draw.DrawTextParagraph; import org.junit.Test; import org.openxmlformats.schemas.drawingml.x2006.main.CTTextLineBreak; diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java index 474bd52c93..e01db97bf1 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTextShape.java @@ -16,7 +16,7 @@ ==================================================================== */ package org.apache.poi.xslf.usermodel; -import static org.apache.poi.sl.TestCommonSL.getColor; +import static org.apache.poi.sl.usermodel.BaseTestSlideShow.getColor; import static org.apache.poi.xslf.usermodel.TestXSLFSimpleShape.getSpPr; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java index 4a90fbc769..12ddf0eabd 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFTheme.java @@ -16,7 +16,7 @@ ==================================================================== */ package org.apache.poi.xslf.usermodel; -import static org.apache.poi.sl.TestCommonSL.getColor; +import static org.apache.poi.sl.usermodel.BaseTestSlideShow.getColor; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; diff --git a/src/ooxml/testcases/org/apache/poi/xssf/AllXSSFTests.java b/src/ooxml/testcases/org/apache/poi/xssf/AllXSSFTests.java index 93f35aac49..e6a61f0afa 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/AllXSSFTests.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/AllXSSFTests.java @@ -17,7 +17,7 @@ package org.apache.poi.xssf; -import org.apache.poi.ss.format.TestCellFormatPart; +import org.apache.poi.ss.tests.format.TestCellFormatPart; import org.apache.poi.xssf.extractor.TestXSSFExcelExtractor; import org.apache.poi.xssf.io.TestLoadSaveXSSF; import org.apache.poi.xssf.model.TestCommentsTable; @@ -42,7 +42,7 @@ import org.junit.runners.Suite; //TestStylesTable.class, //converted to junit4 //TestCellReference.class, //converted to junit4 TestCTColComparator.class, - TestNumericRanges.class, + TestNumericRanges.class, TestCellFormatPart.class, TestXSSFCloneSheet.class }) diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestDeferredSXSSFWorkbook.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestDeferredSXSSFWorkbook.java index 4e72ff69b5..879a2d4ed6 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestDeferredSXSSFWorkbook.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestDeferredSXSSFWorkbook.java @@ -19,7 +19,16 @@ package org.apache.poi.xssf.streaming; -import org.apache.poi.ss.usermodel.BaseTestXWorkbook; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.IOException; + +import org.apache.poi.ss.tests.usermodel.BaseTestXWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; @@ -33,21 +42,17 @@ import org.junit.After; import org.junit.Ignore; import org.junit.Test; -import java.io.IOException; - -import static org.junit.Assert.*; - public final class TestDeferredSXSSFWorkbook extends BaseTestXWorkbook { - + public TestDeferredSXSSFWorkbook() { super(DeferredSXSSFITestDataProvider.instance); } - + @After public void tearDown() { ((DeferredSXSSFITestDataProvider) _testDataProvider).cleanup(); } - + /** * cloning of sheets is not supported in SXSSF */ @@ -61,7 +66,7 @@ public final class TestDeferredSXSSFWorkbook extends BaseTestXWorkbook { assertEquals("Not Implemented", e.getMessage()); } } - + /** * cloning of sheets is not supported in SXSSF */ @@ -75,7 +80,7 @@ public final class TestDeferredSXSSFWorkbook extends BaseTestXWorkbook { assertEquals("Not Implemented", e.getMessage()); } } - + /** * Skip this test, as SXSSF doesn't update formulas on sheet name changes. */ @@ -101,7 +106,7 @@ public final class TestDeferredSXSSFWorkbook extends BaseTestXWorkbook { DeferredSXSSFWorkbook wb1 = new DeferredSXSSFWorkbook(xssfWb1); XSSFWorkbook xssfWb2 = DeferredSXSSFITestDataProvider.instance.writeOutAndReadBack(wb1); assertTrue(wb1.dispose()); - + DeferredSXSSFWorkbook wb2 = new DeferredSXSSFWorkbook(xssfWb2); assertEquals(1, wb2.getNumberOfSheets()); Sheet sheet = wb2.getStreamingSheetAt(0); @@ -110,7 +115,7 @@ public final class TestDeferredSXSSFWorkbook extends BaseTestXWorkbook { assertTrue(wb2.dispose()); xssfWb2.close(); xssfWb1.close(); - + wb2.close(); wb1.close(); } @@ -127,7 +132,7 @@ public final class TestDeferredSXSSFWorkbook extends BaseTestXWorkbook { XSSFWorkbook xssfWb2 = DeferredSXSSFITestDataProvider.instance.writeOutAndReadBack(wb1); assertTrue(wb1.dispose()); xssfWb1.close(); - + DeferredSXSSFWorkbook wb2 = new DeferredSXSSFWorkbook(xssfWb2); // Add a row to the existing empty sheet DeferredSXSSFSheet ssheet1 = wb2.getStreamingSheetAt(0); @@ -136,7 +141,7 @@ public final class TestDeferredSXSSFWorkbook extends BaseTestXWorkbook { Cell cell1_1_1 = row1_1.createCell(1); cell1_1_1.setCellValue("value 1_1_1"); }); - + // Add a row to the existing non-empty sheet DeferredSXSSFSheet ssheet2 = wb2.getStreamingSheetAt(1); ssheet2.setRowGenerator((ssxSheet) -> { @@ -151,10 +156,10 @@ public final class TestDeferredSXSSFWorkbook extends BaseTestXWorkbook { Cell cell3_1_1 = row3_1.createCell(1); cell3_1_1.setCellValue("value 3_1_1"); }); - + XSSFWorkbook xssfWb3 = DeferredSXSSFITestDataProvider.instance.writeOutAndReadBack(wb2); wb2.close(); - + assertEquals(3, xssfWb3.getNumberOfSheets()); // Verify sheet 1 XSSFSheet sheet1 = xssfWb3.getSheetAt(0); @@ -188,12 +193,12 @@ public final class TestDeferredSXSSFWorkbook extends BaseTestXWorkbook { XSSFCell cell3_1_1 = row3_1.getCell(1); assertNotNull(cell3_1_1); assertEquals("value 3_1_1", cell3_1_1.getStringCellValue()); - + xssfWb2.close(); xssfWb3.close(); wb1.close(); } - + @Test public void sheetdataWriter() throws IOException { DeferredSXSSFWorkbook wb = new DeferredSXSSFWorkbook(); @@ -228,7 +233,7 @@ public final class TestDeferredSXSSFWorkbook extends BaseTestXWorkbook { } } } - + @Test public void gzipSheetdataWriter() throws IOException { DeferredSXSSFWorkbook wb = new DeferredSXSSFWorkbook(); @@ -236,7 +241,7 @@ public final class TestDeferredSXSSFWorkbook extends BaseTestXWorkbook { final int rowNum = 1000; final int sheetNum = 5; populateData(wb, 1000, 5); - + XSSFWorkbook xwb = DeferredSXSSFITestDataProvider.instance.writeOutAndReadBack(wb); for (int i = 0; i < sheetNum; i++) { Sheet sh = xwb.getSheetAt(i); @@ -246,15 +251,15 @@ public final class TestDeferredSXSSFWorkbook extends BaseTestXWorkbook { assertNotNull("row[" + j + "]", row); Cell cell1 = row.getCell(0); assertEquals(new CellReference(cell1).formatAsString(), cell1.getStringCellValue()); - + Cell cell2 = row.getCell(1); assertEquals(i, (int) cell2.getNumericCellValue()); - + Cell cell3 = row.getCell(2); assertEquals(j, (int) cell3.getNumericCellValue()); } } - + assertTrue(wb.dispose()); xwb.close(); wb.close(); @@ -273,23 +278,23 @@ public final class TestDeferredSXSSFWorkbook extends BaseTestXWorkbook { assertWorkbookDispose(wb2); wb2.close(); } - + private static void assertWorkbookDispose(DeferredSXSSFWorkbook wb) { populateData(wb, 1000, 5); - + for (Sheet sheet : wb) { DeferredSXSSFSheet sxSheet = (DeferredSXSSFSheet) sheet; assertNull(sxSheet.getSheetDataWriter()); } - + assertTrue(wb.dispose()); - + for (Sheet sheet : wb) { DeferredSXSSFSheet sxSheet = (DeferredSXSSFSheet) sheet; assertNull(sxSheet.getSheetDataWriter()); } } - + private static void populateData(DeferredSXSSFWorkbook wb, final int rowNum, final int sheetNum) { for (int i = 0; i < sheetNum; i++) { DeferredSXSSFSheet sheet = wb.createSheet("sheet" + i); @@ -299,10 +304,10 @@ public final class TestDeferredSXSSFWorkbook extends BaseTestXWorkbook { Row row = sh.createRow(j); Cell cell1 = row.createCell(0); cell1.setCellValue(new CellReference(cell1).formatAsString()); - + Cell cell2 = row.createCell(1); cell2.setCellValue(index); - + Cell cell3 = row.createCell(2); cell3.setCellValue(j); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFCell.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFCell.java index f0519d2035..182eb17775 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFCell.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFCell.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.mockito.Mockito.spy; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -30,7 +31,7 @@ import java.nio.charset.StandardCharsets; import javax.xml.namespace.QName; import org.apache.poi.ss.SpreadsheetVersion; -import org.apache.poi.ss.usermodel.BaseTestXCell; +import org.apache.poi.ss.tests.usermodel.BaseTestXCell; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.RichTextString; @@ -46,9 +47,6 @@ import org.junit.Ignore; import org.junit.Test; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRst; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; - /** * Tests various functionality having to do with {@link SXSSFCell}. For instance support for * particular datatypes, etc. diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFRow.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFRow.java index ee237cc9b0..88c12d7e01 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFRow.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFRow.java @@ -19,7 +19,7 @@ package org.apache.poi.xssf.streaming; -import org.apache.poi.ss.usermodel.BaseTestXRow; +import org.apache.poi.ss.tests.usermodel.BaseTestXRow; import org.apache.poi.xssf.SXSSFITestDataProvider; import org.junit.After; import org.junit.Ignore; @@ -48,8 +48,8 @@ public final class TestSXSSFRow extends BaseTestXRow { @Override @Ignore ("see <https://bz.apache.org/bugzilla/show_bug.cgi?id=62030#c1>") @Test public void testCellShiftingLeft(){ - // Remove when SXSSFRow.shiftCellsLeft() is implemented. + // Remove when SXSSFRow.shiftCellsLeft() is implemented. } - + } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java index 4bc9bd5191..15dcf326a0 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFSheet.java @@ -24,7 +24,7 @@ import static org.junit.Assert.fail; import java.io.IOException; -import org.apache.poi.ss.usermodel.BaseTestXSheet; +import org.apache.poi.ss.tests.usermodel.BaseTestXSheet; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.SXSSFITestDataProvider; @@ -44,7 +44,7 @@ public final class TestSXSSFSheet extends BaseTestXSheet { public void tearDown(){ SXSSFITestDataProvider.instance.cleanup(); } - + @Override protected void trackColumnsForAutoSizingIfSXSSF(Sheet sheet) { SXSSFSheet sxSheet = (SXSSFSheet) sheet; @@ -70,7 +70,7 @@ public final class TestSXSSFSheet extends BaseTestXSheet { thrown.expectMessage("Not Implemented"); super.cloneSheetMultipleTimes(); } - + /** * shifting rows is not supported in SXSSF */ @@ -98,11 +98,11 @@ public final class TestSXSSFSheet extends BaseTestXSheet { @Override @Test public void getCellComment() throws IOException { - // TODO: reading cell comments via Sheet does not work currently as it tries + // TODO: reading cell comments via Sheet does not work currently as it tries // to access the underlying sheet for this, but comments are stored as // properties on Cells... } - + @Override @Test public void defaultColumnStyle() { @@ -133,7 +133,7 @@ public final class TestSXSSFSheet extends BaseTestXSheet { Workbook wb = new SXSSFWorkbook(template); try { Sheet sheet = wb.getSheetAt(0); - + try { sheet.createRow(1); fail("expected exception"); @@ -160,13 +160,13 @@ public final class TestSXSSFSheet extends BaseTestXSheet { SXSSFRow row0 = sheet.createRow(0); SXSSFRow row1 = sheet.createRow(1); sheet.changeRowNum(row0, 2); - + assertEquals("Row 1 knows its row number", 1, row1.getRowNum()); assertEquals("Row 2 knows its row number", 2, row0.getRowNum()); assertEquals("Sheet knows Row 1's row number", 1, sheet.getRowNum(row1)); assertEquals("Sheet knows Row 2's row number", 2, sheet.getRowNum(row0)); assertEquals("Sheet row iteratation order should be ascending", row1, sheet.iterator().next()); - + wb.close(); } } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java index aa0045f809..9e592df284 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbook.java @@ -19,8 +19,8 @@ package org.apache.poi.xssf.streaming; -import static org.apache.poi.POITestCase.assertStartsWith; import static org.apache.poi.POITestCase.assertEndsWith; +import static org.apache.poi.POITestCase.assertStartsWith; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -37,10 +37,9 @@ import java.io.IOException; import java.util.Arrays; import org.apache.poi.POIDataSamples; -import org.apache.poi.POITestCase; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackageAccess; -import org.apache.poi.ss.usermodel.BaseTestXWorkbook; +import org.apache.poi.ss.tests.usermodel.BaseTestXWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; @@ -122,7 +121,7 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook { assertTrue(wb2.dispose()); xssfWb2.close(); xssfWb1.close(); - + wb2.close(); wb1.close(); } @@ -131,8 +130,8 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook { public void useSharedStringsTable() throws Exception { SXSSFWorkbook wb = new SXSSFWorkbook(null, 10, false, true); - SharedStringsTable sss = POITestCase.getFieldValue(SXSSFWorkbook.class, wb, SharedStringsTable.class, "_sharedStringSource"); - + SharedStringsTable sss = wb.getSharedStringSource(); + assertNotNull(sss); Row row = wb.createSheet("S1").createRow(0); @@ -142,7 +141,7 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook { row.createCell(2).setCellValue("A"); XSSFWorkbook xssfWorkbook = SXSSFITestDataProvider.instance.writeOutAndReadBack(wb); - sss = POITestCase.getFieldValue(SXSSFWorkbook.class, wb, SharedStringsTable.class, "_sharedStringSource"); + sss = wb.getSharedStringSource(); assertEquals(2, sss.getUniqueCount()); assertTrue(wb.dispose()); @@ -199,7 +198,7 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook { XSSFWorkbook xssfWb3 = SXSSFITestDataProvider.instance.writeOutAndReadBack(wb2); wb2.close(); - + assertEquals(3, xssfWb3.getNumberOfSheets()); // Verify sheet 1 sheet1 = xssfWb3.getSheetAt(0); @@ -233,7 +232,7 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook { cell3_1_1 = row3_1.getCell(1); assertNotNull(cell3_1_1); assertEquals("value 3_1_1", cell3_1_1.getStringCellValue()); - + xssfWb2.close(); xssfWb3.close(); wb1.close(); @@ -437,15 +436,15 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook { // Some tests commented out because close() modifies the file // See bug 58779 - + // String //wb = new SXSSFWorkbook(new XSSFWorkbook(file.getPath())); //assertCloseDoesNotModifyFile(filename, wb); - + // File //wb = new SXSSFWorkbook(new XSSFWorkbook(file)); //assertCloseDoesNotModifyFile(filename, wb); - + // InputStream try (FileInputStream fis = new FileInputStream(file); @@ -453,15 +452,15 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook { SXSSFWorkbook wb = new SXSSFWorkbook(xwb)) { assertCloseDoesNotModifyFile(filename, wb); } - + // OPCPackage //wb = new SXSSFWorkbook(new XSSFWorkbook(OPCPackage.open(file))); //assertCloseDoesNotModifyFile(filename, wb); } - + /** * Bug #59743 - * + * * this is only triggered on other files apart of sheet[1,2,...].xml * as those are either copied uncompressed or with the use of GZIPInputStream * so we use shared strings @@ -472,7 +471,7 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook { SXSSFSheet s = swb.createSheet(); char[] useless = new char[32767]; Arrays.fill(useless, ' '); - + for (int row=0; row<1; row++) { Row r = s.createRow(row); for (int col=0; col<10; col++) { @@ -483,13 +482,13 @@ public final class TestSXSSFWorkbook extends BaseTestXWorkbook { r.createCell(col, CellType.STRING).setCellValue(ul); } } - + ByteArrayOutputStream bos = new ByteArrayOutputStream(); swb.write(bos); swb.dispose(); swb.close(); } - + /** * To avoid accident changes to the template, you should be able * to create a SXSSFWorkbook from a read-only XSSF one, then diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java index 4ccb70e9d1..d88d1fd959 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/AllXSSFUsermodelTests.java @@ -17,7 +17,7 @@ package org.apache.poi.xssf.usermodel; -import org.apache.poi.ss.formula.eval.forked.TestForkedEvaluator; +import org.apache.poi.ss.formula.eval.forked.BaseTestForkedEvaluator; import org.apache.poi.xssf.usermodel.extensions.TestXSSFBorder; import org.apache.poi.xssf.usermodel.extensions.TestXSSFCellFill; import org.apache.poi.xssf.usermodel.helpers.TestColumnHelper; @@ -58,7 +58,7 @@ import org.junit.runners.Suite; TestColumnHelper.class, TestHeaderFooterHelper.class, //TestXSSFPivotTable.class, //converted to junit4 - TestForkedEvaluator.class + BaseTestForkedEvaluator.class }) public final class AllXSSFUsermodelTests { } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java index 97744249aa..e1ffbd6337 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java @@ -33,7 +33,7 @@ import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackageAccess; import org.apache.poi.ss.formula.eval.TestFormulasFromSpreadsheet; -import org.apache.poi.ss.formula.functions.TestMathX; +import org.apache.poi.ss.formula.functions.BaseTestNumeric; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CellValue; @@ -55,10 +55,10 @@ import org.junit.runners.Parameterized.Parameters; * except for a XSSF spreadsheet, not a HSSF one. * This allows us to check that all our Formula Evaluation code * is able to work for XSSF, as well as for HSSF. - * + * * Periodically, you should open FormulaEvalTestData.xls in * Excel 2007, and re-save it as FormulaEvalTestData_Copy.xlsx - * + * */ @RunWith(Parameterized.class) public final class TestFormulaEvaluatorOnXSSF { @@ -68,12 +68,12 @@ public final class TestFormulaEvaluatorOnXSSF { private static Sheet sheet; private static FormulaEvaluator evaluator; private static Locale userLocale; - - /** + + /** * This class defines constants for navigating around the test data spreadsheet used for these tests. */ private static interface SS { - + /** * Name of the test spreadsheet (found in the standard test data folder) */ @@ -119,7 +119,7 @@ public final class TestFormulaEvaluatorOnXSSF { LocaleUtil.setUserLocale(userLocale); workbook.close(); } - + @Parameters(name="{0}") public static Collection<Object[]> data() throws Exception { // Function "Text" uses custom-formats which are locale specific @@ -131,9 +131,9 @@ public final class TestFormulaEvaluatorOnXSSF { workbook = new XSSFWorkbook( OPCPackage.open(HSSFTestDataSamples.getSampleFile(SS.FILENAME), PackageAccess.READ) ); sheet = workbook.getSheetAt( 0 ); evaluator = new XSSFFormulaEvaluator(workbook); - + List<Object[]> data = new ArrayList<>(); - + processFunctionGroup(data, SS.START_OPERATORS_ROW_INDEX, null); processFunctionGroup(data, SS.START_FUNCTIONS_ROW_INDEX, null); // example for debugging individual functions/operators: @@ -142,10 +142,10 @@ public final class TestFormulaEvaluatorOnXSSF { return data; } - + /** - * @param startRowIndex row index in the spreadsheet where the first function/operator is found - * @param testFocusFunctionName name of a single function/operator to test alone. + * @param startRowIndex row index in the spreadsheet where the first function/operator is found + * @param testFocusFunctionName name of a single function/operator to test alone. * Typically pass <code>null</code> to test all functions */ private static void processFunctionGroup(List<Object[]> data, int startRowIndex, String testFocusFunctionName) { @@ -154,7 +154,7 @@ public final class TestFormulaEvaluatorOnXSSF { // only evaluate non empty row if(r == null) continue; - + String targetFunctionName = getTargetFunctionName(r); assertNotNull("Test spreadsheet cell empty on row (" + (rowIndex+1) + "). Expected function name or '" @@ -165,14 +165,14 @@ public final class TestFormulaEvaluatorOnXSSF { break; } if(testFocusFunctionName == null || targetFunctionName.equalsIgnoreCase(testFocusFunctionName)) { - + // expected results are on the row below Row expectedValuesRow = sheet.getRow(rowIndex + 1); // +1 for 1-based, +1 for next row - assertNotNull("Missing expected values row for function '" + assertNotNull("Missing expected values row for function '" + targetFunctionName + " (row " + rowIndex + 2 + ")" , expectedValuesRow); - + data.add(new Object[]{targetFunctionName, rowIndex, rowIndex + 1}); } } @@ -183,7 +183,7 @@ public final class TestFormulaEvaluatorOnXSSF { public void processFunctionRow() { Row formulasRow = sheet.getRow(formulasRowIdx); Row expectedValuesRow = sheet.getRow(expectedValuesRowIdx); - + short endcolnum = formulasRow.getLastCellNum(); // iterate across the row for all the evaluation cases @@ -198,10 +198,10 @@ public final class TestFormulaEvaluatorOnXSSF { String msg = String.format(Locale.ROOT, "Function '%s': Formula: %s @ %d:%d" , targetFunctionName, c.getCellFormula(), formulasRow.getRowNum(), colnum); - + assertNotNull(msg + " - Bad setup data expected value is null", expValue); assertNotNull(msg + " - actual value was null", actValue); - + final CellType expectedCellType = expValue.getCellType(); switch (expectedCellType) { case BLANK: @@ -221,7 +221,7 @@ public final class TestFormulaEvaluatorOnXSSF { fail("Cannot expect formula as result of formula evaluation: " + msg); case NUMERIC: assertEquals(msg, CellType.NUMERIC, actValue.getCellType()); - TestMathX.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR); + BaseTestNumeric.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), BaseTestNumeric.POS_ZERO, BaseTestNumeric.DIFF_TOLERANCE_FACTOR); // double delta = Math.abs(expValue.getNumericCellValue()-actValue.getNumberValue()); // double pctExpValue = Math.abs(0.00001*expValue.getNumericCellValue()); // assertTrue(msg, delta <= pctExpValue); @@ -237,16 +237,16 @@ public final class TestFormulaEvaluatorOnXSSF { } /* - * TODO - these are all formulas which currently (Apr-2008) break on ooxml + * TODO - these are all formulas which currently (Apr-2008) break on ooxml */ private static void ignoredFormulaTestCase(String cellFormula) { // full row ranges are not parsed properly yet. - // These cases currently work in svn trunk because of another bug which causes the - // formula to get rendered as COLUMN($A$1:$IV$2) or ROW($A$2:$IV$3) + // These cases currently work in svn trunk because of another bug which causes the + // formula to get rendered as COLUMN($A$1:$IV$2) or ROW($A$2:$IV$3) assumeFalse("COLUMN(1:2)".equals(cellFormula)); assumeFalse("ROW(2:3)".equals(cellFormula)); - // currently throws NPE because unknown function "currentcell" causes name lookup + // currently throws NPE because unknown function "currentcell" causes name lookup // Name lookup requires some equivalent object of the Workbook within xSSFWorkbook. assumeFalse("ISREF(currentcell())".equals(cellFormula)); } @@ -270,7 +270,7 @@ public final class TestFormulaEvaluatorOnXSSF { if(cell.getCellType() == CellType.STRING) { return cell.getRichStringCellValue().getString(); } - + fail("Bad cell type for 'function name' column: ("+cell.getColumnIndex()+") row ("+(r.getRowNum()+1)+")"); return null; } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMatrixFormulasFromXMLSpreadsheet.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMatrixFormulasFromXMLSpreadsheet.java index a5b7dcbc2f..487ce8560a 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMatrixFormulasFromXMLSpreadsheet.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMatrixFormulasFromXMLSpreadsheet.java @@ -27,7 +27,7 @@ import java.util.List; import java.util.Locale; import org.apache.poi.ss.formula.eval.ErrorEval; -import org.apache.poi.ss.formula.functions.TestMathX; +import org.apache.poi.ss.formula.functions.BaseTestNumeric; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CellValue; @@ -196,7 +196,7 @@ public final class TestMatrixFormulasFromXMLSpreadsheet { fail("Cannot expect formula as result of formula evaluation: " + msg); case NUMERIC: assertEquals(msg, CellType.NUMERIC, actValue.getCellType()); - TestMathX.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR); + BaseTestNumeric.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), BaseTestNumeric.POS_ZERO, BaseTestNumeric.DIFF_TOLERANCE_FACTOR); break; case STRING: assertEquals(msg, CellType.STRING, actValue.getCellType()); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMissingWorkbookOnXSSF.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMissingWorkbookOnXSSF.java index 0de5eb5a46..f8ba0ff7db 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMissingWorkbookOnXSSF.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMissingWorkbookOnXSSF.java @@ -17,17 +17,17 @@ package org.apache.poi.xssf.usermodel; +import static org.junit.Assert.assertNotNull; + import org.apache.poi.hssf.HSSFTestDataSamples; -import org.apache.poi.ss.formula.TestMissingWorkbook; +import org.apache.poi.ss.formula.BaseTestMissingWorkbook; import org.apache.poi.xssf.XSSFTestDataSamples; import org.junit.Before; -import static org.junit.Assert.assertNotNull; - /** * XSSF Specific version of the Missing Workbooks test */ -public final class TestMissingWorkbookOnXSSF extends TestMissingWorkbook { +public final class TestMissingWorkbookOnXSSF extends BaseTestMissingWorkbook { public TestMissingWorkbookOnXSSF() { super("52575_main.xlsx", "source_dummy.xlsx", "52575_source.xls"); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java index 74648bb7e6..09817ecd45 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java @@ -31,8 +31,7 @@ import java.util.Locale; import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.openxml4j.opc.OPCPackage; import org.apache.poi.openxml4j.opc.PackageAccess; -import org.apache.poi.ss.formula.eval.TestFormulasFromSpreadsheet; -import org.apache.poi.ss.formula.functions.TestMathX; +import org.apache.poi.ss.formula.functions.BaseTestNumeric; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CellValue; @@ -53,7 +52,7 @@ import org.junit.runners.Parameterized.Parameters; */ @RunWith(Parameterized.class) public final class TestMultiSheetFormulaEvaluatorOnXSSF { - private static final POILogger logger = POILogFactory.getLogger(TestFormulasFromSpreadsheet.class); + private static final POILogger logger = POILogFactory.getLogger(TestMultiSheetFormulaEvaluatorOnXSSF.class); private static XSSFWorkbook workbook; private static Sheet sheet; @@ -204,7 +203,7 @@ public final class TestMultiSheetFormulaEvaluatorOnXSSF { fail("Cannot expect formula as result of formula evaluation: " + msg); case NUMERIC: assertEquals(msg, CellType.NUMERIC, actValue.getCellType()); - TestMathX.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR); + BaseTestNumeric.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), BaseTestNumeric.POS_ZERO, BaseTestNumeric.DIFF_TOLERANCE_FACTOR); // double delta = Math.abs(expected.getNumericCellValue()-actual.getNumberValue()); // double pctExpected = Math.abs(0.00001*expected.getNumericCellValue()); // assertTrue(msg, delta <= pctExpected); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index 873d7a0699..b456d91aa6 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -1994,7 +1994,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { // Workbook Factory gives helpful error on package try { - XSSFWorkbookFactory.create(pkg).close(); + XSSFWorkbookFactory.createWorkbook(pkg).close(); fail(".xlsb files not supported"); } catch (XLSBUnsupportedException e) { // Good, detected and warned diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java index 4dae58a238..c5c0427f17 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java @@ -17,6 +17,15 @@ package org.apache.poi.xssf.usermodel; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.IOException; import java.util.List; @@ -24,7 +33,7 @@ import org.apache.poi.common.usermodel.HyperlinkType; import org.apache.poi.hssf.HSSFITestDataProvider; import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.formula.FormulaParseException; -import org.apache.poi.ss.usermodel.BaseTestXCell; +import org.apache.poi.ss.tests.usermodel.BaseTestXCell; import org.apache.poi.ss.usermodel.BorderStyle; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellCopyPolicy; @@ -53,8 +62,6 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula; import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellFormulaType; import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType; -import static org.junit.Assert.*; - public final class TestXSSFCell extends BaseTestXCell { public TestXSSFCell() { diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFForkedEvaluator.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFForkedEvaluator.java index 4da863fafb..ca9ba631f9 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFForkedEvaluator.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFForkedEvaluator.java @@ -17,11 +17,11 @@ package org.apache.poi.xssf.usermodel; -import org.apache.poi.ss.formula.eval.forked.TestForkedEvaluator; +import org.apache.poi.ss.formula.eval.forked.BaseTestForkedEvaluator; import org.apache.poi.ss.usermodel.Workbook; -public class TestXSSFForkedEvaluator extends TestForkedEvaluator { - +public class TestXSSFForkedEvaluator extends BaseTestForkedEvaluator { + @Override protected Workbook newWorkbook() { return new XSSFWorkbook(); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java index 6985625701..669544fd41 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java @@ -23,7 +23,7 @@ import static org.junit.Assert.assertSame; import java.io.IOException; -import org.apache.poi.ss.usermodel.BaseTestXRow; +import org.apache.poi.ss.tests.usermodel.BaseTestXRow; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellCopyPolicy; import org.apache.poi.ss.usermodel.CellType; @@ -42,7 +42,7 @@ public final class TestXSSFRow extends BaseTestXRow { public TestXSSFRow() { super(XSSFITestDataProvider.instance); } - + @Test public void testCopyRowFrom() throws IOException { final XSSFWorkbook workbook = new XSSFWorkbook(); @@ -50,21 +50,21 @@ public final class TestXSSFRow extends BaseTestXRow { final XSSFRow srcRow = sheet.createRow(0); srcRow.createCell(0).setCellValue("Hello"); final XSSFRow destRow = sheet.createRow(1); - + destRow.copyRowFrom(srcRow, new CellCopyPolicy()); assertNotNull(destRow.getCell(0)); assertEquals("Hello", destRow.getCell(0).getStringCellValue()); - + workbook.close(); } - + @Test public void testCopyRowFromExternalSheet() throws IOException { final XSSFWorkbook workbook = new XSSFWorkbook(); final Sheet srcSheet = workbook.createSheet("src"); final XSSFSheet destSheet = workbook.createSheet("dest"); workbook.createSheet("other"); - + final Row srcRow = srcSheet.createRow(0); int col = 0; //Test 2D and 3D Ref Ptgs (Pxg for OOXML Workbooks) @@ -72,13 +72,13 @@ public final class TestXSSFRow extends BaseTestXRow { srcRow.createCell(col++).setCellFormula("src!B5"); srcRow.createCell(col++).setCellFormula("dest!B5"); srcRow.createCell(col++).setCellFormula("other!B5"); - + //Test 2D and 3D Ref Ptgs with absolute row srcRow.createCell(col++).setCellFormula("B$5"); srcRow.createCell(col++).setCellFormula("src!B$5"); srcRow.createCell(col++).setCellFormula("dest!B$5"); srcRow.createCell(col++).setCellFormula("other!B$5"); - + //Test 2D and 3D Area Ptgs (Pxg for OOXML Workbooks) srcRow.createCell(col++).setCellFormula("SUM(B5:D$5)"); srcRow.createCell(col++).setCellFormula("SUM(src!B5:D$5)"); @@ -89,81 +89,81 @@ public final class TestXSSFRow extends BaseTestXRow { final XSSFRow destRow = destSheet.createRow(1); destRow.copyRowFrom(srcRow, new CellCopyPolicy()); - + ////////////////// - + //Test 2D and 3D Ref Ptgs (Pxg for OOXML Workbooks) col = 0; Cell cell = destRow.getCell(col++); assertNotNull(cell); assertEquals("RefPtg", "B6", cell.getCellFormula()); - + cell = destRow.getCell(col++); assertNotNull(cell); assertEquals("Ref3DPtg", "src!B6", cell.getCellFormula()); - + cell = destRow.getCell(col++); assertNotNull(cell); assertEquals("Ref3DPtg", "dest!B6", cell.getCellFormula()); - + cell = destRow.getCell(col++); assertNotNull(cell); assertEquals("Ref3DPtg", "other!B6", cell.getCellFormula()); - + ///////////////////////////////////////////// - + //Test 2D and 3D Ref Ptgs with absolute row (Ptg row number shouldn't change) cell = destRow.getCell(col++); assertNotNull(cell); assertEquals("RefPtg", "B$5", cell.getCellFormula()); - + cell = destRow.getCell(col++); assertNotNull(cell); assertEquals("Ref3DPtg", "src!B$5", cell.getCellFormula()); - + cell = destRow.getCell(col++); assertNotNull(cell); assertEquals("Ref3DPtg", "dest!B$5", cell.getCellFormula()); - + cell = destRow.getCell(col++); assertNotNull(cell); assertEquals("Ref3DPtg", "other!B$5", cell.getCellFormula()); - + ////////////////////////////////////////// - + //Test 2D and 3D Area Ptgs (Pxg for OOXML Workbooks) // Note: absolute row changes from last cell to first cell in order // to maintain topLeft:bottomRight order cell = destRow.getCell(col++); assertNotNull(cell); assertEquals("Area2DPtg", "SUM(B$5:D6)", cell.getCellFormula()); - + cell = destRow.getCell(col++); assertNotNull(cell); assertEquals("Area3DPtg", "SUM(src!B$5:D6)", cell.getCellFormula()); - + cell = destRow.getCell(col++); assertNotNull(destRow.getCell(6)); assertEquals("Area3DPtg", "SUM(dest!B$5:D6)", cell.getCellFormula()); - + cell = destRow.getCell(col++); assertNotNull(destRow.getCell(7)); assertEquals("Area3DPtg", "SUM(other!B$5:D6)", cell.getCellFormula()); - + workbook.close(); } - + @Test public void testCopyRowOverwritesExistingRow() throws IOException { final XSSFWorkbook workbook = new XSSFWorkbook(); final XSSFSheet sheet1 = workbook.createSheet("Sheet1"); final Sheet sheet2 = workbook.createSheet("Sheet2"); - + final Row srcRow = sheet1.createRow(0); final XSSFRow destRow = sheet1.createRow(1); final Row observerRow = sheet1.createRow(2); final Row externObserverRow = sheet2.createRow(0); - + srcRow.createCell(0).setCellValue("hello"); srcRow.createCell(1).setCellValue("world"); destRow.createCell(0).setCellValue(5.0); //A2 -> 5.0 @@ -171,10 +171,10 @@ public final class TestXSSFRow extends BaseTestXRow { observerRow.createCell(0).setCellFormula("A2"); // A3 -> A2 -> 5.0 observerRow.createCell(1).setCellFormula("B2"); // B3 -> B2 -> A1 -> "hello" externObserverRow.createCell(0).setCellFormula("Sheet1!A2"); //Sheet2!A1 -> Sheet1!A2 -> 5.0 - + // overwrite existing destRow with row-copy of srcRow destRow.copyRowFrom(srcRow, new CellCopyPolicy()); - + // copyRowFrom should update existing destRow, rather than creating a new row and reassigning the destRow pointer // to the new row (and allow the old row to be garbage collected) // this is mostly so existing references to rows that are overwritten are updated @@ -183,16 +183,16 @@ public final class TestXSSFRow extends BaseTestXRow { assertSame("existing references to destRow are still valid", destRow, sheet1.getRow(1)); assertSame("existing references to observerRow are still valid", observerRow, sheet1.getRow(2)); assertSame("existing references to externObserverRow are still valid", externObserverRow, sheet2.getRow(0)); - + // Make sure copyRowFrom actually copied row (this is tested elsewhere) assertEquals(CellType.STRING, destRow.getCell(0).getCellType()); assertEquals("hello", destRow.getCell(0).getStringCellValue()); - + // We don't want #REF! errors if we copy a row that contains cells that are referred to by other cells outside of copied region assertEquals("references to overwritten cells are unmodified", "A2", observerRow.getCell(0).getCellFormula()); assertEquals("references to overwritten cells are unmodified", "B2", observerRow.getCell(1).getCellFormula()); assertEquals("references to overwritten cells are unmodified", "Sheet1!A2", externObserverRow.getCell(0).getCellFormula()); - + workbook.close(); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java index 618575c5d1..28239f47b3 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java @@ -27,7 +27,6 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; -import java.io.FileInputStream; import java.io.IOException; import java.util.Arrays; import java.util.Calendar; @@ -37,13 +36,12 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.apache.poi.EncryptedDocumentException; import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.ooxml.POIXMLException; import org.apache.poi.poifs.crypt.CryptoFunctions; import org.apache.poi.poifs.crypt.HashAlgorithm; +import org.apache.poi.ss.tests.usermodel.BaseTestXSheet; import org.apache.poi.ss.usermodel.AutoFilter; -import org.apache.poi.ss.usermodel.BaseTestXSheet; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellCopyPolicy; import org.apache.poi.ss.usermodel.CellType; @@ -57,8 +55,10 @@ import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.ss.usermodel.WorkbookFactory; -import org.apache.poi.ss.util.*; +import org.apache.poi.ss.util.CellAddress; +import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.ss.util.CellUtil; import org.apache.poi.util.LocaleUtil; import org.apache.poi.xssf.XSSFITestDataProvider; import org.apache.poi.xssf.XSSFTestDataSamples; diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java index bdab306964..e2b2d88d5e 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFWorkbook.java @@ -54,7 +54,7 @@ import org.apache.poi.openxml4j.opc.PackagingURIHelper; import org.apache.poi.openxml4j.opc.internal.FileHelper; import org.apache.poi.openxml4j.opc.internal.MemoryPackagePart; import org.apache.poi.openxml4j.opc.internal.PackagePropertiesPart; -import org.apache.poi.ss.usermodel.BaseTestXWorkbook; +import org.apache.poi.ss.tests.usermodel.BaseTestXWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.Font; @@ -81,7 +81,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr; import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCalcMode; -public final class TestXSSFWorkbook extends BaseTestXWorkbook { +public final class TestXSSFWorkbook extends BaseTestXWorkbook { public TestXSSFWorkbook() { super(XSSFITestDataProvider.instance); @@ -1007,26 +1007,26 @@ public final class TestXSSFWorkbook extends BaseTestXWorkbook { assertTrue(file.exists()); // read-only mode works! - Workbook workbook = WorkbookFactory.create(OPCPackage.open(file, PackageAccess.READ)); + Workbook workbook = XSSFWorkbookFactory.createWorkbook(OPCPackage.open(file, PackageAccess.READ)); Date dateAct = workbook.getSheetAt(0).getRow(0).getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getDateCellValue(); assertEquals(dateExp, dateAct); workbook.close(); workbook = null; - workbook = WorkbookFactory.create(OPCPackage.open(file, PackageAccess.READ)); + workbook = XSSFWorkbookFactory.createWorkbook(OPCPackage.open(file, PackageAccess.READ)); dateAct = workbook.getSheetAt(0).getRow(0).getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getDateCellValue(); assertEquals(dateExp, dateAct); workbook.close(); workbook = null; // now check read/write mode - workbook = WorkbookFactory.create(OPCPackage.open(file, PackageAccess.READ_WRITE)); + workbook = XSSFWorkbookFactory.createWorkbook(OPCPackage.open(file, PackageAccess.READ_WRITE)); dateAct = workbook.getSheetAt(0).getRow(0).getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getDateCellValue(); assertEquals(dateExp, dateAct); workbook.close(); workbook = null; - workbook = WorkbookFactory.create(OPCPackage.open(file, PackageAccess.READ_WRITE)); + workbook = XSSFWorkbookFactory.createWorkbook(OPCPackage.open(file, PackageAccess.READ_WRITE)); dateAct = workbook.getSheetAt(0).getRow(0).getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getDateCellValue(); assertEquals(dateExp, dateAct); workbook.close(); diff --git a/src/resources/main/META-INF/services/org.apache.poi.ss.usermodel.WorkbookProvider b/src/resources/main/META-INF/services/org.apache.poi.ss.usermodel.WorkbookProvider new file mode 100644 index 0000000000..fe7fe8c2a7 --- /dev/null +++ b/src/resources/main/META-INF/services/org.apache.poi.ss.usermodel.WorkbookProvider @@ -0,0 +1,18 @@ +# ==================================================================== +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ==================================================================== + +org.apache.poi.hssf.usermodel.HSSFWorkbookFactory
\ No newline at end of file diff --git a/src/resources/ooxml/META-INF/services/org.apache.poi.ss.usermodel.WorkbookProvider b/src/resources/ooxml/META-INF/services/org.apache.poi.ss.usermodel.WorkbookProvider new file mode 100644 index 0000000000..48b893240d --- /dev/null +++ b/src/resources/ooxml/META-INF/services/org.apache.poi.ss.usermodel.WorkbookProvider @@ -0,0 +1,18 @@ +# ==================================================================== +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ==================================================================== + +org.apache.poi.xssf.usermodel.XSSFWorkbookFactory
\ No newline at end of file diff --git a/src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java b/src/scratchpad/testcases/org/apache/poi/hslf/TestPOIDocumentScratchpad.java index d10c6f084f..03f3fcf823 100644 --- a/src/scratchpad/testcases/org/apache/poi/TestPOIDocumentScratchpad.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/TestPOIDocumentScratchpad.java @@ -18,7 +18,7 @@ -package org.apache.poi; +package org.apache.poi.hslf; import static org.junit.Assert.assertEquals; @@ -28,6 +28,8 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import org.apache.poi.POIDataSamples; +import org.apache.poi.POIDocument; import org.apache.poi.hpsf.DocumentSummaryInformation; import org.apache.poi.hpsf.HPSFPropertiesOnlyDocument; import org.apache.poi.hpsf.SummaryInformation; @@ -63,7 +65,7 @@ public final class TestPOIDocumentScratchpad { public void testReadProperties() { testReadPropertiesHelper(doc); } - + private void testReadPropertiesHelper(POIDocument docPH) { // We should have both sets assertNotNull(docPH.getDocumentSummaryInformation()); @@ -116,7 +118,7 @@ public final class TestPOIDocumentScratchpad { // Delegate test testReadPropertiesHelper(ppt); - + ppt.close(); inFS.close(); } diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java index fa0b4ea71b..25f9725ec2 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/model/TestShapes.java @@ -17,7 +17,7 @@ package org.apache.poi.hslf.model; -import static org.apache.poi.sl.TestCommonSL.getColor; +import static org.apache.poi.sl.usermodel.BaseTestSlideShow.getColor; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjListAtom.java b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjListAtom.java index 4a6c02696f..7d46ed14b1 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjListAtom.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/record/TestExObjListAtom.java @@ -18,7 +18,7 @@ package org.apache.poi.hslf.record; -import static org.apache.poi.ss.formula.functions.AbstractNumericTestCase.assertEquals; +import static org.apache.poi.ss.formula.functions.BaseTestNumeric.assertEquals; import static org.junit.Assert.assertArrayEquals; import java.io.ByteArrayOutputStream; diff --git a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTextRun.java b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTextRun.java index 6bae49681a..04d8c05601 100644 --- a/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTextRun.java +++ b/src/scratchpad/testcases/org/apache/poi/hslf/usermodel/TestTextRun.java @@ -17,7 +17,7 @@ package org.apache.poi.hslf.usermodel; -import static org.apache.poi.sl.TestCommonSL.getColor; +import static org.apache.poi.sl.usermodel.BaseTestSlideShow.getColor; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; diff --git a/src/scratchpad/testcases/org/apache/poi/TestJDK12.java b/src/testcases/org/apache/poi/TestJDK12.java index d0d33b2267..dfac092f04 100644 --- a/src/scratchpad/testcases/org/apache/poi/TestJDK12.java +++ b/src/testcases/org/apache/poi/TestJDK12.java @@ -17,14 +17,14 @@ package org.apache.poi; -import org.junit.Test; - import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.font.TextLayout; import java.awt.image.BufferedImage; import java.text.AttributedString; +import org.junit.Test; + /** * Minimal Test-Class found when running the Apache POI regression tests. * diff --git a/src/testcases/org/apache/poi/hssf/dev/BaseXLSIteratingTest.java b/src/testcases/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java index d57583aeb9..a8b30a001c 100644 --- a/src/testcases/org/apache/poi/hssf/dev/BaseXLSIteratingTest.java +++ b/src/testcases/org/apache/poi/hssf/dev/BaseTestIteratingXLS.java @@ -41,16 +41,16 @@ import org.junit.runners.Parameterized.Parameters; /** * Base class for integration-style tests which iterate over all test-files * and execute the same action to find out if any change breaks these applications. - * + * * This test uses {@link Parameterized} to run the test for each file separatedely. */ @RunWith(Parameterized.class) -public abstract class BaseXLSIteratingTest { +public abstract class BaseTestIteratingXLS { protected static final OutputStream NULL_OUTPUT_STREAM = new NullOutputStream(); @Rule public ExpectedException thrown = ExpectedException.none(); - + protected static final Map<String,Class<? extends Throwable>> EXCLUDED = new HashMap<>(); @@ -64,30 +64,30 @@ public abstract class BaseXLSIteratingTest { List<Object[]> files = new ArrayList<>(); findFile(files, dataDirName + "/spreadsheet"); findFile(files, dataDirName + "/hpsf"); - + return files; } - + private static void findFile(List<Object[]> list, String dir) { String[] files = new File(dir).list((arg0, arg1) -> arg1.toLowerCase(Locale.ROOT).endsWith(".xls")); - + assertNotNull("Did not find any xls files in directory " + dir, files); - + for(String file : files) { list.add(new Object[] { new File(dir, file) }); } } - + @Parameter public File file; - + @Test public void testMain() throws Exception { String fileName = file.getName(); if (EXCLUDED.containsKey(fileName)) { thrown.expect(EXCLUDED.get(fileName)); } - + try { runOneFile(file); } catch (Exception e) { @@ -95,7 +95,7 @@ public abstract class BaseXLSIteratingTest { try (FileInputStream stream = new FileInputStream(file); HSSFWorkbook wb = new HSSFWorkbook(stream)) { assertNotNull(wb); } - + throw e; } } diff --git a/src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java b/src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java index 17b43f0da1..12d7c6fbaf 100644 --- a/src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java +++ b/src/testcases/org/apache/poi/hssf/dev/TestBiffDrawingToXml.java @@ -26,7 +26,7 @@ import org.apache.poi.hssf.record.RecordInputStream; import org.apache.poi.util.RecordFormatException; import org.junit.BeforeClass; -public class TestBiffDrawingToXml extends BaseXLSIteratingTest { +public class TestBiffDrawingToXml extends BaseTestIteratingXLS { @BeforeClass public static void setup() { EXCLUDED.clear(); diff --git a/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java b/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java index 82a46327b9..d4fd62fa99 100644 --- a/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java +++ b/src/testcases/org/apache/poi/hssf/dev/TestBiffViewer.java @@ -33,7 +33,7 @@ import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; -public class TestBiffViewer extends BaseXLSIteratingTest { +public class TestBiffViewer extends BaseTestIteratingXLS { @BeforeClass public static void setup() { EXCLUDED.clear(); diff --git a/src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java b/src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java index a24b4967f7..d32e0b71eb 100644 --- a/src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java +++ b/src/testcases/org/apache/poi/hssf/dev/TestEFBiffViewer.java @@ -27,7 +27,7 @@ import org.apache.poi.util.LocaleUtil; import org.apache.poi.util.RecordFormatException; import org.junit.BeforeClass; -public class TestEFBiffViewer extends BaseXLSIteratingTest { +public class TestEFBiffViewer extends BaseTestIteratingXLS { @BeforeClass public static void setup() { EXCLUDED.clear(); diff --git a/src/testcases/org/apache/poi/hssf/dev/TestFormulaViewer.java b/src/testcases/org/apache/poi/hssf/dev/TestFormulaViewer.java index ec69abb4cb..b922230994 100644 --- a/src/testcases/org/apache/poi/hssf/dev/TestFormulaViewer.java +++ b/src/testcases/org/apache/poi/hssf/dev/TestFormulaViewer.java @@ -28,7 +28,7 @@ import org.apache.poi.util.LocaleUtil; import org.apache.poi.util.RecordFormatException; import org.junit.BeforeClass; -public class TestFormulaViewer extends BaseXLSIteratingTest { +public class TestFormulaViewer extends BaseTestIteratingXLS { @BeforeClass public static void setup() { EXCLUDED.clear(); diff --git a/src/testcases/org/apache/poi/hssf/dev/TestReSave.java b/src/testcases/org/apache/poi/hssf/dev/TestReSave.java index 97b84e21ac..890ef1e837 100644 --- a/src/testcases/org/apache/poi/hssf/dev/TestReSave.java +++ b/src/testcases/org/apache/poi/hssf/dev/TestReSave.java @@ -31,7 +31,7 @@ import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; -public class TestReSave extends BaseXLSIteratingTest { +public class TestReSave extends BaseTestIteratingXLS { @BeforeClass public static void setup() { EXCLUDED.clear(); diff --git a/src/testcases/org/apache/poi/hssf/dev/TestRecordLister.java b/src/testcases/org/apache/poi/hssf/dev/TestRecordLister.java index f15801390b..934eb5b89d 100644 --- a/src/testcases/org/apache/poi/hssf/dev/TestRecordLister.java +++ b/src/testcases/org/apache/poi/hssf/dev/TestRecordLister.java @@ -25,7 +25,7 @@ import org.apache.poi.util.LocaleUtil; import org.apache.poi.util.RecordFormatException; import org.junit.BeforeClass; -public class TestRecordLister extends BaseXLSIteratingTest { +public class TestRecordLister extends BaseTestIteratingXLS { @BeforeClass public static void setup() { EXCLUDED.clear(); @@ -40,7 +40,7 @@ public class TestRecordLister extends BaseXLSIteratingTest { EXCLUDED.put("61300.xls", RecordFormatException.class); EXCLUDED.put("64130.xls", OldExcelFormatException.class); //Biff 5 } - + @Override void runOneFile(File fileIn) throws IOException { PrintStream save = System.out; diff --git a/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java index 987741f4ca..987741f4ca 100644 --- a/src/scratchpad/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFChart.java diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRangeCopier.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRangeCopier.java index 8d685fc68d..07f37d8e4a 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRangeCopier.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRangeCopier.java @@ -21,10 +21,10 @@ package org.apache.poi.hssf.usermodel; import org.apache.poi.hssf.HSSFITestDataProvider; import org.apache.poi.hssf.HSSFTestDataSamples; -import org.apache.poi.ss.usermodel.TestRangeCopier; +import org.apache.poi.ss.usermodel.BaseTestRangeCopier; import org.junit.Before; -public class TestHSSFRangeCopier extends TestRangeCopier { +public class TestHSSFRangeCopier extends BaseTestRangeCopier { public TestHSSFRangeCopier() { super(); diff --git a/src/ooxml/testcases/org/apache/poi/xslf/geom/TestFormulaParser.java b/src/testcases/org/apache/poi/sl/draw/geom/TestFormulaParser.java index e78cefd048..0d82c2ad3e 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/geom/TestFormulaParser.java +++ b/src/testcases/org/apache/poi/sl/draw/geom/TestFormulaParser.java @@ -16,14 +16,10 @@ * limitations under the License. * ==================================================================== */ -package org.apache.poi.xslf.geom; +package org.apache.poi.sl.draw.geom; import static org.junit.Assert.assertEquals; -import org.apache.poi.sl.draw.geom.Context; -import org.apache.poi.sl.draw.geom.CustomGeometry; -import org.apache.poi.sl.draw.geom.Formula; -import org.apache.poi.sl.draw.geom.Guide; import org.junit.Test; /** diff --git a/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShow.java b/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShow.java index c12c96559f..5d53b4bd62 100644 --- a/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShow.java +++ b/src/testcases/org/apache/poi/sl/usermodel/BaseTestSlideShow.java @@ -31,6 +31,7 @@ import java.util.List; import org.apache.poi.POIDataSamples; import org.apache.poi.common.usermodel.fonts.FontInfo; +import org.apache.poi.sl.draw.DrawPaint; import org.apache.poi.sl.usermodel.PictureData.PictureType; import org.apache.poi.sl.usermodel.TabStop.TabStopType; import org.junit.Test; @@ -40,24 +41,24 @@ public abstract class BaseTestSlideShow< P extends TextParagraph<S,P,? extends TextRun> > { protected static final POIDataSamples slTests = POIDataSamples.getSlideShowInstance(); - + public abstract SlideShow<S,P> createSlideShow(); public abstract SlideShow<S,P> reopen(SlideShow<S,P> show); - + @Test public void addPicture_File() throws IOException { SlideShow<S,P> show = createSlideShow(); File f = slTests.getFile("clock.jpg"); - + assertEquals(0, show.getPictureData().size()); PictureData picture = show.addPicture(f, PictureType.JPEG); assertEquals(1, show.getPictureData().size()); assertSame(picture, show.getPictureData().get(0)); - + show.close(); } - + @Test public void addPicture_Stream() throws IOException { try (SlideShow<S,P> show = createSlideShow(); @@ -68,34 +69,34 @@ public abstract class BaseTestSlideShow< assertSame(picture, show.getPictureData().get(0)); } } - + @Test public void addPicture_ByteArray() throws IOException { SlideShow<S,P> show = createSlideShow(); byte[] data = slTests.readFile("clock.jpg"); - + assertEquals(0, show.getPictureData().size()); PictureData picture = show.addPicture(data, PictureType.JPEG); assertEquals(1, show.getPictureData().size()); assertSame(picture, show.getPictureData().get(0)); - + show.close(); } - + @Test public void findPicture() throws IOException { SlideShow<S,P> show = createSlideShow(); byte[] data = slTests.readFile("clock.jpg"); - + assertNull(show.findPictureData(data)); PictureData picture = show.addPicture(data, PictureType.JPEG); PictureData found = show.findPictureData(data); assertNotNull(found); assertEquals(picture, found); - + show.close(); } - + @Test public void addTabStops() throws IOException { try (final SlideShow<S,P> show1 = createSlideShow()) { @@ -109,7 +110,7 @@ public abstract class BaseTestSlideShow< master1_tp.addTabStops(10+i1*10, tst); i1++; } - + // then set it on a normal slide final Slide<S,P> slide1 = show1.createSlide(); final AutoShape<S,P> slide1_as = slide1.createAutoShape(); @@ -123,7 +124,7 @@ public abstract class BaseTestSlideShow< slide1_tp.addTabStops(15+i2*5, tst); i2++; } - + try (final SlideShow<S,P> show2 = reopen(show1)) { final MasterSheet<S,P> master2 = show2.getSlideMasters().get(0); final AutoShape<S,P> master2_as = (AutoShape<S,P>)master2.getPlaceholder(Placeholder.BODY); @@ -137,8 +138,8 @@ public abstract class BaseTestSlideShow< assertEquals(tst, ts.getType()); i3++; } - - + + final Slide<S,P> slide2 = show2.getSlides().get(0); @SuppressWarnings("unchecked") final AutoShape<S,P> slide2_as = (AutoShape<S,P>)slide2.getShapes().get(0); @@ -153,7 +154,7 @@ public abstract class BaseTestSlideShow< i4++; } } - } + } } @Test @@ -191,4 +192,11 @@ public abstract class BaseTestSlideShow< } } } + + public static Color getColor(PaintStyle paintActual) { + return (paintActual instanceof PaintStyle.SolidPaint) + ? DrawPaint.applyColorTransform(((PaintStyle.SolidPaint)paintActual).getSolidColor()) + : null; + } + } diff --git a/src/testcases/org/apache/poi/ss/format/TestCellFormat.java b/src/testcases/org/apache/poi/ss/format/TestCellFormat.java index 8234a93e4a..fa24171b9e 100644 --- a/src/testcases/org/apache/poi/ss/format/TestCellFormat.java +++ b/src/testcases/org/apache/poi/ss/format/TestCellFormat.java @@ -16,7 +16,9 @@ ==================================================================== */ package org.apache.poi.ss.format; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import java.io.IOException; import java.text.ParseException; @@ -24,10 +26,12 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone; +import java.util.stream.Stream; import javax.swing.JLabel; import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.hssf.util.HSSFColor; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.DateUtil; import org.apache.poi.ss.usermodel.Row; @@ -35,6 +39,7 @@ import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.util.LocaleUtil; import org.junit.AfterClass; +import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; @@ -1013,4 +1018,12 @@ public class TestCellFormat { CellFormat cf = CellFormat.getInstance("\"ca. \"0"); assertEquals("ca. 5", cf.apply((double) 5).text); } + + @Test + public void testNamedColors() { + assertTrue(CellFormatPart.NAMED_COLORS.size() >= HSSFColor.HSSFColorPredefined.values().length); + Stream.of("GREEN", "Green", "RED", "Red", "BLUE", "Blue", "YELLOW", "Yellow") + .map(CellFormatPart.NAMED_COLORS::get) + .forEach(Assert::assertNotNull); + } } diff --git a/src/testcases/org/apache/poi/ss/formula/AllSSFormulaTests.java b/src/testcases/org/apache/poi/ss/formula/AllSSFormulaTests.java index 59631017d2..14427df5d4 100644 --- a/src/testcases/org/apache/poi/ss/formula/AllSSFormulaTests.java +++ b/src/testcases/org/apache/poi/ss/formula/AllSSFormulaTests.java @@ -17,7 +17,7 @@ package org.apache.poi.ss.formula; -import org.apache.poi.ss.formula.eval.forked.TestForkedEvaluator; +import org.apache.poi.ss.formula.eval.forked.BaseTestForkedEvaluator; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -29,7 +29,7 @@ import org.junit.runners.Suite; TestCellCacheEntry.class, TestEvaluationCache.class, TestWorkbookEvaluator.class, - TestForkedEvaluator.class + BaseTestForkedEvaluator.class }) public class AllSSFormulaTests { } diff --git a/src/testcases/org/apache/poi/ss/formula/TestMissingWorkbook.java b/src/testcases/org/apache/poi/ss/formula/BaseTestMissingWorkbook.java index 1093e541a9..9cb755cf27 100644 --- a/src/testcases/org/apache/poi/ss/formula/TestMissingWorkbook.java +++ b/src/testcases/org/apache/poi/ss/formula/BaseTestMissingWorkbook.java @@ -19,6 +19,15 @@ package org.apache.poi.ss.formula; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.HashMap; +import java.util.Map; + import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; @@ -30,39 +39,30 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import java.util.HashMap; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -public class TestMissingWorkbook { +public class BaseTestMissingWorkbook { protected Workbook mainWorkbook; protected Workbook sourceWorkbook; - + protected final String MAIN_WORKBOOK_FILENAME; protected final String SOURCE_DUMMY_WORKBOOK_FILENAME; protected final String SOURCE_WORKBOOK_FILENAME; - - public TestMissingWorkbook() { + + public BaseTestMissingWorkbook() { this("52575_main.xls", "source_dummy.xls", "52575_source.xls"); } - protected TestMissingWorkbook(String MAIN_WORKBOOK_FILENAME, - String SOURCE_DUMMY_WORKBOOK_FILENAME, String SOURCE_WORKBOOK_FILENAME) { - this.MAIN_WORKBOOK_FILENAME = MAIN_WORKBOOK_FILENAME; + protected BaseTestMissingWorkbook(String MAIN_WORKBOOK_FILENAME, + String SOURCE_DUMMY_WORKBOOK_FILENAME, String SOURCE_WORKBOOK_FILENAME) { + this.MAIN_WORKBOOK_FILENAME = MAIN_WORKBOOK_FILENAME; this.SOURCE_DUMMY_WORKBOOK_FILENAME = SOURCE_DUMMY_WORKBOOK_FILENAME; this.SOURCE_WORKBOOK_FILENAME = SOURCE_WORKBOOK_FILENAME; } - + @Before public void setUp() throws Exception { mainWorkbook = HSSFTestDataSamples.openSampleWorkbook(MAIN_WORKBOOK_FILENAME); sourceWorkbook = HSSFTestDataSamples.openSampleWorkbook(SOURCE_WORKBOOK_FILENAME); - + assertNotNull(mainWorkbook); assertNotNull(sourceWorkbook); } @@ -81,11 +81,11 @@ public class TestMissingWorkbook { @Test public void testMissingWorkbookMissing() { FormulaEvaluator evaluator = mainWorkbook.getCreationHelper().createFormulaEvaluator(); - + Sheet lSheet = mainWorkbook.getSheetAt(0); Row lARow = lSheet.getRow(0); Cell lA1Cell = lARow.getCell(0); - + assertEquals(CellType.FORMULA, lA1Cell.getCellType()); try { evaluator.evaluateFormulaCell(lA1Cell); @@ -101,7 +101,7 @@ public class TestMissingWorkbook { Cell lA1Cell = lSheet.getRow(0).getCell(0); Cell lB1Cell = lSheet.getRow(1).getCell(0); Cell lC1Cell = lSheet.getRow(2).getCell(0); - + assertEquals(CellType.FORMULA, lA1Cell.getCellType()); assertEquals(CellType.FORMULA, lB1Cell.getCellType()); assertEquals(CellType.FORMULA, lC1Cell.getCellType()); @@ -110,7 +110,7 @@ public class TestMissingWorkbook { assertEquals(10.0d, lA1Cell.getNumericCellValue(), 0.00001d); assertEquals("POI rocks!", lB1Cell.getStringCellValue()); assertTrue(lC1Cell.getBooleanCellValue()); - + // Evaluate FormulaEvaluator evaluator = mainWorkbook.getCreationHelper().createFormulaEvaluator(); evaluator.setIgnoreMissingWorkbooks(true); @@ -130,7 +130,7 @@ public class TestMissingWorkbook { Cell lA1Cell = lSheet.getRow(0).getCell(0); Cell lB1Cell = lSheet.getRow(1).getCell(0); Cell lC1Cell = lSheet.getRow(2).getCell(0); - + assertEquals(CellType.FORMULA, lA1Cell.getCellType()); assertEquals(CellType.FORMULA, lB1Cell.getCellType()); assertEquals(CellType.FORMULA, lC1Cell.getCellType()); @@ -141,7 +141,7 @@ public class TestMissingWorkbook { workbooks.put(MAIN_WORKBOOK_FILENAME, lMainWorkbookEvaluator); workbooks.put(SOURCE_DUMMY_WORKBOOK_FILENAME, lSourceEvaluator); lMainWorkbookEvaluator.setupReferencedWorkbooks(workbooks); - + assertEquals(CellType.NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCell(lA1Cell)); assertEquals(CellType.STRING, lMainWorkbookEvaluator.evaluateFormulaCell(lB1Cell)); assertEquals(CellType.BOOLEAN, lMainWorkbookEvaluator.evaluateFormulaCell(lC1Cell)); diff --git a/src/testcases/org/apache/poi/ss/formula/eval/forked/TestForkedEvaluator.java b/src/testcases/org/apache/poi/ss/formula/eval/forked/BaseTestForkedEvaluator.java index e27499ce39..578452fe50 100644 --- a/src/testcases/org/apache/poi/ss/formula/eval/forked/TestForkedEvaluator.java +++ b/src/testcases/org/apache/poi/ss/formula/eval/forked/BaseTestForkedEvaluator.java @@ -32,15 +32,15 @@ import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -public class TestForkedEvaluator { - +public class BaseTestForkedEvaluator { + @Rule public ExpectedException expectedEx = ExpectedException.none(); - + protected Workbook newWorkbook() { return new HSSFWorkbook(); } - + /** * set up a calculation workbook with input cells nicely segregated on a * sheet called "Inputs" @@ -92,7 +92,7 @@ public class TestForkedEvaluator { eval1 = (NumberEval) fe1.evaluate("Calculations", 0, 0); assertNotNull(eval1); assertEquals(13.9, eval1.getNumberValue(), 0.0); - + wb.close(); } diff --git a/src/testcases/org/apache/poi/ss/formula/functions/AbstractNumericTestCase.java b/src/testcases/org/apache/poi/ss/formula/functions/BaseTestNumeric.java index 7d0fd5e7ad..ea1055cf7a 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/AbstractNumericTestCase.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/BaseTestNumeric.java @@ -26,7 +26,7 @@ import static org.junit.Assert.assertTrue; * @author Amol S. Deshmukh < amolweb at ya hoo dot com > * */ -public abstract class AbstractNumericTestCase { +public abstract class BaseTestNumeric { public static final double POS_ZERO = 1E-4; public static final double DIFF_TOLERANCE_FACTOR = 1E-8; diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestFinanceLib.java b/src/testcases/org/apache/poi/ss/formula/functions/TestFinanceLib.java index 212c8acc62..2e08083ca2 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestFinanceLib.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestFinanceLib.java @@ -27,7 +27,7 @@ import org.junit.Test; * @author Amol S. Deshmukh < amolweb at ya hoo dot com > * */ -public class TestFinanceLib extends AbstractNumericTestCase { +public class TestFinanceLib extends BaseTestNumeric { @Test public void testFv() { diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestMathX.java b/src/testcases/org/apache/poi/ss/formula/functions/TestMathX.java index 43a7d48cc9..22506bd00e 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestMathX.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestMathX.java @@ -30,7 +30,7 @@ import org.junit.Test; * @author Amol S. Deshmukh < amolweb at ya hoo dot com > * */ -public class TestMathX extends AbstractNumericTestCase { +public class TestMathX extends BaseTestNumeric { @Test public void testAcosh() { diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestStatsLib.java b/src/testcases/org/apache/poi/ss/formula/functions/TestStatsLib.java index b489cdcb4b..bb8b8e62bb 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestStatsLib.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestStatsLib.java @@ -29,7 +29,7 @@ import org.junit.Ignore; import org.junit.Test; -public class TestStatsLib extends AbstractNumericTestCase { +public class TestStatsLib extends BaseTestNumeric { @Test public void testDevsq() { diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestTrunc.java b/src/testcases/org/apache/poi/ss/formula/functions/TestTrunc.java index b11fd45ad2..a501435616 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestTrunc.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestTrunc.java @@ -29,7 +29,7 @@ import org.junit.Test; * * @author Stephen Wolke (smwolke at geistig.com) */ -public final class TestTrunc extends AbstractNumericTestCase { +public final class TestTrunc extends BaseTestNumeric { private static final NumericFunction F = null; @Test diff --git a/src/testcases/org/apache/poi/ss/formula/ptg/AbstractPtgTestCase.java b/src/testcases/org/apache/poi/ss/formula/ptg/BaseTestPtg.java index d03a4e269a..8e566bf929 100644 --- a/src/testcases/org/apache/poi/ss/formula/ptg/AbstractPtgTestCase.java +++ b/src/testcases/org/apache/poi/ss/formula/ptg/BaseTestPtg.java @@ -24,7 +24,7 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook; * Convenient abstract class to reduce the amount of boilerplate code needed * in ptg-related unit tests. */ -public abstract class AbstractPtgTestCase { +public abstract class BaseTestPtg { /** * Loads a workbook from the given filename in the test data dir. diff --git a/src/testcases/org/apache/poi/ss/formula/ptg/TestArea3DPtg.java b/src/testcases/org/apache/poi/ss/formula/ptg/TestArea3DPtg.java index c06f7f7b35..481d7c5051 100644 --- a/src/testcases/org/apache/poi/ss/formula/ptg/TestArea3DPtg.java +++ b/src/testcases/org/apache/poi/ss/formula/ptg/TestArea3DPtg.java @@ -28,7 +28,7 @@ import org.junit.Test; /** * Tests for Area3DPtg */ -public final class TestArea3DPtg extends AbstractPtgTestCase { +public final class TestArea3DPtg extends BaseTestPtg { /** * confirms that sheet names get properly escaped diff --git a/src/testcases/org/apache/poi/ss/formula/ptg/TestAreaErrPtg.java b/src/testcases/org/apache/poi/ss/formula/ptg/TestAreaErrPtg.java index 028ed03d3f..3d04da1db5 100644 --- a/src/testcases/org/apache/poi/ss/formula/ptg/TestAreaErrPtg.java +++ b/src/testcases/org/apache/poi/ss/formula/ptg/TestAreaErrPtg.java @@ -27,7 +27,7 @@ import org.junit.Test; /** * Tests for {@link AreaErrPtg}. */ -public final class TestAreaErrPtg extends AbstractPtgTestCase { +public final class TestAreaErrPtg extends BaseTestPtg { /** * Tests reading a file containing this ptg. */ diff --git a/src/testcases/org/apache/poi/ss/formula/ptg/TestAttrPtg.java b/src/testcases/org/apache/poi/ss/formula/ptg/TestAttrPtg.java index b7b058007a..d957a956aa 100644 --- a/src/testcases/org/apache/poi/ss/formula/ptg/TestAttrPtg.java +++ b/src/testcases/org/apache/poi/ss/formula/ptg/TestAttrPtg.java @@ -27,7 +27,7 @@ import org.junit.Test; /** * Tests for {@link AttrPtg}. */ -public final class TestAttrPtg extends AbstractPtgTestCase { +public final class TestAttrPtg extends BaseTestPtg { /** * Fix for bug visible around svn r706772. diff --git a/src/testcases/org/apache/poi/ss/formula/ptg/TestErrPtg.java b/src/testcases/org/apache/poi/ss/formula/ptg/TestErrPtg.java index 5f9af47846..0ff6ad78b6 100644 --- a/src/testcases/org/apache/poi/ss/formula/ptg/TestErrPtg.java +++ b/src/testcases/org/apache/poi/ss/formula/ptg/TestErrPtg.java @@ -28,7 +28,7 @@ import org.junit.Test; /** * Tests for {@link ErrPtg}. */ -public final class TestErrPtg extends AbstractPtgTestCase { +public final class TestErrPtg extends BaseTestPtg { /** * Tests reading a file containing this ptg. */ diff --git a/src/testcases/org/apache/poi/ss/formula/ptg/TestIntersectionPtg.java b/src/testcases/org/apache/poi/ss/formula/ptg/TestIntersectionPtg.java index c13bf638a9..729920cb8a 100644 --- a/src/testcases/org/apache/poi/ss/formula/ptg/TestIntersectionPtg.java +++ b/src/testcases/org/apache/poi/ss/formula/ptg/TestIntersectionPtg.java @@ -28,7 +28,7 @@ import org.junit.Test; /** * Tests for {@link IntersectionPtg}. */ -public final class TestIntersectionPtg extends AbstractPtgTestCase { +public final class TestIntersectionPtg extends BaseTestPtg { /** * Tests reading a file containing this ptg. */ diff --git a/src/testcases/org/apache/poi/ss/formula/ptg/TestPercentPtg.java b/src/testcases/org/apache/poi/ss/formula/ptg/TestPercentPtg.java index 84ede5baa6..4b69d0743b 100644 --- a/src/testcases/org/apache/poi/ss/formula/ptg/TestPercentPtg.java +++ b/src/testcases/org/apache/poi/ss/formula/ptg/TestPercentPtg.java @@ -28,7 +28,7 @@ import org.junit.Test; /** * Tests for {@link PercentPtg}. */ -public final class TestPercentPtg extends AbstractPtgTestCase { +public final class TestPercentPtg extends BaseTestPtg { /** * Tests reading a file containing this ptg. */ diff --git a/src/testcases/org/apache/poi/ss/formula/ptg/TestRangePtg.java b/src/testcases/org/apache/poi/ss/formula/ptg/TestRangePtg.java index 55438777fa..5389538ab2 100644 --- a/src/testcases/org/apache/poi/ss/formula/ptg/TestRangePtg.java +++ b/src/testcases/org/apache/poi/ss/formula/ptg/TestRangePtg.java @@ -28,7 +28,7 @@ import org.junit.Test; /** * Tests for {@link RangePtg}. */ -public final class TestRangePtg extends AbstractPtgTestCase { +public final class TestRangePtg extends BaseTestPtg { /** * Tests reading a file containing this ptg. */ diff --git a/src/testcases/org/apache/poi/ss/formula/ptg/TestRef3DPtg.java b/src/testcases/org/apache/poi/ss/formula/ptg/TestRef3DPtg.java index 2bea126dab..04de2cb6e3 100644 --- a/src/testcases/org/apache/poi/ss/formula/ptg/TestRef3DPtg.java +++ b/src/testcases/org/apache/poi/ss/formula/ptg/TestRef3DPtg.java @@ -28,7 +28,7 @@ import org.junit.Test; /** * Tests for Ref3DPtg */ -public final class TestRef3DPtg extends AbstractPtgTestCase { +public final class TestRef3DPtg extends BaseTestPtg { @Test public void testToFormulaString() throws IOException { diff --git a/src/testcases/org/apache/poi/ss/formula/ptg/TestUnionPtg.java b/src/testcases/org/apache/poi/ss/formula/ptg/TestUnionPtg.java index 7d6fc3151c..446700f78d 100644 --- a/src/testcases/org/apache/poi/ss/formula/ptg/TestUnionPtg.java +++ b/src/testcases/org/apache/poi/ss/formula/ptg/TestUnionPtg.java @@ -28,7 +28,7 @@ import org.junit.Test; /** * Tests for {@link UnionPtg}. */ -public final class TestUnionPtg extends AbstractPtgTestCase { +public final class TestUnionPtg extends BaseTestPtg { /** * Tests reading a file containing this ptg. */ diff --git a/src/testcases/org/apache/poi/ss/usermodel/TestRangeCopier.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRangeCopier.java index 929abc35d4..f044b6f0b7 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/TestRangeCopier.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRangeCopier.java @@ -19,16 +19,18 @@ package org.apache.poi.ss.usermodel; -import org.junit.Ignore; -import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import org.apache.poi.ss.ITestDataProvider; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellReference; - -import static org.junit.Assert.*; +import org.junit.Ignore; +import org.junit.Test; @Ignore -public abstract class TestRangeCopier { +public abstract class BaseTestRangeCopier { protected Sheet sheet1; protected Sheet sheet2; protected Workbook workbook; |