View | Details | Raw Unified | Return to bug 63805
Collapse All | Expand All

(-)src/examples/src/org/apache/poi/xslf/usermodel/BarChartDemo.java (-3 / +3 lines)
Lines 76-84 Link Here
76
                listSpeakers.add(Double.valueOf(vals[1]));
76
                listSpeakers.add(Double.valueOf(vals[1]));
77
                listLanguages.add(vals[2]);
77
                listLanguages.add(vals[2]);
78
            }
78
            }
79
            String[] categories = listLanguages.toArray(new String[listLanguages.size()]);
79
            String[] categories = listLanguages.toArray(new String[0]);
80
            Double[] values1 = listCountries.toArray(new Double[listCountries.size()]);
80
            Double[] values1 = listCountries.toArray(new Double[0]);
81
            Double[] values2 = listSpeakers.toArray(new Double[listSpeakers.size()]);
81
            Double[] values2 = listSpeakers.toArray(new Double[0]);
82
82
83
            try (XMLSlideShow pptx = new XMLSlideShow(argIS)) {
83
            try (XMLSlideShow pptx = new XMLSlideShow(argIS)) {
84
                XSLFSlide slide = pptx.getSlides().get(0);
84
                XSLFSlide slide = pptx.getSlides().get(0);
(-)src/examples/src/org/apache/poi/xslf/usermodel/ChartFromScratch.java (-3 / +3 lines)
Lines 79-87 Link Here
79
                listLanguages.add(vals[2]);
79
                listLanguages.add(vals[2]);
80
            }
80
            }
81
81
82
            String[] categories = listLanguages.toArray(new String[listLanguages.size()]);
82
            String[] categories = listLanguages.toArray(new String[0]);
83
            Double[] values1 = listCountries.toArray(new Double[listCountries.size()]);
83
            Double[] values1 = listCountries.toArray(new Double[0]);
84
            Double[] values2 = listSpeakers.toArray(new Double[listSpeakers.size()]);
84
            Double[] values2 = listSpeakers.toArray(new Double[0]);
85
85
86
            try {
86
            try {
87
87
(-)src/examples/src/org/apache/poi/xslf/usermodel/PieChartDemo.java (-2 / +2 lines)
Lines 89-96 Link Here
89
	                listCategories.add(vals[0]);
89
	                listCategories.add(vals[0]);
90
	                listValues.add(Double.valueOf(vals[1]));
90
	                listValues.add(Double.valueOf(vals[1]));
91
	            }
91
	            }
92
	            String[] categories = listCategories.toArray(new String[listCategories.size()]);
92
	            String[] categories = listCategories.toArray(new String[0]);
93
	            Double[] values = listValues.toArray(new Double[listValues.size()]);
93
	            Double[] values = listValues.toArray(new Double[0]);
94
94
95
	            final int numOfPoints = categories.length;
95
	            final int numOfPoints = categories.length;
96
	            final String categoryDataRange = chart.formatRange(new CellRangeAddress(1, numOfPoints, 0, 0));
96
	            final String categoryDataRange = chart.formatRange(new CellRangeAddress(1, numOfPoints, 0, 0));
(-)src/examples/src/org/apache/poi/xwpf/usermodel/examples/BarChartExample.java (-3 / +3 lines)
Lines 78-86 Link Here
78
                listSpeakers.add(Double.valueOf(vals[1]));
78
                listSpeakers.add(Double.valueOf(vals[1]));
79
                listLanguages.add(vals[2]);
79
                listLanguages.add(vals[2]);
80
            }
80
            }
81
            String[] categories = listLanguages.toArray(new String[listLanguages.size()]);
81
            String[] categories = listLanguages.toArray(new String[0]);
82
            Double[] values1 = listCountries.toArray(new Double[listCountries.size()]);
82
            Double[] values1 = listCountries.toArray(new Double[0]);
83
            Double[] values2 = listSpeakers.toArray(new Double[listSpeakers.size()]);
83
            Double[] values2 = listSpeakers.toArray(new Double[0]);
84
84
85
            try (XWPFDocument doc = new XWPFDocument(argIS)) {
85
            try (XWPFDocument doc = new XWPFDocument(argIS)) {
86
                XWPFChart chart = doc.getCharts().get(0);
86
                XWPFChart chart = doc.getCharts().get(0);
(-)src/examples/src/org/apache/poi/xwpf/usermodel/examples/ChartFromScratch.java (-3 / +3 lines)
Lines 80-88 Link Here
80
                listLanguages.add(vals[2]);
80
                listLanguages.add(vals[2]);
81
            }
81
            }
82
82
83
            String[] categories = listLanguages.toArray(new String[listLanguages.size()]);
83
            String[] categories = listLanguages.toArray(new String[0]);
84
            Double[] values1 = listCountries.toArray(new Double[listCountries.size()]);
84
            Double[] values1 = listCountries.toArray(new Double[0]);
85
            Double[] values2 = listSpeakers.toArray(new Double[listSpeakers.size()]);
85
            Double[] values2 = listSpeakers.toArray(new Double[0]);
86
86
87
            try (XWPFDocument doc = new XWPFDocument()) {
87
            try (XWPFDocument doc = new XWPFDocument()) {
88
                XWPFChart chart = doc.createChart(XDDFChart.DEFAULT_WIDTH, XDDFChart.DEFAULT_HEIGHT);
88
                XWPFChart chart = doc.createChart(XDDFChart.DEFAULT_WIDTH, XDDFChart.DEFAULT_HEIGHT);
(-)src/ooxml/java/org/apache/poi/xddf/usermodel/text/XDDFTextRun.java (-1 / +1 lines)
Lines 365-371 Link Here
365
            .map(font -> new XDDFFont(FontGroup.SYMBOL, font))
365
            .map(font -> new XDDFFont(FontGroup.SYMBOL, font))
366
            .ifPresent(font -> list.add(font));
366
            .ifPresent(font -> list.add(font));
367
367
368
        return list.toArray(new XDDFFont[list.size()]);
368
        return list.toArray(new XDDFFont[0]);
369
    }
369
    }
