private void loadStylesFromDOM(Node node, boolean bAllParagraphsAreSoft) { // node should be office:master-styles, office:styles or office:automatic-styles boolean bAutomatic = XMLString.OFFICE_AUTOMATIC_STYLES.equals(node.getNodeName()); if (node.hasChildNodes()) { NodeList nl = node.getChildNodes(); int nLen = nl.getLength(); for (int i = 0; i < nLen; i++) { Node child = nl.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { if (child.getNodeName().equals(XMLString.STYLE_STYLE)) { String sFamily = Misc.getAttribute(child, XMLString.STYLE_FAMILY); if ("text".equals(sFamily)) { text.loadStyleFromDOM(child, bAutomatic); } else if ("paragraph".equals(sFamily)) { par.loadStyleFromDOM(child, bAutomatic && !bAllParagraphsAreSoft); } else if ("section".equals(sFamily)) { section.loadStyleFromDOM(child, bAutomatic); } else if ("table".equals(sFamily)) { table.loadStyleFromDOM(child, bAutomatic); } else if ("table-column".equals(sFamily)) { column.loadStyleFromDOM(child, bAutomatic); } else if ("table-row".equals(sFamily)) { row.loadStyleFromDOM(child, bAutomatic); } else if ("table-cell".equals(sFamily)) { cell.loadStyleFromDOM(child, bAutomatic); } else if ("graphics".equals(sFamily)) { frame.loadStyleFromDOM(child, bAutomatic); } else if ("graphic".equals(sFamily)) { // oasis frame.loadStyleFromDOM(child, bAutomatic); } else if ("presentation".equals(sFamily)) { presentation.loadStyleFromDOM(child, bAutomatic); } else if ("drawing-page".equals(sFamily)) { // Bug in OOo 1.x: The same name may be used for a real and an automatic style... if (drawingPage.getStyle(Misc.getAttribute(child, XMLString.STYLE_NAME)) == null) { drawingPage.loadStyleFromDOM(child, bAutomatic); } } } else if (child.getNodeName().equals(XMLString.STYLE_PAGE_MASTER)) { // old pageLayout.loadStyleFromDOM(child, bAutomatic); } else if (child.getNodeName().equals(XMLString.STYLE_PAGE_LAYOUT)) { // oasis pageLayout.loadStyleFromDOM(child, bAutomatic); } else if (child.getNodeName().equals(XMLString.STYLE_MASTER_PAGE)) { masterPage.loadStyleFromDOM(child, bAutomatic); if (firstMasterPage == null) { firstMasterPage = (MasterPage) masterPage.getStyle(Misc.getAttribute(child, XMLString.STYLE_NAME)); } } else if (child.getNodeName().equals(XMLString.TEXT_LIST_STYLE)) { list.loadStyleFromDOM(child, bAutomatic); } else if (child.getNodeName().equals(XMLString.TEXT_OUTLINE_STYLE)) { outline.loadStyleFromDOM(child); } else if (child.getNodeName().equals(XMLString.STYLE_DEFAULT_STYLE)) { String sFamily = Misc.getAttribute(child, XMLString.STYLE_FAMILY); if ("paragraph".equals(sFamily)) { StyleWithProperties defaultPar = new StyleWithProperties(); defaultPar.loadStyleFromDOM(child); par.setDefaultStyle(defaultPar); } else if ("graphics".equals(sFamily) || "graphic".equals(sFamily)) { // oasis: no s StyleWithProperties defaultFrame = new StyleWithProperties(); defaultFrame.loadStyleFromDOM(child); frame.setDefaultStyle(defaultFrame); } else if ("table-cell".equals(sFamily)) { StyleWithProperties defaultCell = new StyleWithProperties(); defaultCell.loadStyleFromDOM(child); cell.setDefaultStyle(defaultCell); } } } } } }