Overview

When copying papers within within a group, the copied paper would be assigned a new group instance, resulting in the paper ordering being incorrect. To solve this we now make sure the copied paper belongs to the same group as the original. We then rebuild the panel to update and get the correct paper ordering.

Additionally, when multiple papers within a group where copied one of the papers would have an additional copy made. This has been fixed by making sure the specific paper is only copied once.

Runtime/Behavior Changes

Changes to cm/application/paperSelectionPanel.cm

old:

final public bool loadPaper(Url path=null) {

	...

	if (selectedSpace) {
	    // Assign the same group to the new space in order to ensure that the paper ordering is correct.
	    if (world.isCollWorldG2()) newSpace.group = selectedSpace.group;
	    if (!world.isCollWorld()) newSpace.setOrderNr(selectedSpace.orderNr);
	}

	createSmallPagePreviewControl(newSpace);

	...
   }

new:

 final public bool loadPaper(Url path=null) {

	...

	if (selectedSpace) {
	    // Assign the same group to the new space in order to ensure that the paper ordering is correct.
	    newSpace.group = selectedSpace.group;
	    newSpace.setOrderNr(selectedSpace.orderNr);
	}

	clearAndRebuild();
	...
   }

The following change makes sure the selected papers are only cloned once:

old:

private void clonePaperCB(Control c) {
    if (PaperSelectionPanel selector = c.container(PaperSelectionPanel).PaperSelectionPanel) {
	logEvent("clonePaper", "paperview");
	PaperSpace[] toClone();
	for (z in selector.inMultiSelect) {
	    toClone << z;
	}
	selector.clonePaper();

	for (z in toClone) {
	    selector.select(z);
	    selector.clonePaper();
	}
    }
}

new:

private void clonePaperCB(Control c) {
    if (PaperSelectionPanel selector = c.container(PaperSelectionPanel).PaperSelectionPanel) {
	logEvent("clonePaper", "paperview");
	PaperSpace[] toClone();
	for (z in selector.inMultiSelect) {
	    toClone << z;
	}

	if (toClone.empty()) selector.clonePaper();

	for (z in toClone) {
	    selector.select(z);
	    selector.clonePaper();
	}
    }
}

Finally, the below line in cm/application/paperUI.cm was changed in order to make tesing easier:

old:

final private SubWindow buildActionPanel(Window parent) {

 ...

 groupButton.hide();

 ...

}

new:

final private SubWindow buildActionPanel(Window parent) {

 ...

 if (!developMode) groupButton.hide(); //Show only for testing.

 ...

}