370
370
371
    /**
371
    /**
(-)src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFConditionalFormatting.java (-1 / +1 lines)
Lines 61-67 Link Here
61
                lst.add(CellRangeAddress.valueOf(region));
61
                lst.add(CellRangeAddress.valueOf(region));
62
            }
62
            }
63
        }
63
        }
64
        return lst.toArray(new CellRangeAddress[lst.size()]);
64
        return lst.toArray(new CellRangeAddress[0]);
65
    }
65
    }
66
66
67
    @Override
67
    @Override
(-)src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java (-7 / +3 lines)
Lines 445-451 Link Here
445
    }
445
    }
446
446
447
    public XWPFHyperlink[] getHyperlinks() {
447
    public XWPFHyperlink[] getHyperlinks() {
448
        return hyperlinks.toArray(new XWPFHyperlink[hyperlinks.size()]);
448
        return hyperlinks.toArray(new XWPFHyperlink[0]);
449
    }
449
    }
450
450
451
    public XWPFComment getCommentByID(String id) {
451
    public XWPFComment getCommentByID(String id) {
Lines 459-465 Link Here
459
    }
459
    }
460
460
461
    public XWPFComment[] getComments() {
461
    public XWPFComment[] getComments() {
462
        return comments.toArray(new XWPFComment[comments.size()]);
462
        return comments.toArray(new XWPFComment[0]);
463
    }
463
    }
464
464
465
    /**
465
    /**
Lines 1423-1433 Link Here
1423
    }
1423
    }
1424
1424
1425
    void registerPackagePictureData(XWPFPictureData picData) {
1425
    void registerPackagePictureData(XWPFPictureData picData) {
1426
        List<XWPFPictureData> list = packagePictures.get(picData.getChecksum());
1426
        List<XWPFPictureData> list = packagePictures.computeIfAbsent(picData.getChecksum(), k -> new ArrayList<>(1));
1427
        if (list == null) {
1428
            list = new ArrayList<>(1);
1429
            packagePictures.put(picData.getChecksum(), list);
1430
        }
1431
        if (!list.contains(picData)) {
1427
        if (!list.contains(picData)) {
1432
            list.add(picData);
1428
            list.add(picData);
1433
        }
1429
        }
(-)src/scratchpad/src/org/apache/poi/hdgf/chunks/Chunk.java (-1 / +1 lines)
Lines 258-264 Link Here
258
258
259
		// Save the commands we liked the look of
259
		// Save the commands we liked the look of
260
		this.commands = commandList.toArray(
260
		this.commands = commandList.toArray(
261
							new Command[commandList.size()] );
261
                new Command[0]);
262
262
263
		// Now build up the blocks, if we had a command that tells
263
		// Now build up the blocks, if we had a command that tells
264
		//  us where a block is
264
		//  us where a block is
(-)src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkFactory.java (-1 / +1 lines)
Lines 109-115 Link Here
109
    				defsL.add(def);
109
    				defsL.add(def);
110
    			}
110
    			}
111
    
111
    
112
    			CommandDefinition[] defs = defsL.toArray(new CommandDefinition[defsL.size()]);
112
    			CommandDefinition[] defs = defsL.toArray(new CommandDefinition[0]);
113
    
113
    
114
    			// Add to the map
114
    			// Add to the map
115
    			chunkCommandDefinitions.put(Integer.valueOf(chunkType), defs);
115
    			chunkCommandDefinitions.put(Integer.valueOf(chunkType), defs);
(-)src/scratchpad/src/org/apache/poi/hdgf/streams/ChunkStream.java (-1 / +1 lines)
Lines 76-81 Link Here
76
			logger.log(POILogger.ERROR, "Failed to create chunk at " + pos + ", ignoring rest of data." + e);
76
			logger.log(POILogger.ERROR, "Failed to create chunk at " + pos + ", ignoring rest of data." + e);
77
		}
77
		}
78
78
79
		chunks = chunksA.toArray(new Chunk[chunksA.size()]);
79
		chunks = chunksA.toArray(new Chunk[0]);
80
	}
80
	}
81
}
81
}
(-)src/scratchpad/src/org/apache/poi/hpbf/model/EscherPart.java (-1 / +1 lines)
Lines 57-63 Link Here
57
			ec.add(er);
57
			ec.add(er);
58
		}
58
		}
59
59
60
		records = ec.toArray(new EscherRecord[ec.size()]);
60
		records = ec.toArray(new EscherRecord[0]);
61
	}
61
	}
62
62
63
	public EscherRecord[] getEscherRecords() {
63
	public EscherRecord[] getEscherRecords() {
(-)src/scratchpad/src/org/apache/poi/hslf/record/ExObjList.java (-1 / +1 lines)
Lines 50-56 Link Here
50
			}
50
			}
51
		}
51
		}
52
52
53
		return links.toArray(new ExHyperlink[links.size()]);
53
		return links.toArray(new ExHyperlink[0]);
54
	}
54
	}
55
55
56
	/** 
56
	/** 
(-)src/scratchpad/src/org/apache/poi/hslf/record/MainMaster.java (-2 / +2 lines)
Lines 82-89 Link Here
82
			}
82
			}
83
83
84
		}
84
		}
85
		txmasters = tx.toArray(new TxMasterStyleAtom[tx.size()]);
85
		txmasters = tx.toArray(new TxMasterStyleAtom[0]);
86
		clrscheme = clr.toArray(new ColorSchemeAtom[clr.size()]);
86
		clrscheme = clr.toArray(new ColorSchemeAtom[0]);
87
	}
87
	}
88
88
89
	/**
89
	/**
(-)src/scratchpad/src/org/apache/poi/hslf/record/Record.java (-1 / +1 lines)
Lines 149-155 Link Here
149
		}
149
		}
150
150
151
		// Turn the vector into an array, and return
151
		// Turn the vector into an array, and return
152
        return children.toArray( new Record[children.size()] );
152
        return children.toArray(new Record[0]);
153
	}
153
	}
154
154
155
	/**
155
	/**
(-)src/scratchpad/src/org/apache/poi/hslf/record/RecordContainer.java (-1 / +1 lines)
Lines 150-156 Link Here
150
                rm = r;
150
                rm = r;
151
            }
151
            }
152
        }
152
        }
153
        _children = lst.toArray(new Record[lst.size()]);
153
        _children = lst.toArray(new Record[0]);
154
        return rm;
154
        return rm;
155
    }
155
    }
156
156
(-)src/scratchpad/src/org/apache/poi/hslf/record/SlideListWithText.java (-1 / +1 lines)
Lines 107-113 Link Here
107
		}
107
		}
108
108
109
		// Turn the list into an array
109
		// Turn the list into an array
110
		slideAtomsSets = sets.toArray( new SlideAtomsSet[sets.size()] );
110
		slideAtomsSets = sets.toArray(new SlideAtomsSet[0]);
111
	}
111
	}
112
112
113
	/**
113
	/**
(-)src/scratchpad/src/org/apache/poi/hslf/record/StyleTextProp9Atom.java (-2 / +2 lines)
Lines 91-97 Link Here
91
                break;
91
                break;
92
            }
92
            }
93
        }
93
        }
94
        this.autoNumberSchemes = schemes.toArray(new TextPFException9[schemes.size()]);
94
        this.autoNumberSchemes = schemes.toArray(new TextPFException9[0]);
95
    }
95
    }
96
96
97
    /**
97
    /**
Lines 155-158 Link Here
155
            "autoNumberSchemes", this::getAutoNumberTypes
155
            "autoNumberSchemes", this::getAutoNumberTypes
156
        );
156
        );
157
    }
157
    }
158
}
158
}
(-)src/scratchpad/src/org/apache/poi/hslf/record/TextSpecInfoAtom.java (-1 / +1 lines)
Lines 177-183 Link Here
177
        while (bis.getReadIndex() < _data.length) {
177
        while (bis.getReadIndex() < _data.length) {
178
            lst.add(new TextSpecInfoRun(bis));
178
            lst.add(new TextSpecInfoRun(bis));
179
        }
179
        }
180
        return lst.toArray(new TextSpecInfoRun[lst.size()]);
180
        return lst.toArray(new TextSpecInfoRun[0]);
181
    }
181
    }
182
182
183
    @Override
183
    @Override
(-)src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowEncrypted.java (-2 / +2 lines)
Lines 452-458 Link Here
452
            recordMap.remove(oldOffset);
452
            recordMap.remove(oldOffset);
453
        }
453
        }
454
454
455
        return recordMap.values().toArray(new Record[recordMap.size()]);
455
        return recordMap.values().toArray(new Record[0]);
456
    }
456
    }
457
457
458
458
Lines 496-502 Link Here
496
496
497
        uea.setMaxPersistWritten(maxSlideId);
497
        uea.setMaxPersistWritten(maxSlideId);
498
498
499
        records = recordList.toArray(new Record[recordList.size()]);
499
        records = recordList.toArray(new Record[0]);
500
500
501
        return records;
501
        return records;
502
    }
502
    }
(-)src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSoundData.java (-1 / +1 lines)
Lines 89-94 Link Here
89
            }
89
            }
90
90
91
        }
91
        }
92
        return lst.toArray(new HSLFSoundData[lst.size()]);
92
        return lst.toArray(new HSLFSoundData[0]);
93
    }
93
    }
94
}
94
}
(-)src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java (-2 / +2 lines)
Lines 167-174 Link Here
167
            attachments.add( (AttachmentChunks)group );
167
            attachments.add( (AttachmentChunks)group );
168
         }
168
         }
169
      }
169
      }
170
      attachmentChunks = attachments.toArray(new AttachmentChunks[attachments.size()]);
170
      attachmentChunks = attachments.toArray(new AttachmentChunks[0]);
171
      recipientChunks  = recipients.toArray(new RecipientChunks[recipients.size()]);
171
      recipientChunks  = recipients.toArray(new RecipientChunks[0]);
172
172
173
      // Now sort these chunks lists so they're in ascending order,
173
      // Now sort these chunks lists so they're in ascending order,
174
      //  rather than in random filesystem order
174
      //  rather than in random filesystem order
(-)src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java (-1 / +1 lines)
Lines 98-104 Link Here
98
    }
98
    }
99
99
100
    public Chunk[] getAll() {
100
    public Chunk[] getAll() {
101
        return allChunks.toArray(new Chunk[allChunks.size()]);
101
        return allChunks.toArray(new Chunk[0]);
102
    }
102
    }
103
103
104
    @Override
104
    @Override
(-)src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java (-5 / +3 lines)
Lines 110-116 Link Here
110
        for (List<Chunk> c : allChunks.values()) {
110
        for (List<Chunk> c : allChunks.values()) {
111
            chunks.addAll(c);
111
            chunks.addAll(c);
112
        }
112
        }
113
        return chunks.toArray(new Chunk[chunks.size()]);
113
        return chunks.toArray(new Chunk[0]);
114
    }
114
    }
115
115
116
    public StringChunk getMessageClass() {
116
    public StringChunk getMessageClass() {
Lines 239-247 Link Here
239
        }
239
        }
240
240
241
        // And add to the main list
241
        // And add to the main list
242
        if (allChunks.get(prop) == null) {
242
        allChunks.computeIfAbsent(prop, k -> new ArrayList<>());
243
            allChunks.put(prop, new ArrayList<>());
244
        }
245
        allChunks.get(prop).add(chunk);
243
        allChunks.get(prop).add(chunk);
246
    }
244
    }
247
245
Lines 254-257 Link Here
254
                    "Message didn't contain a root list of properties!");
252
                    "Message didn't contain a root list of properties!");
255
        }
253
        }
256
    }
254
    }
257
}
255
}
(-)src/scratchpad/src/org/apache/poi/hsmf/datatypes/NameIdChunks.java (-1 / +1 lines)
Lines 30-36 Link Here
30
    private List<Chunk> allChunks = new ArrayList<>();
30
    private List<Chunk> allChunks = new ArrayList<>();
31
31
32
    public Chunk[] getAll() {
32
    public Chunk[] getAll() {
33
        return allChunks.toArray(new Chunk[allChunks.size()]);
33
        return allChunks.toArray(new Chunk[0]);
34
    }
34
    }
35
35
36
    @Override
36
    @Override
(-)src/scratchpad/src/org/apache/poi/hsmf/datatypes/RecipientChunks.java (-1 / +1 lines)
Lines 172-178 Link Here
172
    }
172
    }
173
173
174
    public Chunk[] getAll() {
174
    public Chunk[] getAll() {
175
        return allChunks.toArray(new Chunk[allChunks.size()]);
175
        return allChunks.toArray(new Chunk[0]);
176
    }
176
    }
177
177
178
    @Override
178
    @Override
(-)src/scratchpad/src/org/apache/poi/hsmf/parsers/POIFSChunkParser.java (-1 / +1 lines)
Lines 99-105 Link Here
99
      }
99
      }
100
      
100
      
101
      // Finish
101
      // Finish
102
      return groups.toArray(new ChunkGroup[groups.size()]);
102
      return groups.toArray(new ChunkGroup[0]);
103
   }
103
   }
104
   
104
   
105
   /**
105
   /**
(-)src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordUtils.java (-1 / +1 lines)
Lines 82-88 Link Here
82
            }
82
            }
83
        }
83
        }
84
84
85
        Integer[] sorted = edges.toArray( new Integer[edges.size()] );
85
        Integer[] sorted = edges.toArray(new Integer[0]);
86
        int[] result = new int[sorted.length];
86
        int[] result = new int[sorted.length];
87
        for ( int i = 0; i < sorted.length; i++ )
87
        for ( int i = 0; i < sorted.length; i++ )
88
        {
88
        {
(-)src/scratchpad/src/org/apache/poi/hwpf/model/BookmarksTables.java (-1 / +1 lines)
Lines 194-200 Link Here
194
        }
194
        }
195
195
196
        int start = tableStream.size();
196
        int start = tableStream.size();
197
        SttbUtils.writeSttbfBkmk( names.toArray( new String[names.size()] ),
197
        SttbUtils.writeSttbfBkmk( names.toArray(new String[0]),
198
                tableStream );
198
                tableStream );
199
        int end = tableStream.size();
199
        int end = tableStream.size();
200
200
(-)src/scratchpad/src/org/apache/poi/hwpf/model/ComplexFileTable.java (-1 / +1 lines)
Lines 61-67 Link Here
61
            SprmBuffer sprmBuffer = new SprmBuffer(bs, false, 0);
61
            SprmBuffer sprmBuffer = new SprmBuffer(bs, false, 0);
62
            sprmBuffers.add(sprmBuffer);
62
            sprmBuffers.add(sprmBuffer);
63
        }
63
        }
64
        this._grpprls = sprmBuffers.toArray(new SprmBuffer[sprmBuffers.size()]);
64
        this._grpprls = sprmBuffers.toArray(new SprmBuffer[0]);
65
65
66
        if (tableStream[offset] != TEXT_PIECE_TABLE_TYPE) {
66
        if (tableStream[offset] != TEXT_PIECE_TABLE_TYPE) {
67
            throw new IOException("The text piece table is corrupted");
67
            throw new IOException("The text piece table is corrupted");
(-)src/scratchpad/src/org/apache/poi/hwpf/model/FSPATable.java (-1 / +1 lines)
Lines 84-90 Link Here
84
        {
84
        {
85
            result.add( new FSPA( propertyNode.getBytes(), 0 ) );
85
            result.add( new FSPA( propertyNode.getBytes(), 0 ) );
86
        }
86
        }
87
        return result.toArray( new FSPA[result.size()] );
87
        return result.toArray(new FSPA[0]);
88
    }
88
    }
89
89
90
    public String toString()
90
    public String toString()
(-)src/scratchpad/src/org/apache/poi/hwpf/model/OldFontTable.java (-1 / +1 lines)
Lines 57-63 Link Here
57
            startOffset += oldFfn.getLength();
57
            startOffset += oldFfn.getLength();
58
58
59
        }
59
        }
60
        _fontNames = ffns.toArray(new OldFfn[ffns.size()]);
60
        _fontNames = ffns.toArray(new OldFfn[0]);
61
    }
61
    }
62
62
63
63
(-)src/scratchpad/src/org/apache/poi/hwpf/model/PlexOfCps.java (-1 / +1 lines)
Lines 163-169 Link Here
163
        if (_props == null || _props.isEmpty())
163
        if (_props == null || _props.isEmpty())
164
            return new GenericPropertyNode[0];
164
            return new GenericPropertyNode[0];
165
165
166
        return _props.toArray(new GenericPropertyNode[_props.size()]);
166
        return _props.toArray(new GenericPropertyNode[0]);
167
    }
167
    }
168
168
169
    @Override
169
    @Override
(-)src/scratchpad/testcases/org/apache/poi/hslf/record/TestTxMasterStyleAtom.java (-1 / +1 lines)
Lines 235-240 Link Here
235
            }
235
            }
236
        }
236
        }
237
237
238
        return lst.toArray(new TxMasterStyleAtom[lst.size()]);
238
        return lst.toArray(new TxMasterStyleAtom[0]);
239
    }
239
    }
240
}
240
}
(-)src/testcases/org/apache/poi/hssf/record/aggregates/TestColumnInfoRecordsAggregate.java (-1 / +1 lines)
Lines 74-80 Link Here
74
		public static ColumnInfoRecord[] getRecords(ColumnInfoRecordsAggregate agg) {
74
		public static ColumnInfoRecord[] getRecords(ColumnInfoRecordsAggregate agg) {
75
			CIRCollector circ = new CIRCollector();
75
			CIRCollector circ = new CIRCollector();
76
			agg.visitContainedRecords(circ);
76
			agg.visitContainedRecords(circ);
77
            return circ._list.toArray(new ColumnInfoRecord[circ._list.size()]);
77
            return circ._list.toArray(new ColumnInfoRecord[0]);
78
		}
78
		}
79
	}
79
	}
80
80
(-)src/java/org/apache/poi/hssf/record/GroupMarkerSubRecord.java (-2 / +1 lines)
Lines 77-84 Link Here
77
    public GroupMarkerSubRecord clone() {
77
    public GroupMarkerSubRecord clone() {
78
        GroupMarkerSubRecord rec = new GroupMarkerSubRecord();
78
        GroupMarkerSubRecord rec = new GroupMarkerSubRecord();
79
        rec.reserved = new byte[reserved.length];
79
        rec.reserved = new byte[reserved.length];
80
        for ( int i = 0; i < reserved.length; i++ )
80
        System.arraycopy(reserved, 0, rec.reserved, 0, reserved.length);
81
            rec.reserved[i] = reserved[i];
82
        return rec;
81
        return rec;
83
    }
82
    }
84
}
83
}
(-)src/java/org/apache/poi/hssf/record/HyperlinkRecord.java (-3 / +1 lines)
Lines 159-167 Link Here
159
			int d0 = (parseShort(cc, 0) << 16) + (parseShort(cc, 4) << 0);
159
			int d0 = (parseShort(cc, 0) << 16) + (parseShort(cc, 4) << 0);
160
			int d1 = parseShort(cc, 9);
160
			int d1 = parseShort(cc, 9);
161
			int d2 = parseShort(cc, 14);
161
			int d2 = parseShort(cc, 14);
162
			for (int i = 23; i > 19; i--) {
162
            System.arraycopy(cc, 19, cc, 20, 4);
163
				cc[i] = cc[i - 1];
164
			}
165
			long d3 = parseLELong(cc, 20);
163
			long d3 = parseLELong(cc, 20);
166
164
167
			return new GUID(d0, d1, d2, d3);
165
			return new GUID(d0, d1, d2, d3);
(-)src/java/org/apache/poi/poifs/filesystem/POIFSDocumentPath.java (-4 / +1 lines)
Lines 122-131 Link Here
122
            this.components =
122
            this.components =
123
                new String[ path.components.length + components.length ];
123
                new String[ path.components.length + components.length ];
124
        }
124
        }
125
        for (int j = 0; j < path.components.length; j++)
125
        System.arraycopy(path.components, 0, this.components, 0, path.components.length);
126
        {
127
            this.components[ j ] = path.components[ j ];
128
        }
129
        if (components != null)
126
        if (components != null)
130
        {
127
        {
131
            for (int j = 0; j < components.length; j++)
128
            for (int j = 0; j < components.length; j++)
(-)src/java/org/apache/poi/ss/formula/functions/Trend.java (-3 / +1 lines)
Lines 149-157 Link Here
149
        }
149
        }
150
        double[] oneD = new double[twoD.length * twoD[0].length];
150
        double[] oneD = new double[twoD.length * twoD[0].length];
151
        for (int i = 0; i < twoD.length; i++) {
151
        for (int i = 0; i < twoD.length; i++) {
152
            for (int j = 0; j < twoD[0].length; j++) {
152
            System.arraycopy(twoD[i], 0, oneD, i * twoD[0].length + 0, twoD[0].length);
153
                oneD[i * twoD[0].length + j] = twoD[i][j];
154
            }
155
        }
153
        }
156
        return oneD;
154
        return oneD;
157
    }
155
    }
(-)src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/RelationshipTransformService.java (-3 / +1 lines)
Lines 125-133 Link Here
125
            throw new InvalidAlgorithmParameterException();
125
            throw new InvalidAlgorithmParameterException();
126
        }
126
        }
127
        RelationshipTransformParameterSpec relParams = (RelationshipTransformParameterSpec) params;
127
        RelationshipTransformParameterSpec relParams = (RelationshipTransformParameterSpec) params;
128
        for (String sourceId : relParams.sourceIds) {
128
        this.sourceIds.addAll(relParams.sourceIds);
129
            this.sourceIds.add(sourceId);
130
        }
131
    }
129
    }
132
130
133
    @Override
131
    @Override
(-)src/ooxml/java/org/apache/poi/xssf/binary/XSSFBSheetHandler.java (-3 / +1 lines)
Lines 312-320 Link Here
312
        b0 &= ~(1<<1);
312
        b0 &= ~(1<<1);
313
313
314
        rkBuffer[4] = b0;
314
        rkBuffer[4] = b0;
315
        for (int i = 1; i < 4; i++) {
315
        System.arraycopy(data, offset + 1, rkBuffer, 5, 3);
316
            rkBuffer[i+4] = data[offset+i];
317
        }
318
        double d = 0.0;
316
        double d = 0.0;
319
        if (floatingPoint) {
317
        if (floatingPoint) {
320
            d = LittleEndian.getDouble(rkBuffer);
318
            d = LittleEndian.getDouble(rkBuffer);
(-)src/testcases/org/apache/poi/poifs/filesystem/TestPOIFSDocumentPath.java (-12 / +3 lines)
Lines 49-58 Link Here
49
        {
49
        {
50
            String[] params = new String[ j ];
50
            String[] params = new String[ j ];
51
51
52
            for (int k = 0; k < j; k++)
52
            System.arraycopy(components, 0, params, 0, j);
53
            {
54
                params[ k ] = components[ k ];
55
            }
56
            POIFSDocumentPath path = new POIFSDocumentPath(params);
53
            POIFSDocumentPath path = new POIFSDocumentPath(params);
57
54
58
            assertEquals(j, path.length());
55
            assertEquals(j, path.length());
Lines 116-125 Link Here
116
        {
113
        {
117
            String[] initialParams = new String[ n ];
114
            String[] initialParams = new String[ n ];
118
115
119
            for (int k = 0; k < n; k++)
116
            System.arraycopy(initialComponents, 0, initialParams, 0, n);
120
            {
121
                initialParams[ k ] = initialComponents[ k ];
122
            }
123
            POIFSDocumentPath base       =
117
            POIFSDocumentPath base       =
124
                new POIFSDocumentPath(initialParams);
118
                new POIFSDocumentPath(initialParams);
125
            String[]          components =
119
            String[]          components =
Lines 131-140 Link Here
131
            {
125
            {
132
                String[] params = new String[ j ];
126
                String[] params = new String[ j ];
133
127
134
                for (int k = 0; k < j; k++)
128
                System.arraycopy(components, 0, params, 0, j);
135
                {
136
                    params[ k ] = components[ k ];
137
                }
138
                POIFSDocumentPath path = new POIFSDocumentPath(base, params);
129
                POIFSDocumentPath path = new POIFSDocumentPath(base, params);
139
130
140
                assertEquals(j + n, path.length());
131
                assertEquals(j + n, path.length());
(-)src/java/org/apache/poi/hssf/eventusermodel/EventWorkbookBuilder.java (-8 / +5 lines)
Lines 17-22 Link Here
17
package org.apache.poi.hssf.eventusermodel;
17
package org.apache.poi.hssf.eventusermodel;
18
18
19
import java.util.ArrayList;
19
import java.util.ArrayList;
20
import java.util.Collections;
20
import java.util.List;
21
import java.util.List;
21
22
22
import org.apache.poi.hssf.model.HSSFFormulaParser;
23
import org.apache.poi.hssf.model.HSSFFormulaParser;
Lines 69-77 Link Here
69
70
70
		// Core Workbook records go first
71
		// Core Workbook records go first
71
		if(bounds != null) {
72
		if(bounds != null) {
72
			for (BoundSheetRecord bound : bounds) {
73
			Collections.addAll(wbRecords, bounds);
73
				wbRecords.add(bound);
74
			}
75
		}
74
		}
76
		if(sst != null) {
75
		if(sst != null) {
77
			wbRecords.add(sst);
76
			wbRecords.add(sst);
Lines 82-90 Link Here
82
		if(externs != null) {
81
		if(externs != null) {
83
			wbRecords.add(SupBookRecord.createInternalReferences(
82
			wbRecords.add(SupBookRecord.createInternalReferences(
84
					(short)externs.length));
83
					(short)externs.length));
85
			for (ExternSheetRecord extern : externs) {
84
			Collections.addAll(wbRecords, externs);
86
				wbRecords.add(extern);
87
			}
88
		}
85
		}
89
86
90
		// Finally we need an EoF record
87
		// Finally we need an EoF record
Lines 125-136 Link Here
125
122
126
		public BoundSheetRecord[] getBoundSheetRecords() {
123
		public BoundSheetRecord[] getBoundSheetRecords() {
127
			return boundSheetRecords.toArray(
124
			return boundSheetRecords.toArray(
128
					new BoundSheetRecord[boundSheetRecords.size()]
125
					new BoundSheetRecord[0]
129
			);
126
			);
130
		}
127
		}
131
		public ExternSheetRecord[] getExternSheetRecords() {
128
		public ExternSheetRecord[] getExternSheetRecords() {
132
			return externSheetRecords.toArray(
129
			return externSheetRecords.toArray(
133
					new ExternSheetRecord[externSheetRecords.size()]
130
					new ExternSheetRecord[0]
134
			);
131
			);
135
		}
132
		}
136
		public SSTRecord getSSTRecord() {
133
		public SSTRecord getSSTRecord() {
(-)src/java/org/apache/poi/hssf/eventusermodel/HSSFRequest.java (-5 / +2 lines)
Lines 55-66 Link Here
55
	 *        for example req.addListener(myListener, BOFRecord.sid)
55
	 *        for example req.addListener(myListener, BOFRecord.sid)
56
	 */
