Skip to content
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
7ef857f
setroworder
izulin Dec 13, 2020
9ed086f
undo-redo + tests
izulin Dec 13, 2020
2948c79
undo tests
izulin Dec 14, 2020
1b7f8c4
extra logic
izulin Dec 14, 2020
f4c64f6
docs
izulin Dec 14, 2020
77bdb96
.
izulin Dec 14, 2020
cbd46e6
numeric matrices
izulin Dec 15, 2020
68faa65
linter
izulin Dec 15, 2020
a74b281
columns
izulin Dec 15, 2020
902f932
test
izulin Dec 15, 2020
9278854
tests
izulin Dec 15, 2020
ad839db
fixes bug with serialization of negative refs
izulin Dec 16, 2020
5e064e1
doc
izulin Dec 16, 2020
2c8be5a
Merge branch 'develop' into pu/reorder
izulin Dec 16, 2020
3f5fbf0
doc
izulin Dec 16, 2020
b087b30
linter
izulin Dec 16, 2020
bb83b0c
Merge branch 'pu/reorder' of https://github.com/handsontable/hyperfor…
izulin Dec 16, 2020
405e9e6
Merge branch 'develop' into pu/reorder
izulin Dec 28, 2020
89cf8aa
Update src/HyperFormula.ts
izulin Dec 29, 2020
59890a3
Update src/HyperFormula.ts
izulin Dec 29, 2020
5dacc68
extra methods
izulin Dec 30, 2020
a2aa30f
rename
izulin Dec 30, 2020
32e08b0
range serailization
izulin Dec 30, 2020
c5d5565
.
izulin Dec 31, 2020
8a73d6b
more methods
izulin Jan 1, 2021
2339770
abort cut
izulin Jan 1, 2021
05e1962
clear redo stack
izulin Jan 1, 2021
fb80fc6
linter
izulin Jan 1, 2021
7cb9734
docs
izulin Jan 3, 2021
4c7e3ee
simpler
izulin Jan 4, 2021
281a28f
Update src/CrudOperations.ts
izulin Jan 4, 2021
cf0780a
Update src/CrudOperations.ts
izulin Jan 4, 2021
7e7a6cb
Update src/HyperFormula.ts
izulin Jan 4, 2021
7637192
Update src/HyperFormula.ts
izulin Jan 4, 2021
3f595ac
docs
izulin Jan 4, 2021
1c75d16
warnings
izulin Jan 4, 2021
4cb55c7
refactor
izulin Jan 6, 2021
bda2cbf
refactor
izulin Jan 6, 2021
034b865
doc
izulin Jan 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added function aliases mechanism. (PR #569)
- Added support for scientific notation. (#579)
- Added support for complex numbers. (#281)
- Added support for row and column reordering. (#343)

### Fixed
- Fixed a problem with dependencies not collected for specific functions. (#550, #549)
- Fixed a minor problem with dependencies under nested parenthesis. (#549, #558)
- Fixed a problem with HLOOKUP/VLOOKUP getting stuck in binary search. (#559, #562)
- Fixed a problem with the logic of dependency resolving. (#561, #563)
- Fixed a minor bug with ATAN2 function. (#581)
- Fixed a bug with serialization of some addresses after CRUDs. (#587)

## [0.3.0] - 2020-10-22

Expand Down
4 changes: 4 additions & 0 deletions src/Cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,17 @@ export interface SimpleRowAddress {

export const simpleRowAddress = (sheet: number, row: number): SimpleRowAddress => ({sheet, row})

export const invalidSimpleRowAddress = (address: SimpleRowAddress): boolean => (address.row < 0)

export interface SimpleColumnAddress {
col: number,
sheet: number,
}

export const simpleColumnAddress = (sheet: number, col: number): SimpleColumnAddress => ({sheet, col})

export const invalidSimpleColumnAddress = (address: SimpleColumnAddress): boolean => (address.col < 0)

export interface SimpleCellAddress {
col: number,
row: number,
Expand Down
67 changes: 66 additions & 1 deletion src/CrudOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import {
RemoveRowsUndoEntry,
RemoveSheetUndoEntry,
RenameSheetUndoEntry,
SetCellContentsUndoEntry,
SetCellContentsUndoEntry, SetColumnOrderUndoEntry, SetRowOrderUndoEntry,
SetSheetContentUndoEntry,
UndoRedo
} from './UndoRedo'
Expand Down Expand Up @@ -293,6 +293,71 @@ export class CrudOperations {
this.undoRedo.saveOperation(new SetSheetContentUndoEntry(sheetId, oldSheetContent, values))
}

public setRowOrder(sheetId: number, rowMapping: [number, number][]): void {
this.validateSwapRowIndexes(sheetId, rowMapping)
this.undoRedo.clearRedoStack()
this.clipboardOperations.abortCut()
this.operations.setRowOrder(sheetId, rowMapping)
this.undoRedo.saveOperation(new SetRowOrderUndoEntry(sheetId, rowMapping))
}

public validateSwapRowIndexes(sheetId: number, rowMapping: [number, number][]): void {
if (!this.sheetMapping.hasSheetWithId(sheetId)) {
throw new NoSheetWithIdError(sheetId)
}
this.validateRowOrColumnMapping(sheetId, rowMapping, 'row')
}

public setColumnOrder(sheetId: number, columnMapping: [number, number][]): void {
this.validateSwapColumnIndexes(sheetId, columnMapping)
this.undoRedo.clearRedoStack()
Comment thread
wojciechczerniak marked this conversation as resolved.
Resolved
this.clipboardOperations.abortCut()
Comment thread
wojciechczerniak marked this conversation as resolved.
Resolved
this.operations.setColumnOrder(sheetId, columnMapping)
this.undoRedo.saveOperation(new SetColumnOrderUndoEntry(sheetId, columnMapping))
}

public validateSwapColumnIndexes(sheetId: number, columnMapping: [number, number][]): void {
if (!this.sheetMapping.hasSheetWithId(sheetId)) {
throw new NoSheetWithIdError(sheetId)
}
this.validateRowOrColumnMapping(sheetId, columnMapping, 'column')
}

public mappingFromOrder(sheetId: number, newOrder: number[], rowOrColumn: 'row' | 'column'): [number, number][] {
if (!this.sheetMapping.hasSheetWithId(sheetId)) {
throw new NoSheetWithIdError(sheetId)
}
const limit = rowOrColumn === 'row' ? this.dependencyGraph.getSheetHeight(sheetId) : this.dependencyGraph.getSheetWidth(sheetId)
if(newOrder.length !== limit) {
throw new InvalidArgumentsError(`number of ${rowOrColumn}s provided to be sheet ${rowOrColumn==='row'?'height':'width'}.`)
}
const ret: [number, number][] = []
for(let i=0;i<limit;i++) {
if(newOrder[i]!==i) {
ret.push([i, newOrder[i]])
}
}
return ret
}

private validateRowOrColumnMapping(sheetId: number, rowMapping: [number, number][], rowOrColumn: 'row' | 'column'): void {
const limit = rowOrColumn === 'row' ? this.dependencyGraph.getSheetHeight(sheetId) : this.dependencyGraph.getSheetWidth(sheetId)
const sources = rowMapping.map(([a, b])=>a).sort((a, b) => a-b)
Comment thread
izulin marked this conversation as resolved.
Resolved
const targets = rowMapping.map(([a, b])=>b).sort((a, b) => a-b)
Comment thread
izulin marked this conversation as resolved.
Resolved

for(let i=0;i<sources.length;i++) {
if(!isNonnegativeInteger(sources[i]) || sources[i] >= limit) {
throw new InvalidArgumentsError(`${rowOrColumn} numbers to be nonnegative integers and less than sheet ${rowOrColumn==='row'?'height':'width'}.`)
}
if(sources[i]===sources[i+1]) {
throw new InvalidArgumentsError(`source ${rowOrColumn} numbers to be unique.`)
}
if(sources[i]!==targets[i]) {
throw new InvalidArgumentsError(`target ${rowOrColumn} numbers to be permutation of source ${rowOrColumn} numbers.`)
}
}
}

public undo() {
if (this.undoRedo.isUndoStackEmpty()) {
throw new NoOperationToUndoError()
Expand Down
Loading