Bug Report T293893
Visible to All Users

Numeration is incorrectly applied to document titles on import

created 9 years ago (modified 9 years ago)

Hello,

I've noticed an issue in Document Server behavior:

  1. Convert the attached document from DOCX to HTML with default settings.
  2. Take a look at HTML markup generated for any of the headers in the resulting document (e.g. "Abstract" or "Introduction"). You'll see something like this:
    <ol start="2" style="margin-top:0;margin-bottom:0;"><li class="csC09771DB"><span class="csC05134DD">Introduction</span></li></ol>

This is wrong. They are headers, so they must be rendered as h1 or h2 (depending on the outline level).

I did some debug and it appears that the styles for the paragraphs in question are inherited - probably that's why your logic does not detect their outline level. In order to handle such scenarios properly, you need to use something like this:

C#
private int getStyleOutlineLevel(ParagraphStyle style) { if (style.OutlineLevel.HasValue && style.OutlineLevel.Value > 0) { return style.OutlineLevel.Value; } else if (style.Parent != null) { return getStyleOutlineLevel(style.Parent); } else { return 0; } }

Instead of simply checking for style.OutlineLevel.Value.

Please fix this issue as it is important for me to get some real h1-h2 tags instead of simply replicating the needed heading style with spans and li.

Nickolay, Software Architect
ClickHelp - Online Documentation Tool
http://clickhelp.co

Show previous comments (6)
CT CT
ClickHelp Team 9 years ago

    >>>
    I guess your main idea is to remove the document auto-numbering and replace numbers as a simple text in the document headers before exporting
    <<<
    Exactly.
    >>>
    So, you should generate this string with the number manually by counting the number of headers with the corresponding outline level. When the string is generated, you can insert this string in the paragraph start position using the RichEditDocumentServer.Document.InsertText method.
    <<<
    So, no built-in way to do that. OK, thanks for clarifying that. I think I'll just keep removing the numbers for now - just wanted to check whether there's an easy way to keep them. They're not very important for me and if I'll need them I'll just count the headers as you suggested.
    I see that you've put this case to the "Fixed" status. Could you please clarify what exactly behavior will be fixed by the hotfix? I mean, what the change of behavior will be after applying the hotfix?
    Nickolay, Software Architect
    ClickHelp - Online Documentation Tool
    http://clickhelp.co

    Maria Nikulina (DevExpress) 9 years ago

      As I specified in my first comment, the Abstract header becomes numbered on document loading for some reason. So, all the document numbering was incorrect.
      Now this document numbering is fixed (Abstract is not numbered anymore). So, you will be able to import this document as expected and the exported document should have the correct numbers.

      CT CT
      ClickHelp Team 9 years ago

        For anyone interested in removing the automatic numbers, the sample above is not correct as it removes all lists from the document regardless of whether they are headers or not, which is obviously not acceptable. You need to use the following code instead:
        private void cleanupNumberedHeadings()
           {
             foreach (Paragraph p in _doc.Paragraphs)
             {
               if (!p.IsInList
                 || (getStyleOutlineLevel(p.Style) < 1
                   && p.OutlineLevel < 1))
               { // Not a numbered heading
                 continue;
               }
               int listLevel = p.ListLevel;
               _doc.Paragraphs.RemoveNumberingFromParagraph§;
               p.OutlineLevel = listLevel + 1;
             }
           }
        Where getStyleOutlineLevel is a routine used to get a style outline recursively considering the inheritance:
        private int getStyleOutlineLevel(ParagraphStyle style)
           {
             if (style.OutlineLevel.HasValue
               && style.OutlineLevel.Value > 0)
             {
               return style.OutlineLevel.Value;
             }
             else if (style.Parent != null)
             {
               return getStyleOutlineLevel(style.Parent);
             }
             else
             {
               return 0;
             }
           }
        Nickolay, Software Architect
        ClickHelp - Online Documentation Tool
        http://clickhelp.co

        Answers approved by DevExpress Support

        created 9 years ago (modified 9 years ago)

        We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

        Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

          Show previous comments (4)
          Maria Nikulina (DevExpress) 9 years ago

            Hello Nickolay,
            I tried your code with the source document and it worked as expected (numbering is removed for the Abstract title). After that, I exported the result to the html format, and this exported document did not contain numbered titles either. It's difficult to determine the cause of the behavior occurred on your side, since it's not completely clear what modifications you apply to the document.
            It will be great if you provide me with the source code that you use to edit documents. I'm looking forward to your response.

            CT CT
            ClickHelp Team 9 years ago

              I'll try but this may take time and as I said this is no longer high priority for me. I'll need to narrow down the piece of code which causes this, because the full logic has tons of dependencies and it would be easier to give you all the 3 K source files of my project (nope, I won't do that) than to split it into a fully working example.
              Nickolay, Software Architect
              ClickHelp - Online Documentation Tool
              http://clickhelp.co

              Maria Nikulina (DevExpress) 9 years ago

                Okay. Please feel free to reactivate this ticket or create a new one once you prepare the sample for this case.

                Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

                Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.