56
	 */
57
	public void addListener(HSSFListener lsnr, short sid) {
57
	public void addListener(HSSFListener lsnr, short sid) {
58
		List<HSSFListener> list = _records.get(Short.valueOf(sid));
58
		List<HSSFListener> list = _records.computeIfAbsent(Short.valueOf(sid), k -> new ArrayList<>(1));
59
59
60
		if (list == null) {
60
		// probably most people will use one listener
61
			list = new ArrayList<>(1); // probably most people will use one listener
62
			_records.put(Short.valueOf(sid), list);
63
		}
64
		list.add(lsnr);
61
		list.add(lsnr);
65
	}
62
	}
66
63
(-)src/java/org/apache/poi/hssf/record/PaletteRecord.java (-3 / +2 lines)
Lines 18-23 Link Here
18
package org.apache.poi.hssf.record;
18
package org.apache.poi.hssf.record;
19
19
20
import java.util.ArrayList;
20
import java.util.ArrayList;
21
import java.util.Collections;
21
import java.util.List;
22
import java.util.List;
22
23
23
import org.apache.poi.util.LittleEndianOutput;
24
import org.apache.poi.util.LittleEndianOutput;
Lines 40-48 Link Here
40
    public PaletteRecord() {
41
    public PaletteRecord() {
41
      PColor[] defaultPalette = createDefaultPalette();
42
      PColor[] defaultPalette = createDefaultPalette();
42
      _colors    = new ArrayList<>(defaultPalette.length);
43
      _colors    = new ArrayList<>(defaultPalette.length);
43
      for (PColor element : defaultPalette) {
44
      Collections.addAll(_colors, defaultPalette);
44
        _colors.add(element);
45
      }
46
    }
45
    }
