/* PivotTableHelper.java

	Purpose:
		
	Description:
		
	History:
		May 17, 2012 12:33:05 PM, Created by henri

Copyright (C) 2012 Potix Corporation. All Rights Reserved.
*/
package org.zkoss.poi.hssf.usermodel;

import java.lang.reflect.Field;

import org.zkoss.poi.xssf.usermodel.XSSFPivotCache;
import org.zkoss.poi.xssf.usermodel.XSSFPivotCacheRecords;
import org.zkoss.poi.xssf.usermodel.XSSFPivotTable;
import org.zkoss.poi.xssf.usermodel.XSSFRelation;
import org.zkoss.zpoiex.util.Classes;

/**
 * @author henri
 *
 */
public class PivotTableHelper {
	
	static {
		Field fd = null;
		try {
			fd = Classes.getAnyField(XSSFRelation.class, "_cls");
		} catch (NoSuchFieldException e) {
			throw new RuntimeException(e);
		}
		final boolean old = fd.isAccessible();
		try {
			fd.setAccessible(true);
			fd.set(XSSFRelation.PIVOT_TABLE, XSSFPivotTable.class);
			fd.set(XSSFRelation.PIVOT_CACHE_DEFINITION, XSSFPivotCache.class);
			fd.set(XSSFRelation.PIVOT_CACHE_RECORDS, XSSFPivotCacheRecords.class);
		} catch (IllegalAccessException e) {
			throw new RuntimeException(e);
		} finally {
			fd.setAccessible(old);
		}
	}
}
