Ejemplo n.º 1
0
  public static Ptg createDeletedRef(Ptg ptg) {
    if (ptg instanceof RefPtg) {
      return new RefErrorPtg();
    }
    if (ptg instanceof Ref3DPtg) {
      Ref3DPtg rptg = (Ref3DPtg) ptg;
      return new DeletedRef3DPtg(rptg.getExternSheetIndex());
    }
    if (ptg instanceof AreaPtg) {
      return new AreaErrPtg();
    }
    if (ptg instanceof Area3DPtg) {
      Area3DPtg area3DPtg = (Area3DPtg) ptg;
      return new DeletedArea3DPtg(area3DPtg.getExternSheetIndex());
    }

    throw new IllegalArgumentException(
        "Unexpected ref ptg class (" + ptg.getClass().getName() + ")");
  }
Ejemplo n.º 2
0
 private Ptg adjustPtg(Ptg ptg, int currentExternSheetIx) {
   if (_rowAmount == 0 && _colAmount == 0) {
     return null;
   }
   if (ptg instanceof RefPtg) {
     if (currentExternSheetIx != _externSheetIndex) {
       // local refs on other sheets are unaffected
       return null;
     }
     final RefPtg rptg = (RefPtg) ptg;
     if (_rowAmount != 0 && _colAmount != 0) {
       return bothMoveRefPtg(rptg);
     } else if (_rowAmount != 0) {
       return rowMoveRefPtg(rptg);
     } else {
       return colMoveRefPtg(rptg);
     }
   }
   if (ptg instanceof Ref3DPtg) {
     final Ref3DPtg rptg = (Ref3DPtg) ptg;
     if (_externSheetIndex != rptg.getExternSheetIndex()) {
       // only move 3D refs that refer to the sheet with cells being moved
       // (currentExternSheetIx is irrelevant)
       return null;
     }
     if (_rowAmount != 0 && _colAmount != 0) {
       return bothMoveRefPtg(rptg);
     } else if (_rowAmount != 0) {
       return rowMoveRefPtg(rptg);
     } else {
       return colMoveRefPtg(rptg);
     }
   }
   if (ptg instanceof Area2DPtgBase) {
     if (currentExternSheetIx != _externSheetIndex) {
       // local refs on other sheets are unaffected
       return null;
     }
     final Area2DPtgBase aptg = (Area2DPtgBase) ptg;
     if (_rowAmount != 0 && _colAmount != 0) {
       return bothMoveAreaPtg(aptg);
     } else if (_rowAmount != 0) {
       return rowMoveAreaPtg(aptg);
     } else {
       return colMoveAreaPtg(aptg);
     }
   }
   if (ptg instanceof Area3DPtg) {
     final Area3DPtg aptg = (Area3DPtg) ptg;
     if (_externSheetIndex != aptg.getExternSheetIndex()) {
       // only move 3D refs that refer to the sheet with cells being moved
       // (currentExternSheetIx is irrelevant)
       return null;
     }
     if (_rowAmount != 0 && _colAmount != 0) {
       return bothMoveAreaPtg(aptg);
     } else if (_rowAmount != 0) {
       return rowMoveAreaPtg(aptg);
     } else {
       return colMoveAreaPtg(aptg);
     }
   }
   return null;
 }