47
46
48
    public PaletteRecord(RecordInputStream in) {
47
    public PaletteRecord(RecordInputStream in) {
(-)src/java/org/apache/poi/ss/format/CellFormat.java (-5 / +1 lines)
Lines 154-164 Link Here
154
     * @return A {@link CellFormat} that applies the given format.
154
     * @return A {@link CellFormat} that applies the given format.
155
     */
155
     */
156
    public static synchronized CellFormat getInstance(Locale locale, String format) {
156
    public static synchronized CellFormat getInstance(Locale locale, String format) {
157
        Map<String, CellFormat> formatMap = formatCache.get(locale);
157
        Map<String, CellFormat> formatMap = formatCache.computeIfAbsent(locale, k -> new WeakHashMap<>());
158
        if (formatMap == null) {
159
            formatMap = new WeakHashMap<>();
160
            formatCache.put(locale, formatMap);
161
        }
162
        CellFormat fmt = formatMap.get(format);
158
        CellFormat fmt = formatMap.get(format);
163
        if (fmt == null) {
159
        if (fmt == null) {
164
            if (format.equals("General") || format.equals("@"))
160
            if (format.equals("General") || format.equals("@"))
(-)src/java/org/apache/poi/ss/formula/FormulaCellCacheEntry.java (-4 / +3 lines)
Lines 17-22 Link Here
17
17
18
package org.apache.poi.ss.formula;
18
package org.apache.poi.ss.formula;
19
19
20
import java.util.Arrays;
20
import java.util.Collections;
21
import java.util.Collections;
21
import java.util.HashSet;
22
import java.util.HashSet;
22
import java.util.Set;
23
import java.util.Set;
Lines 94-102 Link Here
94
			usedSet = Collections.emptySet();
95
			usedSet = Collections.emptySet();
95
		} else {
96
		} else {
96
			usedSet = new HashSet<>(nUsed * 3 / 2);
97
			usedSet = new HashSet<>(nUsed * 3 / 2);
97
			for (int i = 0; i < nUsed; i++) {
98
			usedSet.addAll(Arrays.asList(usedCells).subList(0, nUsed));
98
				usedSet.add(usedCells[i]);
99
			}
100
		}
99
		}
101
		for (int i = 0; i < nPrevUsed; i++) {
100
		for (int i = 0; i < nPrevUsed; i++) {
102
			CellCacheEntry prevUsed = prevUsedCells[i];
101
			CellCacheEntry prevUsed = prevUsedCells[i];
Lines 121-124 Link Here
121
			}
120
			}
122
		}
121
		}
123
	}
122
	}
