Changes to a protected shape

I’ve added a mastershape on a page. With this shape, the width, height, aspect ratio and rotation are locked. Then an attempt was made to make the shape wider.

In Visio, the width did not appear to have changed. However, when you select the shape, the selection area is wider than the shape appears to be. The width displayed for the shape, however, is the updated width. So, visually, the shape has not changed, but Visio displays the updated values and the selection area is now exactly the same size as the updated values.

I then tried using the Shape.Protection method to check whether it was even possible to change the width of the shape. However, all the lock properties of the Protection method have the value ‘Undefined’.

VisioProtectedWidth.png (7,1 KB)

In the screenshot, you can see how this phenomenon appears in my case. The protected shape is originally 180 mm wide. I had changed the width to 183 mm using Aspose.Diagram. The selection is now wider than the shape, and the modified value is displayed as the size, even though the shape does not appear to have become any wider.

How can I find out whether the width of a shape is locked?
Is there a way to remove this protection and still change the value?

Hello,

Thank you for the detailed description and screenshot. Let me address your questions:

1. How to check if width/height is locked

You can check the protection state via Shape.Protection.LockWidth.Value and Shape.Protection.LockHeight.Value. If these return Undefined, it means the protection cell is not explicitly set in the ShapeSheet — the shape may still be protected at the master level or via the page’s default protection settings.

To properly check, also inspect:

// Check master-level protection
if (shape.Master != null)
{
    var masterProt = shape.Master.PageSheet?.Protection;
    // Check LockWidth, LockHeight here
}

2. How to unlock width/height

Use the following C# code (Aspose.Diagram for .NET):

// Explicitly set protection to false (unlocked)
shape.Protection.LockWidth.Value = false;   // BOOL.False
shape.Protection.LockHeight.Value = false;  // BOOL.False

// Also check these if the shape behaves unexpectedly:
shape.Protection.LockAspect.Value = false;    // aspect ratio lock
shape.Protection.LockRotate.Value = false;    // rotation lock

Important: The syntax (BOOL)0 is C/C++ cast syntax and will cause a compilation error in C#. Please use false or BOOL.False instead.

For Java:

shape.getProtection().getLockWidth().setValue(BOOL.FALSE);
shape.getProtection().getLockHeight().setValue(BOOL.FALSE);

3. Please share the following

After trying the code above:

  1. Your full test code (including file loading and saving)
  2. The resulting Visio file or a screenshot showing the shape behavior after unlock
  3. Any error messages if the problem persists

This will help us determine whether the issue is with protection unlocking or something else (e.g., the master shape overriding your changes).