Lines 18-26
Link Here
|
18 |
|
18 |
|
19 |
package org.apache.poi.hssf.usermodel; |
19 |
package org.apache.poi.hssf.usermodel; |
20 |
|
20 |
|
|
|
21 |
import java.util.Arrays; |
22 |
import java.util.List; |
23 |
|
21 |
import org.apache.poi.hssf.model.InternalWorkbook; |
24 |
import org.apache.poi.hssf.model.InternalWorkbook; |
22 |
import org.apache.poi.hssf.record.ExtendedFormatRecord; |
25 |
import org.apache.poi.hssf.record.ExtendedFormatRecord; |
23 |
import org.apache.poi.hssf.record.FontRecord; |
26 |
import org.apache.poi.hssf.record.FontRecord; |
|
|
27 |
import org.apache.poi.hssf.record.FormatRecord; |
24 |
import org.apache.poi.hssf.record.StyleRecord; |
28 |
import org.apache.poi.hssf.record.StyleRecord; |
25 |
import org.apache.poi.hssf.util.HSSFColor; |
29 |
import org.apache.poi.hssf.util.HSSFColor; |
26 |
import org.apache.poi.ss.usermodel.CellStyle; |
30 |
import org.apache.poi.ss.usermodel.CellStyle; |
Lines 106-113
public final class HSSFCellStyle impleme
Link Here
|
106 |
* @see org.apache.poi.hssf.usermodel.HSSFDataFormat |
110 |
* @see org.apache.poi.hssf.usermodel.HSSFDataFormat |
107 |
* @return the format string or "General" if not found |
111 |
* @return the format string or "General" if not found |
108 |
*/ |
112 |
*/ |
|
|
113 |
|
114 |
private static short lastDateFormat = Short.MIN_VALUE; |
115 |
private static List<FormatRecord> lastFormats = null; |
116 |
private static String getDataFormatStringCache = null; |
117 |
|
118 |
private static final Object cacheLock = new Object(); |
119 |
|
109 |
public String getDataFormatString() { |
120 |
public String getDataFormatString() { |
110 |
return getDataFormatString(_workbook); |
121 |
synchronized (cacheLock) { |
|
|
122 |
if (getDataFormatStringCache != null) { |
123 |
if (lastDateFormat == getDataFormat() && _workbook.getFormats().equals(lastFormats)) { |
124 |
return getDataFormatStringCache; |
125 |
} |
126 |
} |
127 |
|
128 |
lastFormats = _workbook.getFormats(); |
129 |
lastDateFormat = getDataFormat(); |
130 |
|
131 |
getDataFormatStringCache = getDataFormatString(_workbook); |
132 |
|
133 |
return getDataFormatStringCache; |
134 |
} |
111 |
} |
135 |
} |
112 |
/** |
136 |
/** |
113 |
* Get the contents of the format string, by looking up |
137 |
* Get the contents of the format string, by looking up |
Lines 828-833
public final class HSSFCellStyle impleme
Link Here
|
828 |
|
852 |
|
829 |
// Handle matching things if we cross workbooks |
853 |
// Handle matching things if we cross workbooks |
830 |
if(_workbook != source._workbook) { |
854 |
if(_workbook != source._workbook) { |
|
|
855 |
|
856 |
synchronized (cacheLock) { |
857 |
lastDateFormat = Short.MIN_VALUE; |
858 |
lastFormats = null; |
859 |
getDataFormatStringCache = null; |
860 |
} |
861 |
|
831 |
// Then we need to clone the format string, |
862 |
// Then we need to clone the format string, |
832 |
// and update the format record for this |
863 |
// and update the format record for this |
833 |
short fmt = (short)_workbook.createFormat(source.getDataFormatString() ); |
864 |
short fmt = (short)_workbook.createFormat(source.getDataFormatString() ); |
Lines 874-877
public final class HSSFCellStyle impleme
Link Here
|
874 |
} |
905 |
} |
875 |
return false; |
906 |
return false; |
876 |
} |
907 |
} |
|
|
908 |
|
877 |
} |
909 |
} |