| 749 | } |
| 750 | |
| 751 | func EffectiveCopyDestination(source, destination *sheets.GridRange, transpose bool) *sheets.GridRange { |
| 752 | if source == nil || destination == nil { |
| 753 | return destination |
| 754 | } |
| 755 | minHeight := source.EndRowIndex - source.StartRowIndex |
| 756 | |
| 757 | minWidth := source.EndColumnIndex - source.StartColumnIndex |
| 758 | if transpose { |
| 759 | minHeight, minWidth = minWidth, minHeight |
| 760 | } |
| 761 | effective := *destination |
| 762 | effective.EndRowIndex = effective.StartRowIndex + effectivePasteLength( |
| 763 | minHeight, |
| 764 | effective.EndRowIndex-effective.StartRowIndex, |
| 765 | ) |
| 766 | effective.EndColumnIndex = effective.StartColumnIndex + effectivePasteLength( |
| 767 | minWidth, |
| 768 | effective.EndColumnIndex-effective.StartColumnIndex, |
| 769 | ) |
| 770 | |
| 771 | return &effective |
| 772 | } |
| 773 | |
| 774 | func effectivePasteLength(sourceLength, destinationLength int64) int64 { |
| 775 | if destinationLength >= sourceLength && destinationLength%sourceLength == 0 { |