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

(-)poi-3.9/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java (-1 / +45 lines)
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 ThreadLocal<Short> lastDateFormat = new ThreadLocal<Short>() {
115
      @Override
116
      protected Short initialValue() {
117
         return Short.MIN_VALUE;
118
      }
119
    };
120
    
121
    private static ThreadLocal<List<FormatRecord>> lastFormats = new ThreadLocal<List<FormatRecord>>() {
122
      @Override
123
      protected List<FormatRecord> initialValue() {
124
         return null;
125
      }
126
    };
127
128
    private static ThreadLocal<String> getDataFormatStringCache = new ThreadLocal<String>() {
129
      @Override
130
      protected String initialValue() {
131
         return null;
132
      }
133
    };
134
109
    public String getDataFormatString() {
135
    public String getDataFormatString() {
110
        return getDataFormatString(_workbook);
136
      if (getDataFormatStringCache.get() != null) {
137
         if (lastDateFormat.get() == getDataFormat() && _workbook.getFormats().equals(lastFormats.get())) {
138
            return getDataFormatStringCache.get();
139
         }
140
      }
141
      
142
      lastFormats.set(_workbook.getFormats());
143
      lastDateFormat.set(getDataFormat());
144
      
145
      getDataFormatStringCache.set(getDataFormatString(_workbook));
146
      
147
      return getDataFormatStringCache.get();
148
111
    }
149
    }
112
    /**
150
    /**
113
     * Get the contents of the format string, by looking up
151
     * Get the contents of the format string, by looking up
Lines 828-833 public final class HSSFCellStyle impleme Link Here
828
866
829
    	// Handle matching things if we cross workbooks
867
    	// Handle matching things if we cross workbooks
830
    	if(_workbook != source._workbook) {
868
    	if(_workbook != source._workbook) {
869
    	
870
    	   lastDateFormat.set(Short.MIN_VALUE);
871
           lastFormats.set(null);
872
           getDataFormatStringCache.set(null);
873
    	   
831
			// Then we need to clone the format string,
874
			// Then we need to clone the format string,
832
			//  and update the format record for this
875
			//  and update the format record for this
833
    		short fmt = (short)_workbook.createFormat(source.getDataFormatString() );
876
    		short fmt = (short)_workbook.createFormat(source.getDataFormatString() );
Lines 874-877 public final class HSSFCellStyle impleme Link Here
874
		}
917
		}
875
		return false;
918
		return false;
876
	}
919
	}
920
	
877
}
921
}

Return to bug 55612