124
}
123
}
(-)src/java/org/apache/poi/ss/util/CellRangeUtil.java (-3 / +2 lines)
Lines 18-23 Link Here
18
package org.apache.poi.ss.util;
18
package org.apache.poi.ss.util;
19
19
20
import java.util.ArrayList;
20
import java.util.ArrayList;
21
import java.util.Collections;
21
import java.util.List;
22
import java.util.List;
22
23
23
/**
24
/**
Lines 173-181 Link Here
173
    }
174
    }
174
    private static List<CellRangeAddress> toList(CellRangeAddress[] temp) {
175
    private static List<CellRangeAddress> toList(CellRangeAddress[] temp) {
175
        List<CellRangeAddress> result = new ArrayList<>(temp.length);
176
        List<CellRangeAddress> result = new ArrayList<>(temp.length);
176
        for (CellRangeAddress range : temp) {
177
        Collections.addAll(result, temp);
177
            result.add(range);
178
        }
179
        return result;
178
        return result;
180
    }
179
    }
181
180
(-)src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java (-1 / +2 lines)
Lines 23-28 Link Here
23
import java.util.Deque;
23
import java.util.Deque;
24
import java.util.LinkedList;
24
import java.util.LinkedList;
25
import java.util.List;
25
import java.util.List;
26
import java.util.Objects;
26
27
27
import javax.xml.parsers.DocumentBuilder;
28
import javax.xml.parsers.DocumentBuilder;
28
import javax.xml.parsers.ParserConfigurationException;
29
import javax.xml.parsers.ParserConfigurationException;
Lines 200-206 Link Here
200
        Triplet triplet = getCharacterRunTriplet( characterRun );
201
        Triplet triplet = getCharacterRunTriplet( characterRun );
201
202
202
        if ( AbstractWordUtils.isNotEmpty( triplet.fontName )
203
        if ( AbstractWordUtils.isNotEmpty( triplet.fontName )
203
                && !AbstractWordUtils.equals( triplet.fontName,
204
                && !Objects.equals( triplet.fontName,
204
                        blockProperies.pFontName ) )
205
                        blockProperies.pFontName ) )
205
        {
206
        {
206
            style.append("font-family:").append(triplet.fontName).append(";");
207
            style.append("font-family:").append(triplet.fontName).append(";");
(-)src/scratchpad/src/org/apache/poi/hwpf/usermodel/BookmarksImpl.java (-6 / +1 lines)
Lines 231-242 Link Here
231
            GenericPropertyNode property = bookmarksTables
231
            GenericPropertyNode property = bookmarksTables
232
                    .getDescriptorFirst( b );
232
                    .getDescriptorFirst( b );
233
            Integer positionKey = Integer.valueOf( property.getStart() );
233
            Integer positionKey = Integer.valueOf( property.getStart() );
234
            List<GenericPropertyNode> atPositionList = result.get( positionKey );
234
            List<GenericPropertyNode> atPositionList = result.computeIfAbsent(positionKey, k -> new LinkedList<>());
235
            if ( atPositionList == null )
236
            {
237
                atPositionList = new LinkedList<>();
238
                result.put( positionKey, atPositionList );
239
            }
240
            atPositionList.add( property );
235
            atPositionList.add( property );
241
        }
236
        }
242
237
(-).project (-1 / +7 lines)
Lines 1-10 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
2
<projectDescription>
3
	<name>ApachePOI</name>
3
	<name>poi</name>
4
	<comment></comment>
4
	<comment></comment>
5
	<projects>
5
	<projects>
6
	</projects>
6
	</projects>
7
	<buildSpec>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
8
		<buildCommand>
13
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
14
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
15
			<arguments>
Lines 14-18 Link Here
14
	<natures>
19
	<natures>
15
		<nature>org.sonar.ide.eclipse.core.sonarNature</nature>
20
		<nature>org.sonar.ide.eclipse.core.sonarNature</nature>
16
		<nature>org.eclipse.jdt.core.javanature</nature>
21
		<nature>org.eclipse.jdt.core.javanature</nature>
22
		<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
17
	</natures>
23
	</natures>
18
</projectDescription>
24
</projectDescription>
(-)src/java/org/apache/poi/ddf/EscherDggRecord.java (-1 / +1 lines)
Lines 219-225 Link Here
219
     * @return the file id clusters
219
     * @return the file id clusters
220
     */
