/** sets the reference , the area only (range)
* @param ref area reference
*/
public void setAreaReference(String ref){
//Trying to find if what ptg do we need
RangeAddress ra = new RangeAddress(ref);
Ptg oldPtg;
if (field_13_name_definition.length < 1){
oldPtg = createNewPtg();
} else {
//Trying to find extern sheet index
oldPtg = field_13_name_definition[0];
}
List temp = new ArrayList();
int externSheetIndex = 0;
if (oldPtg.getClass() == Area3DPtg.class){
externSheetIndex = ((Area3DPtg) oldPtg).getExternSheetIndex();
} else if (oldPtg.getClass() == Ref3DPtg.class){
externSheetIndex = ((Ref3DPtg) oldPtg).getExternSheetIndex();
}
if (ra.hasRange()) {
// Is it contiguous or not?
AreaReference[] refs = AreaReference.generateContiguous(ref);
// Add the area reference(s)
for(int i=0; i<refs.length; i++) {
Ptg ptg = new Area3DPtg(refs[i].formatAsString(), externSheetIndex);
temp.add(ptg);
}
// And then a union if we had more than one area
if(refs.length > 1) {
Ptg ptg = UnionPtg.instance;
temp.add(ptg);
}
} else {
Ref3DPtg ptg = new Ref3DPtg(ra.getFromCell(), externSheetIndex);
temp.add(ptg);
}
Ptg[] ptgs = new Ptg[temp.size()];
temp.toArray(ptgs);
field_13_name_definition = ptgs;