From: Ian Jackson Date: Sun, 8 May 2022 11:08:34 +0000 (+0100) Subject: shapelib: Reorganise shape/outline handling (2) X-Git-Tag: otter-1.1.0~255 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=c49e2cbd90daa463647d041abb6d50b20989cd0e;p=otter.git shapelib: Reorganise shape/outline handling (2) Centralise this in two functiosn now associated with GroupData. Now there is one place we can put new size and outline handling. Signed-off-by: Ian Jackson --- diff --git a/src/shapelib.rs b/src/shapelib.rs index ce337a11..23781de4 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -475,10 +475,8 @@ impl Catalogue { item_for_item: item_for.into(), })?; - let eh = shape_calculable.err_mapper(); - - let outline = group.d.outline.load(&group, sz).map_err(eh)?; - let xform = FaceTransform::from_group(&group.d).map_err(eh)?; + let (xform, outline) = group.load_shape(sz) + .map_err(shape_calculable.err_mapper())?; ImageLoaded { svgd: svg_data, @@ -616,6 +614,19 @@ impl ShapeCalculable { } } +impl GroupData { + #[throws(LibraryLoadError)] + fn check_shape(&self) -> ShapeCalculable { + self.d.outline.check(self)? + } + #[throws(LibraryLoadError)] + fn load_shape(&self, svg_sz: PosC) -> (FaceTransform, Outline) { + let xform = FaceTransform::from_group(&self.d)?; + let outline = self.d.outline.load(&self, svg_sz)?; + (xform, outline) + } +} + //---------- RectShape ---------- #[derive(Clone,Copy,Debug,Serialize,Deserialize)] @@ -855,7 +866,7 @@ pub fn load_catalogue(libname: &str, src: &mut dyn LibrarySource) // We do this here rather than in the files loop because // 1. we want to check it even if there are no files specified // 2. this is OK because the group doesn't change from here on - let shape_calculable = group.d.outline.check(&group)?.into(); + let shape_calculable = group.check_shape()?.into(); if [ group.d.flip,