Page 1 of 1

Ms word default styles

PostPosted: Mon Mar 09, 2015 8:13 pm
by AnbuChezhian
Hi,

How can we read a documents built-in styles like heading1, heading2,title etc.,. If we create a paragraph with those styles, we can read it from style.xml. I want to know how we can read if we don't use those styles in our document?

Re: Ms word default styles

PostPosted: Wed Mar 11, 2015 12:52 pm
by jason
Your question isn't clear, but:

https://github.com/plutext/docx4j/blob/ ... Styles.xml

contains a default set of styles.

StyleDefinitionsPart contains:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
        /**
         * Returns a map of styles defined in docx4j's KnownStyles.xml
         * (not styles defined in your pkg)
         * @return
         */

        public static java.util.Map<String, org.docx4j.wml.Style> getKnownStyles() {
                if (knownStyles==null) {
                        initKnownStyles();
                }
                return knownStyles;
        }
 
Parsed in 0.015 seconds, using GeSHi 1.0.8.4


It isn't used much in docx4j, but PropertyResolver's activateStyle uses it to add a style to the styles part.

Re: Ms word default styles

PostPosted: Wed Mar 11, 2015 3:31 pm
by AnbuChezhian
Hi, Thank you for your reply. KnownStyles.xml has some hard coded value. I have attached a document for your reference. In that document, the "docdefaults" and "normal" styles does not have a entry for line spacing. In this case how we get exact value of line spacing.

Re: Ms word default styles

PostPosted: Wed Mar 11, 2015 6:04 pm
by jason
See http://webapp.docx4java.org/OnlineDemo/ ... ing_1.html

The defaults are given in the table.

[MS-OI29500] doesn't say anything different, so just experiment with Word to confirm it behaves as described. Use the "Reveal Formatting" function (be sure to check the "Distinguish style source" box).