220
     */
221
    public FileIdCluster[] getFileIdClusters() {
221
    public FileIdCluster[] getFileIdClusters() {
222
        return field_5_fileIdClusters.toArray(new FileIdCluster[field_5_fileIdClusters.size()]);
222
        return field_5_fileIdClusters.toArray(new FileIdCluster[0]);
223
    }
223
    }
224
224
225
    /**
225
    /**
(-)src/java/org/apache/poi/hpsf/Vector.java (-1 / +1 lines)
Lines 58-64 Link Here
58
            }
58
            }
59
            values.add(value);
59
            values.add(value);
60
        }
60
        }
61
        _values = values.toArray(new TypedPropertyValue[values.size()]);
61
        _values = values.toArray(new TypedPropertyValue[0]);
62
    }
62
    }
63
63
64
    public TypedPropertyValue[] getValues(){
64
    public TypedPropertyValue[] getValues(){
(-)src/java/org/apache/poi/hssf/record/ExtSSTRecord.java (-1 / +1 lines)
Lines 103-109 Link Here
103
                in.nextRecord();
103
                in.nextRecord();
104
            }
104
            }
105
        }
105
        }
106
        _sstInfos = lst.toArray(new InfoSubRecord[lst.size()]);
106
        _sstInfos = lst.toArray(new InfoSubRecord[0]);
107
    }
107
    }
108
108
109
    public void setNumStringsPerBucket(short numStrings) {
109
    public void setNumStringsPerBucket(short numStrings) {
(-)src/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java (-2 / +2 lines)
Lines 195-201 Link Here
195
        int startIndex = block * DBCellRecord.BLOCK_SIZE;
195
        int startIndex = block * DBCellRecord.BLOCK_SIZE;
196
196
197
        if (_rowRecordValues == null) {
197
        if (_rowRecordValues == null) {
198
            _rowRecordValues = _rowRecords.values().toArray(new RowRecord[_rowRecords.size()]);
198
            _rowRecordValues = _rowRecords.values().toArray(new RowRecord[0]);
199
        }
199
        }
200
200
201
        try {
201
        try {
Lines 212-218 Link Here
212
            endIndex = _rowRecords.size()-1;
212
            endIndex = _rowRecords.size()-1;
213
213
214
        if (_rowRecordValues == null){
214
        if (_rowRecordValues == null){
215
            _rowRecordValues = _rowRecords.values().toArray(new RowRecord[_rowRecords.size()]);
215
            _rowRecordValues = _rowRecords.values().toArray(new RowRecord[0]);
216
        }
216
        }
217
217
218
        try {
218
        try {
(-)src/java/org/apache/poi/hssf/usermodel/HSSFChart.java (-3 / +3 lines)
Lines 273-279 Link Here
273
			}
273
			}
274
		}
274
		}
275
275
276
		return charts.toArray( new HSSFChart[charts.size()] );
276
		return charts.toArray(new HSSFChart[0]);
277
	}
277
	}
278
278
279
	/** Get the X offset of the chart */
