dave-howard / vsdx

vsdx - A python library for processing .vsdx files
BSD 3-Clause "New" or "Revised" License
67 stars 25 forks source link

Support copying shapes from one vsdx file to another #41

Open MariusSchiffer opened 2 years ago

MariusSchiffer commented 2 years ago

if a shape has master_page_ID, which cannot be found in the current vsdx file, the shapes' text method tries to access its master's text without actually checking if it has an accessable master.

Breaks here: https://github.com/dave-howard/vsdx/blob/ff82f8fb095f53436b2f63cc80bfb004d18c8d3c/vsdx/shapes.py#L563

Easiest fix is probably to rather check is master_shape is None.

I have not yet found out why this happens, but it seems to be happening when pasting nested shapes in from other files.

dave-howard commented 2 years ago

Thank you @MariusSchiffer I'll add a simple check that shape has a master_shape here to stop the failure - but when copying a shape between files the tool would ideally also need to either include the master data with the copied shape and merge with the existing master data, or incorportate it into the shape itself (similar challenge internally to creating connectors in a vsdx with existing master data - which I am working on in #10 ).

Copying shapes from one vsdx file to another is not a use case this package currentl;y supports - depending on what you want to acheieve you might be able to acheive same by creating a template vsdx with the content you want and removing pages from the final output file (though see #42 I need to address also).

dave-howard commented 2 years ago

@MariusSchiffer - minor change added to v0.5.6 to validate the shape has a master shape - so now text peroperty returns None if no master shape found.

dave-howard commented 2 years ago

Renamed this issue to reflect reason I have left open - to support that use case