LibreOffice Module xmerge (master) 1
Style.java
Go to the documentation of this file.
1/*
2 * This file is part of the LibreOffice project.
3 *
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/.
7 *
8 * This file incorporates work covered by the following license notice:
9 *
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 .
17 */
18
19package org.openoffice.xmerge.converter.xml;
20
21import org.w3c.dom.Node;
22import org.w3c.dom.NamedNodeMap;
23
34public class Style {
35
37 protected String name = null;
39 protected String family = null;
41 protected String parent = null;
42
47 protected StyleCatalog sc;
48
59 public Style(Node node, StyleCatalog sc) {
60
61 this.sc = sc;
62
63 // Run through the attributes of this node, saving
64 // the ones we're interested in.
65 if (node.getNodeName().equals("style:default-style"))
66 name = "DEFAULT_STYLE";
67 NamedNodeMap attrNodes = node.getAttributes();
68 if (attrNodes != null) {
69 int len = attrNodes.getLength();
70 for (int i = 0; i < len; i++) {
71 Node attr = attrNodes.item(i);
72 if (attr.getNodeName().equals("style:family"))
73 family = attr.getNodeValue();
74 else if (attr.getNodeName().equals("style:name")) {
75 name = attr.getNodeValue();
76 } else if (attr.getNodeName().equals("style:parent-style-name"))
77 parent = attr.getNodeValue();
78
79 }
80 }
81 }
82
93 public Style(String name, String family, String parent, StyleCatalog sc) {
94 this.sc = sc;
95 this.name = name;
96 this.family = family;
97 this.parent = parent;
98 }
99
108 this.sc = sc;
109 }
110
116 public String getName() {
117 return name;
118 }
119
125 public void setName(String newName) {
126 name = newName;
127 }
128
134 public String getFamily() {
135 return family;
136 }
137
143 public String getParent() {
144 return parent;
145 }
146
157 return new Style(name, family, parent, sc);
158 }
159
168 public Node createNode(org.w3c.dom.Document parentDoc, String name) {
169 // DJP: write this! Should call writeAttributes()
170 return null;
171 }
172
188 public boolean isSubset(Style style) {
189 return true;
190 }
191}
A StyleCatalog holds a collection of Style objects.
An object of class Style represents a style in an OpenOffice document.
Definition: Style.java:34
String parent
Parent of the Style.
Definition: Style.java:41
Style getResolved()
Return a Style object corresponding to this one, but with all of the inherited information from paren...
Definition: Style.java:156
StyleCatalog sc
A reference to the StyleCatalog to be used for looking up ancestor Style objects.
Definition: Style.java:47
Node createNode(org.w3c.dom.Document parentDoc, String name)
Write a Node in parentDoc representing this Style.
Definition: Style.java:168
String getName()
Returns the name of this Style.
Definition: Style.java:116
void setName(String newName)
Sets the name of this Style.
Definition: Style.java:125
boolean isSubset(Style style)
Return true if Style is a subset of this one.
Definition: Style.java:188
void setCatalog(StyleCatalog sc)
Set the StyleCatalog to be used when looking up the Style parent.
Definition: Style.java:107
String family
Family of the Style.
Definition: Style.java:39
String getFamily()
Return the family of this Style.
Definition: Style.java:134
String getParent()
Return the name of the parent of this Style.
Definition: Style.java:143
Style(Node node, StyleCatalog sc)
Constructor for use when going from DOM to client device format.
Definition: Style.java:59
Style(String name, String family, String parent, StyleCatalog sc)
Constructor for use when going from client device format to DOM.
Definition: Style.java:93
String name
Name of the Style.
Definition: Style.java:37
OUString newName(std::u16string_view aNewPrefix, std::u16string_view aOldPrefix, std::u16string_view old_Name)
int i