@Test public void applyAtToAnotherSheet() throws Exception { XlsArea xlsArea = new XlsArea(new CellRef("sheet1!A1"), new CellRef("sheet1!G10"), transformer); Context context = new Context(); Size size = xlsArea.applyAt(new CellRef("sheet2!B2"), context); assertEquals("Width is wrong", 7, size.getWidth()); assertEquals("Height is wrong", 10, size.getHeight()); verify(transformer).transform(new CellRef("sheet1!A1"), new CellRef("sheet2!B2"), context, false); verify(transformer).transform(new CellRef("sheet1!D2"), new CellRef("sheet2!E3"), context, false); }
@Override public Size applyAt(CellRef cellRef, Context context) { if (this == XlsArea.EMPTY_AREA) { return Size.ZERO_SIZE; } logger.debug("Applying XlsArea at {}", cellRef); fireBeforeApplyEvent(cellRef, context); createCellRange(); AreaRef commandsArea = transformTopStaticArea(cellRef, context); for (int i = 0; i < commandDataList.size(); i++) { cellRange.resetChangeMatrix(); CommandData commandData = commandDataList.get(i); String shiftMode = commandData.getCommand().getShiftMode(); CellShiftStrategy commandCellShiftStrategy = detectCellShiftStrategy(shiftMode); cellRange.setCellShiftStrategy(commandCellShiftStrategy); CellRef commandStartCellRef = commandData.getStartCellRef(); Size commandInitialSize = commandData.getSize(); int startCol = commandStartCellRef.getCol() - startCellRef.getCol(); int startRow = commandStartCellRef.getRow() - startCellRef.getRow(); CellRef newCell = new CellRef(cellRef.getSheetName(), startRow + cellRef.getRow(), startCol + cellRef.getCol()); Size commandNewSize = commandData.getCommand().applyAt(newCell, context); int widthChange = commandNewSize.getWidth() - commandInitialSize.getWidth(); int heightChange = commandNewSize.getHeight() - commandInitialSize.getHeight(); int endCol = startCol + commandInitialSize.getWidth() - 1; int endRow = startRow + commandInitialSize.getHeight() - 1; if (heightChange != 0) { cellRange.shiftCellsWithColBlock(startCol, endCol, endRow, heightChange, true); Set<CommandData> commandsToShift = findCommandsForVerticalShift(commandDataList.subList(i+1, commandDataList.size()), startCol, endCol, endRow, heightChange); for (CommandData commandDataToShift : commandsToShift) { CellRef commandDataStartCellRef = commandDataToShift.getStartCellRef(); int relativeRow = commandDataStartCellRef.getRow() - startCellRef.getRow(); int relativeStartCol = commandDataStartCellRef.getCol() - startCellRef.getCol(); int relativeEndCol = relativeStartCol + commandDataToShift.getSize().getWidth() - 1; cellRange.shiftCellsWithColBlock(relativeStartCol, relativeEndCol, relativeRow + commandDataToShift.getSize().getHeight() - 1, heightChange, false); commandDataToShift.setStartCellRef( new CellRef(commandStartCellRef.getSheetName(), commandDataStartCellRef.getRow() + heightChange, commandDataStartCellRef.getCol())); if (heightChange < 0) { CellRef initialStartCellRef = commandDataToShift.getSourceStartCellRef(); Size initialSize = commandDataToShift.getSourceSize(); int initialStartRow = initialStartCellRef.getRow() - startCellRef.getRow(); int initialEndRow = initialStartRow + initialSize.getHeight() - 1; int initialStartCol = initialStartCellRef.getCol() - startCellRef.getCol(); int initialEndCol = initialStartCol + initialSize.getWidth() - 1; cellRange.clearCells(initialStartCol, initialEndCol, initialStartRow, initialEndRow); } } } if (widthChange != 0) { cellRange.shiftCellsWithRowBlock(startRow, endRow, endCol, widthChange, true); Set<CommandData> commandsToShift = findCommandsForHorizontalShift( commandDataList.subList(i + 1, commandDataList.size()), startRow, endRow, endCol, widthChange); for (CommandData commandDataToShift : commandsToShift) { CellRef commandDataStartCellRef = commandDataToShift.getStartCellRef(); int relativeCol = commandDataStartCellRef.getCol() - startCellRef.getCol(); int relativeStartRow = commandDataStartCellRef.getRow() - startCellRef.getRow(); int relativeEndRow = relativeStartRow + commandDataToShift.getSize().getHeight() - 1; cellRange.shiftCellsWithRowBlock(relativeStartRow, relativeEndRow, relativeCol + commandDataToShift.getSize().getWidth() - 1, widthChange, false); commandDataToShift.setStartCellRef( new CellRef(commandStartCellRef.getSheetName(), commandDataStartCellRef.getRow(), commandDataStartCellRef.getCol() + widthChange)); if (widthChange < 0) { CellRef initialStartCellRef = commandDataToShift.getSourceStartCellRef(); Size initialSize = commandDataToShift.getSourceSize(); int initialStartRow = initialStartCellRef.getRow() - startCellRef.getRow(); int initialEndRow = initialStartRow + initialSize.getHeight() - 1; int initialStartCol = initialStartCellRef.getCol() - startCellRef.getCol(); int initialEndCol = initialStartCellRef.getCol() + initialSize.getWidth() - 1; cellRange.clearCells(initialStartCol, initialEndCol, initialStartRow, initialEndRow); } } } } transformStaticCells(cellRef, context, commandsArea); fireAfterApplyEvent(cellRef, context); Size finalSize = new Size(cellRange.calculateWidth(), cellRange.calculateHeight()); AreaRef newAreaRef = new AreaRef(cellRef, finalSize); updateCellDataFinalAreaForFormulaCells(newAreaRef); for (CommandData commandData : commandDataList) { commandData.resetStartCellAndSize(); } return finalSize; }
XlsArea implements Area { @Override public Size applyAt(CellRef cellRef, Context context) { if (this == XlsArea.EMPTY_AREA) { return Size.ZERO_SIZE; } logger.debug("Applying XlsArea at {}", cellRef); fireBeforeApplyEvent(cellRef, context); createCellRange(); AreaRef commandsArea = transformTopStaticArea(cellRef, context); for (int i = 0; i < commandDataList.size(); i++) { cellRange.resetChangeMatrix(); CommandData commandData = commandDataList.get(i); String shiftMode = commandData.getCommand().getShiftMode(); CellShiftStrategy commandCellShiftStrategy = detectCellShiftStrategy(shiftMode); cellRange.setCellShiftStrategy(commandCellShiftStrategy); CellRef commandStartCellRef = commandData.getStartCellRef(); Size commandInitialSize = commandData.getSize(); int startCol = commandStartCellRef.getCol() - startCellRef.getCol(); int startRow = commandStartCellRef.getRow() - startCellRef.getRow(); CellRef newCell = new CellRef(cellRef.getSheetName(), startRow + cellRef.getRow(), startCol + cellRef.getCol()); Size commandNewSize = commandData.getCommand().applyAt(newCell, context); int widthChange = commandNewSize.getWidth() - commandInitialSize.getWidth(); int heightChange = commandNewSize.getHeight() - commandInitialSize.getHeight(); int endCol = startCol + commandInitialSize.getWidth() - 1; int endRow = startRow + commandInitialSize.getHeight() - 1; if (heightChange != 0) { cellRange.shiftCellsWithColBlock(startCol, endCol, endRow, heightChange, true); Set<CommandData> commandsToShift = findCommandsForVerticalShift(commandDataList.subList(i+1, commandDataList.size()), startCol, endCol, endRow, heightChange); for (CommandData commandDataToShift : commandsToShift) { CellRef commandDataStartCellRef = commandDataToShift.getStartCellRef(); int relativeRow = commandDataStartCellRef.getRow() - startCellRef.getRow(); int relativeStartCol = commandDataStartCellRef.getCol() - startCellRef.getCol(); int relativeEndCol = relativeStartCol + commandDataToShift.getSize().getWidth() - 1; cellRange.shiftCellsWithColBlock(relativeStartCol, relativeEndCol, relativeRow + commandDataToShift.getSize().getHeight() - 1, heightChange, false); commandDataToShift.setStartCellRef( new CellRef(commandStartCellRef.getSheetName(), commandDataStartCellRef.getRow() + heightChange, commandDataStartCellRef.getCol())); if (heightChange < 0) { CellRef initialStartCellRef = commandDataToShift.getSourceStartCellRef(); Size initialSize = commandDataToShift.getSourceSize(); int initialStartRow = initialStartCellRef.getRow() - startCellRef.getRow(); int initialEndRow = initialStartRow + initialSize.getHeight() - 1; int initialStartCol = initialStartCellRef.getCol() - startCellRef.getCol(); int initialEndCol = initialStartCol + initialSize.getWidth() - 1; cellRange.clearCells(initialStartCol, initialEndCol, initialStartRow, initialEndRow); } } } if (widthChange != 0) { cellRange.shiftCellsWithRowBlock(startRow, endRow, endCol, widthChange, true); Set<CommandData> commandsToShift = findCommandsForHorizontalShift( commandDataList.subList(i + 1, commandDataList.size()), startRow, endRow, endCol, widthChange); for (CommandData commandDataToShift : commandsToShift) { CellRef commandDataStartCellRef = commandDataToShift.getStartCellRef(); int relativeCol = commandDataStartCellRef.getCol() - startCellRef.getCol(); int relativeStartRow = commandDataStartCellRef.getRow() - startCellRef.getRow(); int relativeEndRow = relativeStartRow + commandDataToShift.getSize().getHeight() - 1; cellRange.shiftCellsWithRowBlock(relativeStartRow, relativeEndRow, relativeCol + commandDataToShift.getSize().getWidth() - 1, widthChange, false); commandDataToShift.setStartCellRef( new CellRef(commandStartCellRef.getSheetName(), commandDataStartCellRef.getRow(), commandDataStartCellRef.getCol() + widthChange)); if (widthChange < 0) { CellRef initialStartCellRef = commandDataToShift.getSourceStartCellRef(); Size initialSize = commandDataToShift.getSourceSize(); int initialStartRow = initialStartCellRef.getRow() - startCellRef.getRow(); int initialEndRow = initialStartRow + initialSize.getHeight() - 1; int initialStartCol = initialStartCellRef.getCol() - startCellRef.getCol(); int initialEndCol = initialStartCellRef.getCol() + initialSize.getWidth() - 1; cellRange.clearCells(initialStartCol, initialEndCol, initialStartRow, initialEndRow); } } } } transformStaticCells(cellRef, context, commandsArea); fireAfterApplyEvent(cellRef, context); Size finalSize = new Size(cellRange.calculateWidth(), cellRange.calculateHeight()); AreaRef newAreaRef = new AreaRef(cellRef, finalSize); updateCellDataFinalAreaForFormulaCells(newAreaRef); for (CommandData commandData : commandDataList) { commandData.resetStartCellAndSize(); } return finalSize; } }
XlsArea implements Area { @Override public Size applyAt(CellRef cellRef, Context context) { if (this == XlsArea.EMPTY_AREA) { return Size.ZERO_SIZE; } logger.debug("Applying XlsArea at {}", cellRef); fireBeforeApplyEvent(cellRef, context); createCellRange(); AreaRef commandsArea = transformTopStaticArea(cellRef, context); for (int i = 0; i < commandDataList.size(); i++) { cellRange.resetChangeMatrix(); CommandData commandData = commandDataList.get(i); String shiftMode = commandData.getCommand().getShiftMode(); CellShiftStrategy commandCellShiftStrategy = detectCellShiftStrategy(shiftMode); cellRange.setCellShiftStrategy(commandCellShiftStrategy); CellRef commandStartCellRef = commandData.getStartCellRef(); Size commandInitialSize = commandData.getSize(); int startCol = commandStartCellRef.getCol() - startCellRef.getCol(); int startRow = commandStartCellRef.getRow() - startCellRef.getRow(); CellRef newCell = new CellRef(cellRef.getSheetName(), startRow + cellRef.getRow(), startCol + cellRef.getCol()); Size commandNewSize = commandData.getCommand().applyAt(newCell, context); int widthChange = commandNewSize.getWidth() - commandInitialSize.getWidth(); int heightChange = commandNewSize.getHeight() - commandInitialSize.getHeight(); int endCol = startCol + commandInitialSize.getWidth() - 1; int endRow = startRow + commandInitialSize.getHeight() - 1; if (heightChange != 0) { cellRange.shiftCellsWithColBlock(startCol, endCol, endRow, heightChange, true); Set<CommandData> commandsToShift = findCommandsForVerticalShift(commandDataList.subList(i+1, commandDataList.size()), startCol, endCol, endRow, heightChange); for (CommandData commandDataToShift : commandsToShift) { CellRef commandDataStartCellRef = commandDataToShift.getStartCellRef(); int relativeRow = commandDataStartCellRef.getRow() - startCellRef.getRow(); int relativeStartCol = commandDataStartCellRef.getCol() - startCellRef.getCol(); int relativeEndCol = relativeStartCol + commandDataToShift.getSize().getWidth() - 1; cellRange.shiftCellsWithColBlock(relativeStartCol, relativeEndCol, relativeRow + commandDataToShift.getSize().getHeight() - 1, heightChange, false); commandDataToShift.setStartCellRef( new CellRef(commandStartCellRef.getSheetName(), commandDataStartCellRef.getRow() + heightChange, commandDataStartCellRef.getCol())); if (heightChange < 0) { CellRef initialStartCellRef = commandDataToShift.getSourceStartCellRef(); Size initialSize = commandDataToShift.getSourceSize(); int initialStartRow = initialStartCellRef.getRow() - startCellRef.getRow(); int initialEndRow = initialStartRow + initialSize.getHeight() - 1; int initialStartCol = initialStartCellRef.getCol() - startCellRef.getCol(); int initialEndCol = initialStartCol + initialSize.getWidth() - 1; cellRange.clearCells(initialStartCol, initialEndCol, initialStartRow, initialEndRow); } } } if (widthChange != 0) { cellRange.shiftCellsWithRowBlock(startRow, endRow, endCol, widthChange, true); Set<CommandData> commandsToShift = findCommandsForHorizontalShift( commandDataList.subList(i + 1, commandDataList.size()), startRow, endRow, endCol, widthChange); for (CommandData commandDataToShift : commandsToShift) { CellRef commandDataStartCellRef = commandDataToShift.getStartCellRef(); int relativeCol = commandDataStartCellRef.getCol() - startCellRef.getCol(); int relativeStartRow = commandDataStartCellRef.getRow() - startCellRef.getRow(); int relativeEndRow = relativeStartRow + commandDataToShift.getSize().getHeight() - 1; cellRange.shiftCellsWithRowBlock(relativeStartRow, relativeEndRow, relativeCol + commandDataToShift.getSize().getWidth() - 1, widthChange, false); commandDataToShift.setStartCellRef( new CellRef(commandStartCellRef.getSheetName(), commandDataStartCellRef.getRow(), commandDataStartCellRef.getCol() + widthChange)); if (widthChange < 0) { CellRef initialStartCellRef = commandDataToShift.getSourceStartCellRef(); Size initialSize = commandDataToShift.getSourceSize(); int initialStartRow = initialStartCellRef.getRow() - startCellRef.getRow(); int initialEndRow = initialStartRow + initialSize.getHeight() - 1; int initialStartCol = initialStartCellRef.getCol() - startCellRef.getCol(); int initialEndCol = initialStartCellRef.getCol() + initialSize.getWidth() - 1; cellRange.clearCells(initialStartCol, initialEndCol, initialStartRow, initialEndRow); } } } } transformStaticCells(cellRef, context, commandsArea); fireAfterApplyEvent(cellRef, context); Size finalSize = new Size(cellRange.calculateWidth(), cellRange.calculateHeight()); AreaRef newAreaRef = new AreaRef(cellRef, finalSize); updateCellDataFinalAreaForFormulaCells(newAreaRef); for (CommandData commandData : commandDataList) { commandData.resetStartCellAndSize(); } return finalSize; } XlsArea(AreaRef areaRef, Transformer transformer);  XlsArea(String areaRef, Transformer transformer);  XlsArea(CellRef startCell, CellRef endCell, Transformer transformer);  XlsArea(CellRef startCellRef, Size size, List<CommandData> commandDataList, Transformer transformer);  XlsArea(CellRef startCellRef, Size size);  XlsArea(CellRef startCellRef, Size size, Transformer transformer); }
XlsArea implements Area { @Override public Size applyAt(CellRef cellRef, Context context) { if (this == XlsArea.EMPTY_AREA) { return Size.ZERO_SIZE; } logger.debug("Applying XlsArea at {}", cellRef); fireBeforeApplyEvent(cellRef, context); createCellRange(); AreaRef commandsArea = transformTopStaticArea(cellRef, context); for (int i = 0; i < commandDataList.size(); i++) { cellRange.resetChangeMatrix(); CommandData commandData = commandDataList.get(i); String shiftMode = commandData.getCommand().getShiftMode(); CellShiftStrategy commandCellShiftStrategy = detectCellShiftStrategy(shiftMode); cellRange.setCellShiftStrategy(commandCellShiftStrategy); CellRef commandStartCellRef = commandData.getStartCellRef(); Size commandInitialSize = commandData.getSize(); int startCol = commandStartCellRef.getCol() - startCellRef.getCol(); int startRow = commandStartCellRef.getRow() - startCellRef.getRow(); CellRef newCell = new CellRef(cellRef.getSheetName(), startRow + cellRef.getRow(), startCol + cellRef.getCol()); Size commandNewSize = commandData.getCommand().applyAt(newCell, context); int widthChange = commandNewSize.getWidth() - commandInitialSize.getWidth(); int heightChange = commandNewSize.getHeight() - commandInitialSize.getHeight(); int endCol = startCol + commandInitialSize.getWidth() - 1; int endRow = startRow + commandInitialSize.getHeight() - 1; if (heightChange != 0) { cellRange.shiftCellsWithColBlock(startCol, endCol, endRow, heightChange, true); Set<CommandData> commandsToShift = findCommandsForVerticalShift(commandDataList.subList(i+1, commandDataList.size()), startCol, endCol, endRow, heightChange); for (CommandData commandDataToShift : commandsToShift) { CellRef commandDataStartCellRef = commandDataToShift.getStartCellRef(); int relativeRow = commandDataStartCellRef.getRow() - startCellRef.getRow(); int relativeStartCol = commandDataStartCellRef.getCol() - startCellRef.getCol(); int relativeEndCol = relativeStartCol + commandDataToShift.getSize().getWidth() - 1; cellRange.shiftCellsWithColBlock(relativeStartCol, relativeEndCol, relativeRow + commandDataToShift.getSize().getHeight() - 1, heightChange, false); commandDataToShift.setStartCellRef( new CellRef(commandStartCellRef.getSheetName(), commandDataStartCellRef.getRow() + heightChange, commandDataStartCellRef.getCol())); if (heightChange < 0) { CellRef initialStartCellRef = commandDataToShift.getSourceStartCellRef(); Size initialSize = commandDataToShift.getSourceSize(); int initialStartRow = initialStartCellRef.getRow() - startCellRef.getRow(); int initialEndRow = initialStartRow + initialSize.getHeight() - 1; int initialStartCol = initialStartCellRef.getCol() - startCellRef.getCol(); int initialEndCol = initialStartCol + initialSize.getWidth() - 1; cellRange.clearCells(initialStartCol, initialEndCol, initialStartRow, initialEndRow); } } } if (widthChange != 0) { cellRange.shiftCellsWithRowBlock(startRow, endRow, endCol, widthChange, true); Set<CommandData> commandsToShift = findCommandsForHorizontalShift( commandDataList.subList(i + 1, commandDataList.size()), startRow, endRow, endCol, widthChange); for (CommandData commandDataToShift : commandsToShift) { CellRef commandDataStartCellRef = commandDataToShift.getStartCellRef(); int relativeCol = commandDataStartCellRef.getCol() - startCellRef.getCol(); int relativeStartRow = commandDataStartCellRef.getRow() - startCellRef.getRow(); int relativeEndRow = relativeStartRow + commandDataToShift.getSize().getHeight() - 1; cellRange.shiftCellsWithRowBlock(relativeStartRow, relativeEndRow, relativeCol + commandDataToShift.getSize().getWidth() - 1, widthChange, false); commandDataToShift.setStartCellRef( new CellRef(commandStartCellRef.getSheetName(), commandDataStartCellRef.getRow(), commandDataStartCellRef.getCol() + widthChange)); if (widthChange < 0) { CellRef initialStartCellRef = commandDataToShift.getSourceStartCellRef(); Size initialSize = commandDataToShift.getSourceSize(); int initialStartRow = initialStartCellRef.getRow() - startCellRef.getRow(); int initialEndRow = initialStartRow + initialSize.getHeight() - 1; int initialStartCol = initialStartCellRef.getCol() - startCellRef.getCol(); int initialEndCol = initialStartCellRef.getCol() + initialSize.getWidth() - 1; cellRange.clearCells(initialStartCol, initialEndCol, initialStartRow, initialEndRow); } } } } transformStaticCells(cellRef, context, commandsArea); fireAfterApplyEvent(cellRef, context); Size finalSize = new Size(cellRange.calculateWidth(), cellRange.calculateHeight()); AreaRef newAreaRef = new AreaRef(cellRef, finalSize); updateCellDataFinalAreaForFormulaCells(newAreaRef); for (CommandData commandData : commandDataList) { commandData.resetStartCellAndSize(); } return finalSize; } XlsArea(AreaRef areaRef, Transformer transformer);  XlsArea(String areaRef, Transformer transformer);  XlsArea(CellRef startCell, CellRef endCell, Transformer transformer);  XlsArea(CellRef startCellRef, Size size, List<CommandData> commandDataList, Transformer transformer);  XlsArea(CellRef startCellRef, Size size);  XlsArea(CellRef startCellRef, Size size, Transformer transformer); @Override Command getParentCommand(); @Override void setParentCommand(Command command); @Override CellShiftStrategy getCellShiftStrategy(); @Override void setCellShiftStrategy(CellShiftStrategy cellShiftStrategy); @Override FormulaProcessor getFormulaProcessor(); @Override void setFormulaProcessor(FormulaProcessor formulaProcessor); @Override void addCommand(AreaRef areaRef, Command command); void addCommand(String areaRef, Command command); @Override List<CommandData> getCommandDataList(); @Override Transformer getTransformer(); void setTransformer(Transformer transformer); @Override Size applyAt(CellRef cellRef, Context context); void clearCells(); @Override CellRef getStartCellRef(); @Override Size getSize(); @Override AreaRef getAreaRef(); @Override void processFormulas(); @Override void addAreaListener(AreaListener listener); @Override List<AreaListener> getAreaListeners(); @Override List<Command> findCommandByName(String name); @Override void reset(); }
XlsArea implements Area { @Override public Size applyAt(CellRef cellRef, Context context) { if (this == XlsArea.EMPTY_AREA) { return Size.ZERO_SIZE; } logger.debug("Applying XlsArea at {}", cellRef); fireBeforeApplyEvent(cellRef, context); createCellRange(); AreaRef commandsArea = transformTopStaticArea(cellRef, context); for (int i = 0; i < commandDataList.size(); i++) { cellRange.resetChangeMatrix(); CommandData commandData = commandDataList.get(i); String shiftMode = commandData.getCommand().getShiftMode(); CellShiftStrategy commandCellShiftStrategy = detectCellShiftStrategy(shiftMode); cellRange.setCellShiftStrategy(commandCellShiftStrategy); CellRef commandStartCellRef = commandData.getStartCellRef(); Size commandInitialSize = commandData.getSize(); int startCol = commandStartCellRef.getCol() - startCellRef.getCol(); int startRow = commandStartCellRef.getRow() - startCellRef.getRow(); CellRef newCell = new CellRef(cellRef.getSheetName(), startRow + cellRef.getRow(), startCol + cellRef.getCol()); Size commandNewSize = commandData.getCommand().applyAt(newCell, context); int widthChange = commandNewSize.getWidth() - commandInitialSize.getWidth(); int heightChange = commandNewSize.getHeight() - commandInitialSize.getHeight(); int endCol = startCol + commandInitialSize.getWidth() - 1; int endRow = startRow + commandInitialSize.getHeight() - 1; if (heightChange != 0) { cellRange.shiftCellsWithColBlock(startCol, endCol, endRow, heightChange, true); Set<CommandData> commandsToShift = findCommandsForVerticalShift(commandDataList.subList(i+1, commandDataList.size()), startCol, endCol, endRow, heightChange); for (CommandData commandDataToShift : commandsToShift) { CellRef commandDataStartCellRef = commandDataToShift.getStartCellRef(); int relativeRow = commandDataStartCellRef.getRow() - startCellRef.getRow(); int relativeStartCol = commandDataStartCellRef.getCol() - startCellRef.getCol(); int relativeEndCol = relativeStartCol + commandDataToShift.getSize().getWidth() - 1; cellRange.shiftCellsWithColBlock(relativeStartCol, relativeEndCol, relativeRow + commandDataToShift.getSize().getHeight() - 1, heightChange, false); commandDataToShift.setStartCellRef( new CellRef(commandStartCellRef.getSheetName(), commandDataStartCellRef.getRow() + heightChange, commandDataStartCellRef.getCol())); if (heightChange < 0) { CellRef initialStartCellRef = commandDataToShift.getSourceStartCellRef(); Size initialSize = commandDataToShift.getSourceSize(); int initialStartRow = initialStartCellRef.getRow() - startCellRef.getRow(); int initialEndRow = initialStartRow + initialSize.getHeight() - 1; int initialStartCol = initialStartCellRef.getCol() - startCellRef.getCol(); int initialEndCol = initialStartCol + initialSize.getWidth() - 1; cellRange.clearCells(initialStartCol, initialEndCol, initialStartRow, initialEndRow); } } } if (widthChange != 0) { cellRange.shiftCellsWithRowBlock(startRow, endRow, endCol, widthChange, true); Set<CommandData> commandsToShift = findCommandsForHorizontalShift( commandDataList.subList(i + 1, commandDataList.size()), startRow, endRow, endCol, widthChange); for (CommandData commandDataToShift : commandsToShift) { CellRef commandDataStartCellRef = commandDataToShift.getStartCellRef(); int relativeCol = commandDataStartCellRef.getCol() - startCellRef.getCol(); int relativeStartRow = commandDataStartCellRef.getRow() - startCellRef.getRow(); int relativeEndRow = relativeStartRow + commandDataToShift.getSize().getHeight() - 1; cellRange.shiftCellsWithRowBlock(relativeStartRow, relativeEndRow, relativeCol + commandDataToShift.getSize().getWidth() - 1, widthChange, false); commandDataToShift.setStartCellRef( new CellRef(commandStartCellRef.getSheetName(), commandDataStartCellRef.getRow(), commandDataStartCellRef.getCol() + widthChange)); if (widthChange < 0) { CellRef initialStartCellRef = commandDataToShift.getSourceStartCellRef(); Size initialSize = commandDataToShift.getSourceSize(); int initialStartRow = initialStartCellRef.getRow() - startCellRef.getRow(); int initialEndRow = initialStartRow + initialSize.getHeight() - 1; int initialStartCol = initialStartCellRef.getCol() - startCellRef.getCol(); int initialEndCol = initialStartCellRef.getCol() + initialSize.getWidth() - 1; cellRange.clearCells(initialStartCol, initialEndCol, initialStartRow, initialEndRow); } } } } transformStaticCells(cellRef, context, commandsArea); fireAfterApplyEvent(cellRef, context); Size finalSize = new Size(cellRange.calculateWidth(), cellRange.calculateHeight()); AreaRef newAreaRef = new AreaRef(cellRef, finalSize); updateCellDataFinalAreaForFormulaCells(newAreaRef); for (CommandData commandData : commandDataList) { commandData.resetStartCellAndSize(); } return finalSize; } XlsArea(AreaRef areaRef, Transformer transformer);  XlsArea(String areaRef, Transformer transformer);  XlsArea(CellRef startCell, CellRef endCell, Transformer transformer);  XlsArea(CellRef startCellRef, Size size, List<CommandData> commandDataList, Transformer transformer);  XlsArea(CellRef startCellRef, Size size);  XlsArea(CellRef startCellRef, Size size, Transformer transformer); @Override Command getParentCommand(); @Override void setParentCommand(Command command); @Override CellShiftStrategy getCellShiftStrategy(); @Override void setCellShiftStrategy(CellShiftStrategy cellShiftStrategy); @Override FormulaProcessor getFormulaProcessor(); @Override void setFormulaProcessor(FormulaProcessor formulaProcessor); @Override void addCommand(AreaRef areaRef, Command command); void addCommand(String areaRef, Command command); @Override List<CommandData> getCommandDataList(); @Override Transformer getTransformer(); void setTransformer(Transformer transformer); @Override Size applyAt(CellRef cellRef, Context context); void clearCells(); @Override CellRef getStartCellRef(); @Override Size getSize(); @Override AreaRef getAreaRef(); @Override void processFormulas(); @Override void addAreaListener(AreaListener listener); @Override List<AreaListener> getAreaListeners(); @Override List<Command> findCommandByName(String name); @Override void reset(); static final XlsArea EMPTY_AREA; }