Merging style inheritance elements
Home › Forums › WordprocessingML › Merging style inheritance elements
- This topic has 3 replies, 2 voices, and was last updated 9 years, 6 months ago by
Eric White.
-
AuthorPosts
-
August 22, 2016 at 2:24 pm #3629
Eric White
KeymasterI 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.
August 22, 2016 at 8:06 pm #3639Xyo
ParticipantThanks 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 9 years, 6 months ago by
Xyo.
August 25, 2016 at 4:26 pm #3672Eric White
KeymasterYou 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.
-
This reply was modified 9 years, 6 months ago by
-
AuthorPosts
- You must be logged in to reply to this topic.