question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PPT: The Outline default Line Width value is one pixel not the zero

See original GitHub issue

Description

I find the behavior in PowerPoint is different from the ECMA-376 document.

We can find the ECMA-376 document chapter 20.1.2.2.24 say that the Line Width is omitted, then a value of 0 is assumed.

But when we create a document with the Line Width is omitted, and the PowerPoint will show the shape Line Width as one pixel.

Information

  • .NET Target: ALL
  • DocumentFormat.OpenXml Version: ALL

Repro

https://github.com/lindexi/lindexi_gd/tree/173fbaf7c68023cf5064888bceeb197bd463538f/PptxDemo

  <p:sp>
    <p:nvSpPr>
      <p:cNvPr id="2" name="Rectangle 1" />
      <p:cNvSpPr />
      <p:nvPr />
    </p:nvSpPr>
    <p:spPr>
      <a:xfrm>
        <a:off x="5220072" y="1484784" />
        <a:ext cx="1440160" cy="1008112" />
      </a:xfrm>
      <a:prstGeom prst="rect"/>
      <a:ln w="0">
        <a:solidFill>
          <a:srgbClr val="565656" />
        </a:solidFill>
      </a:ln>
    </p:spPr>
  </p:sp>

And

  <p:sp>
    <p:nvSpPr>
      <p:cNvPr id="2" name="Rectangle 1" />
      <p:cNvSpPr />
      <p:nvPr />
    </p:nvSpPr>
    <p:spPr>
      <a:xfrm>
        <a:off x="5220072" y="1484784" />
        <a:ext cx="1440160" cy="1008112" />
      </a:xfrm>
      <a:prstGeom prst="rect"/>
      <a:ln>
        <a:solidFill>
          <a:srgbClr val="565656" />
        </a:solidFill>
      </a:ln>
    </p:spPr>
  </p:sp>
        private static void ReadShape(Shape shape)
        {
            var outline = shape.ShapeProperties?.GetFirstChild<Outline>();
            if (outline != null)
            {
                var lineWidth = outline.Width;
                var emu = new Emu(lineWidth);
                var pixel = emu.ToPixel();
                Console.WriteLine($"LineWidth {pixel.Value}");
            }
            else
            {
               
            }
        }

Observed

The outline.Width is null

Expected

I dot not know how to handle the PPT behavior is different from the ECMA-376 document

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lindexicommented, Aug 5, 2021

@tomjebo Thank you.

1reaction
tomjebocommented, Aug 5, 2021

@lindexi, the graphics team confirmed that this behavior mimics GDI/GDI+ library behavior and has likely been in early versions of Office. I’m proposing that we add a behavior note to [MS-OI29500] 2.1.1211 (that’s the section that describes our Office implementation for ISO 29500 20.1.2.2.24 ln (Outline)).

Some notes: A value of w=“0” is not the correct way to remove the outline from a shape. To remove the outline, use the <noFill> line property. As long as there is a fill of some kind (the default fill will be <solidFill>), the outline will be drawn. When w=“0” is specified in the XML or if you omit the w attribute and do not include <noFill>, the effect on Office will be to draw a 1 device unit outline on the shape. Office will also preload the Format Shape dialog with a width of “1 pt” but this will not be written to XML.

For the SDK, we should not default the Outline class’ Width property to 0 or 1. That is actually an application behavior of Office when rendering but is not persisted. For example, Office will show a width of 1 pt in the UI but it won’t write anything out unless the user explicitly sets/changes that or sets/changes some other property that mandates it like <solidFill>. Without those conditions, upon save, Office does not touch the <ln> element. So my understanding: if the w attribute is missing, calling Outline.Width should get a null object. In that case you’re application should behave as if a shape has an outline of one device unit. But it should not persist anything to the underlying XML unless an explicit change is required. I hope this is clear.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how do you set default shape and line in powerpoint 2010
I am trying to set an arrow's thickness, color, and style as my default. When I create the line I right click and...
Read more >
How do I set a default line style in PowerPoint that will ...
When drawing a line (Insert -> Shapes -> line) it is blue by default. I want it to be black and a certain...
Read more >
gnuplot: why is linewidth 0 not zero in width?
According to this convention, a line width of zero does not mean invisible; ... So, on monitors, it will be a line which...
Read more >
PowerPoint 2016 - Resize an Image - How to Change Picture ...
This Microsoft Office PowerPoint 2016 shows you how to move and resize pictures. This tutorial covers aspect ratio, sizing handles, ...
Read more >
border-width - CSS: Cascading Style Sheets - MDN Web Docs
The border-width property may be specified using one, two, three, or four values. When one value is specified, it applies the same width...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found