Update git submodules
[LibreOffice.git] / reportbuilder / java / org / libreoffice / report / pentaho / model / OfficeStylesCollection.java
blobeee9ad5531bd532e2bb89c8f3165c0274564990b
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 package org.libreoffice.report.pentaho.model;
20 import org.libreoffice.report.pentaho.OfficeNamespaces;
22 import org.jfree.report.structure.Element;
24 /**
25 * Holds all style-definitions and provides some simplified lookup methods to
26 * grab them by their type and name.
28 * <p>For now, we are only interested in 'style:style' nodes. Each of these nodes
29 * has a style-name and a style-family. Each style declaration can have a parent
30 * style, from which properties are inherited.</p>
32 * <p>Style names are unique within the family, no matter whether the style is an
33 * automatic style, a common style or a master style.</p>
35 * <p>The contents of this element are the union of the 'styles.xml' file (if it
36 * exists), the font-declarations and auto-styles of the document-content.xml
37 * and the styles declared in the main document.</p>
39 * @since 06.03.2007
41 public class OfficeStylesCollection extends Element
43 // Font-face declarations are copied as is. We simply merge them by adding
44 // them all in one set. This may result in duplicate entries, but as the
45 // fileformat does not forbid that, it therefore must be ok.
47 private final FontFaceDeclsSection fontFaceDecls;
48 private final OfficeStyles automaticStyles;
49 private final OfficeStyles commonStyles;
50 private final OfficeMasterStyles masterStyles;
52 public OfficeStylesCollection()
54 fontFaceDecls = new FontFaceDeclsSection();
56 automaticStyles = new OfficeStyles();
57 automaticStyles.setType("automatic-styles");
58 automaticStyles.setNamespace(OfficeNamespaces.OFFICE_NS);
60 commonStyles = new OfficeStyles();
61 commonStyles.setType("styles");
62 commonStyles.setNamespace(OfficeNamespaces.OFFICE_NS);
64 masterStyles = new OfficeMasterStyles();
65 masterStyles.setType("master-styles");
66 masterStyles.setNamespace(OfficeNamespaces.OFFICE_NS);
69 public OfficeStyle getStyle(final String family, final String name)
71 final OfficeStyle commonStyle = commonStyles.getStyle(family, name);
72 if (commonStyle != null)
74 return commonStyle;
76 final OfficeStyle autoStyle = automaticStyles.getStyle(family, name);
77 if (autoStyle != null)
79 return autoStyle;
82 // And later: Autogenerate one of the default styles.
83 // However, at this moment, we don't have a clue about the default styles
84 // at all. Maybe we should add them to make this implementation more robust
85 // against invalid documents.
86 return null;
89 public boolean containsStyle(final String family, final String name)
91 return (getStyle(family, name) != null);
94 public OfficeStyles getAutomaticStyles()
96 return automaticStyles;
99 public OfficeStyles getCommonStyles()
101 return commonStyles;
104 public OfficeMasterStyles getMasterStyles()
106 return masterStyles;
109 public FontFaceDeclsSection getFontFaceDecls()
111 return fontFaceDecls;