Merging style inheritance elements

Home Forums WordprocessingML Merging style inheritance elements

This topic contains 3 replies, has 2 voices, and was last updated by  Eric White 8 years, 4 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #3623

    Xyo
    Participant

    Using the algorithms found here, https://blogs.msdn.microsoft.com/ericwhite/2009/12/13/implementing-inheritance-in-xml/, does anyone know what the particular element semantics are?

    Such as in https://blogs.msdn.microsoft.com/ericwhite/2009/10/28/open-xml-wordprocessingml-style-inheritance-post-4/ eric states that for the w:top (Paragraph Border Above Identical Paragraphs) element we don’t need to iterate through the attributes, as it’s replaced wholesale?

    If there isn’t a comprehensive list (from Eric or not) of the element merging schematics, does anyone know where the child element merging semantics are specified in the EMCA specification? I can’t seem to find where they are specified.

    Thanks

    #3629

    Eric White
    Keymaster

    I remember being told that it is defined in the Implementation Notes, but I can’t find it.

    Anyway, if I were to make a list of the exact, precise rules for style inheritance (and they are sometimes weird, take toggle properties, for instance), I would read the code of FormattingAssembler.cs. That module implements style inheritance properly.

    Sorry I don’t have a better answer for you. This is also what I would need to do – I of course can’t remember all the details. But the code is there, and it is pretty accurate.

    #3639

    Xyo
    Participant

    Thanks for the response Eric.

    I have worked out a crude implementation of rolling up style inheritance and a run’s style hierarchy. Right now my implementation accepts any new attributes that change for the next hierarchy or inheritance, as long as that attribute is defined. I handle the toggle properties when rolling up the run style hierarchy as well.
    The properties that aren’t On/Off types like shading, borders, color, and the run font names are what I’m looking for in particular. Whether or not their attributes (like shading’s background & foreground colors, and texture) are replaced wholesale, or each is looked at in turn.

    Thanks for pointing me towards FormattingAssembler.cs, I’m looking through it right now to hopefully find what I need.

    • This reply was modified 8 years, 4 months ago by  Xyo.
    #3672

    Eric White
    Keymaster

    You should also take notice of font merging semantics. See the FontMerge function in FormattingAssembler.

    In a past project, when I needed to test against something that might be defined in the paragraph or might be defined in a style, I added a GUID to the beginning of the text of the paragraph. I then process the document using FormattingAssembler, open the processed document, find the paragraph with my GUID, then look at the paragraph and run properties, which will be correct according to the style chain, default document properties, and of course direct styling on the paragraph. In the case of tables, it gets even more complicated because of how table style inheritance, and conditionally applied formatting is applied to tables. FormattingAssembler takes care of all of that stuff – after processing with it, you need only to look at the local properties to see whether text is bolded, or has some particular foreground or background color.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.