How to access styles? Where is "w:style"?

Answered How to access styles? Where is "w:style"?

  • Freitag, 30. November 2007 15:41
     
     

     

    The file styles.xml contains definitions of the default styles. How to access this via the SDK API?

    The current 'parts' (e.g. MainDocumentPart or WordprocessingDocument) don't seem to contain the tags "wTongue Tiedtyle" or "wTongue Tiedtyles".

     

    Where are they?! Do I have to go in through the package interface?

     

    John D.

Alle Antworten

  • Freitag, 30. November 2007 15:43
     
     

    Well! Just interpret the emoticon Tongue Tied as meaning ":" followed by "s". That will teach me to preview...

  • Freitag, 30. November 2007 17:12
     
     
    If you apply "Heading 2" style to your text you can see following fragment in the document.xml (MainDocumentPart):

    <w:r>
    <w:rPr>
    <w:rStyle w:val="Heading2Char" />
    </w:rPr>
    <w:r>

    Best Regards,
    Denis
  • Samstag, 1. Dezember 2007 13:34
     
     

    Denis,

     

    (by the way, thanks for answering - it's pretty quiet in here!)

     

    what you say is true, but it doesn't answer the question. You can override style on an individual item (such as a run as in yxour example), but there is also a 'default' style which lives in styles.xml. The question is how to access the things in styles.xml programmatically. Ideally, I want to use the SDK. If I *have* to I will go through system.io.packaging (access the file as part of the zip).

     

    My reason is that I want to validate that a given document has a certain style, and that it hasn't been changed.

     

    John D.

  • Montag, 3. Dezember 2007 07:49
     
     Beantwortet

    WordprocessingDocument.MainDocumentPart.StyleDefinitionsPart.

    You could create a DOM on the part stream and access each style definition that way.

    API doesn't provide more support on understanding each parts.

     

  • Donnerstag, 6. Dezember 2007 16:19
     
     

    Yes, that was exactly what I was looking for. I hadn't realised the SDK imposed some kind of hierarchy on the files you see in the zip. So, you only get to the content of the Styles part, within the main document part.

     

    Thanks.

     

    John D.