279
	/** Get the X offset of the chart */
Lines 298-304 Link Here
298
	 * Returns the series of the chart
298
	 * Returns the series of the chart
299
	 */
299
	 */
300
	public HSSFSeries[] getSeries() {
300
	public HSSFSeries[] getSeries() {
301
		return series.toArray(new HSSFSeries[series.size()]);
301
		return series.toArray(new HSSFSeries[0]);
302
	}
302
	}
303
303
304
	/**
304
	/**
Lines 1153-1159 Link Here
1153
				}
1153
				}
1154
			}
1154
			}
1155
			
1155
			
1156
			linkedDataRecord.setFormulaOfLink(ptgList.toArray(new Ptg[ptgList.size()]));
1156
			linkedDataRecord.setFormulaOfLink(ptgList.toArray(new Ptg[0]));
1157
			
1157
			
1158
			return rowCount * colCount;
1158
			return rowCount * colCount;
1159
		}
1159
		}
(-)src/java/org/apache/poi/ss/formula/CollaboratingWorkbooksEnvironment.java (-1 / +1 lines)
Lines 71-77 Link Here
71
            throw new IllegalArgumentException("Must provide at least one collaborating worbook");
71
            throw new IllegalArgumentException("Must provide at least one collaborating worbook");
72
        }
72
        }
73
        WorkbookEvaluator[] evaluators = 
73
        WorkbookEvaluator[] evaluators = 
74
                evaluatorsByName.values().toArray(new WorkbookEvaluator[evaluatorsByName.size()]); 
74
                evaluatorsByName.values().toArray(new WorkbookEvaluator[0]); 
75
        new CollaboratingWorkbooksEnvironment(evaluatorsByName, evaluators);
75
        new CollaboratingWorkbooksEnvironment(evaluatorsByName, evaluators);
76
    }
76
    }
77
    public static void setupFormulaEvaluator(Map<String,FormulaEvaluator> evaluators) {
77
    public static void setupFormulaEvaluator(Map<String,FormulaEvaluator> evaluators) {
(-)src/java/org/apache/poi/ss/formula/functions/Subtotal.java (-1 / +1 lines)
Lines 141-146 Link Here
141
			}
141
			}
142
		}
142
		}
143
143
144
		return innerFunc.evaluate(list.toArray(new ValueEval[list.size()]), srcRowIndex, srcColumnIndex);
144
		return innerFunc.evaluate(list.toArray(new ValueEval[0]), srcRowIndex, srcColumnIndex);
145
	}
145
	}
146
}
146
}
(-)src/java/org/apache/poi/util/HexRead.java (-1 / +1 lines)
Lines 125-131 Link Here
125
                }
125
                }
126
            }
126
            }
127
        }
127
        }
128
        Byte[] polished = bytes.toArray(new Byte[bytes.size()]);
128
        Byte[] polished = bytes.toArray(new Byte[0]);
129
        byte[] rval = new byte[polished.length];
129
        byte[] rval = new byte[polished.length];
130
        for ( int j = 0; j < polished.length; j++ ) {
130
        for ( int j = 0; j < polished.length; j++ ) {
131
            rval[j] = polished[j].byteValue();
131
            rval[j] = polished[j].byteValue();

Return to bug 63805