Skip to content

Commit e047ece

Browse files
committed
SpreadsheetViewport.urlFragment includes all properties
- /home/A1/width/200/height/300/includeFrozenColumnsRows/true/selection/B2/top-left/navigations/right 400px - previously only included #anchoredSelection - Closes #7207 - SpreadsheetViewport.urlFragment is missing rectangle/includeFrozenColumnsRows/navigations
1 parent c28a552 commit e047ece

File tree

2 files changed

+56
-10
lines changed

2 files changed

+56
-10
lines changed

src/main/java/walkingkooka/spreadsheet/viewport/SpreadsheetViewport.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,39 @@ public void printTree(final IndentingPrinter printer) {
215215

216216
// HasUrlFragment...................................................................................................
217217

218+
// /home/A1/width/200/height/300/includeFrozenColumnsRows/true/selection/B2/top-left/navigations/right 400px
218219
@Override
219220
public UrlFragment urlFragment() {
220-
return this.anchoredSelection.map(HasUrlFragment::urlFragment)
221-
.orElse(UrlFragment.EMPTY);
221+
UrlFragment urlFragment = this.rectangle.urlFragment();
222+
223+
if(this.includeFrozenColumnsRows) {
224+
urlFragment = urlFragment.appendSlashThen(INCLUDE_FROZEN_COLUMNS_ROWS);
225+
}
226+
227+
urlFragment = urlFragment.appendSlashThen(SELECTION);
228+
229+
final AnchoredSpreadsheetSelection selection = this.anchoredSelection.orElse(null);
230+
if(null != selection) {
231+
urlFragment = urlFragment.append(
232+
selection.urlFragment()
233+
);
234+
}
235+
236+
final SpreadsheetViewportNavigationList navigations = this.navigations;
237+
if(navigations.isNotEmpty()) {
238+
urlFragment = urlFragment.appendSlashThen(NAVIGATIONS)
239+
.appendSlashThen(this.navigations.urlFragment());
240+
}
241+
242+
return urlFragment;
222243
}
223244

245+
private final static UrlFragment INCLUDE_FROZEN_COLUMNS_ROWS = UrlFragment.with("includeFrozenColumnsRows/true");
246+
247+
private final static UrlFragment SELECTION = UrlFragment.with("selection");
248+
249+
private final static UrlFragment NAVIGATIONS = UrlFragment.with("navigations");
250+
224251
// Object...........................................................................................................
225252

226253
@Override

src/test/java/walkingkooka/spreadsheet/viewport/SpreadsheetViewportTest.java

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ public void testTreePrintRectangleAnchoredSelectionRowRangeNavigations() {
427427
public void testUrlFragmentCell() {
428428
this.urlFragmentAndCheck(
429429
SpreadsheetSelection.A1.setDefaultAnchor(),
430-
"/A1"
430+
"/home/A1/width/100/height/50/selection/A1"
431431
);
432432
}
433433

@@ -436,7 +436,7 @@ public void testUrlFragmentCellRangeTopLeft() {
436436
this.urlFragmentAndCheck(
437437
SpreadsheetSelection.parseCellRange("B2:C3")
438438
.setAnchor(SpreadsheetViewportAnchor.TOP_LEFT),
439-
"/B2:C3/top-left"
439+
"/home/A1/width/100/height/50/selection/B2:C3/top-left"
440440
);
441441
}
442442

@@ -445,7 +445,7 @@ public void testUrlFragmentCellRangeTopRight() {
445445
this.urlFragmentAndCheck(
446446
SpreadsheetSelection.parseCellRange("B2:C3")
447447
.setAnchor(SpreadsheetViewportAnchor.TOP_RIGHT),
448-
"/B2:C3/top-right"
448+
"/home/A1/width/100/height/50/selection/B2:C3/top-right"
449449
);
450450
}
451451

@@ -454,7 +454,7 @@ public void testUrlFragmentColumnNone() {
454454
this.urlFragmentAndCheck(
455455
SpreadsheetSelection.parseColumn("Z")
456456
.setDefaultAnchor(),
457-
"/Z"
457+
"/home/A1/width/100/height/50/selection/Z"
458458
);
459459
}
460460

@@ -463,7 +463,7 @@ public void testUrlFragmentColumnRangeLeft() {
463463
this.urlFragmentAndCheck(
464464
SpreadsheetSelection.parseColumnRange("X:Y")
465465
.setAnchor(SpreadsheetViewportAnchor.LEFT),
466-
"/X:Y/left"
466+
"/home/A1/width/100/height/50/selection/X:Y/left"
467467
);
468468
}
469469

@@ -472,7 +472,7 @@ public void testUrlFragmentColumnRangeRight() {
472472
this.urlFragmentAndCheck(
473473
SpreadsheetSelection.parseColumnRange("X:Y")
474474
.setAnchor(SpreadsheetViewportAnchor.RIGHT),
475-
"/X:Y/right"
475+
"/home/A1/width/100/height/50/selection/X:Y/right"
476476
);
477477
}
478478

@@ -481,7 +481,7 @@ public void testUrlFragmentLabelNone() {
481481
this.urlFragmentAndCheck(
482482
SpreadsheetSelection.parseCellOrLabel("Label123")
483483
.setDefaultAnchor(),
484-
"/Label123"
484+
"/home/A1/width/100/height/50/selection/Label123"
485485
);
486486
}
487487

@@ -490,7 +490,7 @@ public void testUrlFragmentLabelBottomRight() {
490490
this.urlFragmentAndCheck(
491491
SpreadsheetSelection.parseCellOrLabel("Label123")
492492
.setAnchor(SpreadsheetViewportAnchor.BOTTOM_RIGHT),
493-
"/Label123/bottom-right"
493+
"/home/A1/width/100/height/50/selection/Label123/bottom-right"
494494
);
495495
}
496496

@@ -508,6 +508,25 @@ private void urlFragmentAndCheck(final AnchoredSpreadsheetSelection anchoredSpre
508508
);
509509
}
510510

511+
@Test
512+
public void testUrlFragmentIncludeFrozenColumnsRowsTrueAndWithoutSelection() {
513+
this.urlFragmentAndCheck(
514+
HOME.viewportRectangle(111, 222)
515+
.viewport()
516+
.setIncludeFrozenColumnsRows(true)
517+
.setNavigations(SpreadsheetViewportNavigationList.parse("right 99px,down 999px")),
518+
"/home/A1/width/111/height/222/includeFrozenColumnsRows/true/selection/navigations/right%2099px,down%20999px"
519+
);
520+
}
521+
522+
@Test
523+
public void testUrlFragmentAllProperties() {
524+
this.urlFragmentAndCheck(
525+
this.createObject(),
526+
"/home/A1/width/100/height/50/selection/B2:C3/top-left/navigations/left%20column"
527+
);
528+
}
529+
511530
// json.............................................................................................................
512531

513532
@Test

0 commit comments

Comments
 (0)