dave-howard / vsdx

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

Shape name is not language agnostic #40

Closed FROGGS closed 2 years ago

FROGGS commented 2 years ago

Hi, here you check the Name attribute of a shape against a known value: https://github.com/dave-howard/vsdx/blob/6e98f01e4726b7785a76fde82d2356d7041319e2/vsdx/shapes.py#L490

Though, in my German version of Visio it will contain a German translation, see:

<Shape ID="144" NameU="Dynamic connector" Name="Dynamischer Verbinder" Type="Shape" Master="5">...</Shape>

You might want to use the NameU attribute instead.

This is Visio Standard 2016 if that matters.

FROGGS commented 2 years ago

I just stumbled across another example:

<Shape ID="146" NameU="Dynamic connector.41" IsCustomNameU="1" Name="Dynamischer Verbinder.41" IsCustomName="1" Type="Shape" Master="5">...</Shape>

So not even NameU is reliable.

dave-howard commented 2 years ago

Thanks for flagging this - I expect I need to create a dict/map of translations for these kind of comparisons - and need to take account of the possible name.number format also.

Dave

dave-howard commented 2 years ago

Hello - I have added langauge mapping for this comparison and included in release v0.5.4. Please me know if that helps. Note that when creating a new connector via Connect.create() the tool copies content from an included media.vsdx file which will have the name in English language.

FROGGS commented 2 years ago

You could perhaps also check the master shape. Its PageSheet/Section[N="Layer"]/Row[IX="0"]/Cell[N="NameUniv"]has a value of Connector.

To be clear, I dont actually need a fix for this. I merely am about to write a software that also parses vsdx files, and reviewed your code for inspiration.

dave-howard commented 2 years ago

Hi @FROGGS - that looks really helpful. Thanks for the tip. Hope you found something useful in the source,

dave-howard commented 2 years ago

Implemented as Shape.universal_name in v0.5.5 - thank you :)