OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 17 | Rev 73 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17 Rev 25
Line 11... Line 11...
11
 * When distributing the software, include this License Header Notice in each file.
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
12
 */
13
 
13
 
14
 package org.openconcerto.openoffice.text;
14
 package org.openconcerto.openoffice.text;
15
 
15
 
16
import org.openconcerto.openoffice.ODSingleXMLDocument;
16
import org.openconcerto.openoffice.ODDocument;
17
import org.openconcerto.openoffice.StyleStyle;
17
import org.openconcerto.openoffice.StyleStyle;
18
import org.openconcerto.openoffice.StyledNode;
18
import org.openconcerto.openoffice.StyledNode;
19
 
19
 
20
import org.jdom.Element;
20
import org.jdom.Element;
21
 
21
 
Line 24... Line 24...
24
 * 
24
 * 
25
 * @author Sylvain CUAZ
25
 * @author Sylvain CUAZ
26
 * 
26
 * 
27
 * @param <S> type of style.
27
 * @param <S> type of style.
28
 */
28
 */
29
public abstract class TextNode<S extends StyleStyle> extends StyledNode<S, ODSingleXMLDocument> {
29
public abstract class TextNode<S extends StyleStyle> extends StyledNode<S, TextDocument> {
30
 
30
 
31
    protected ODSingleXMLDocument parent;
31
    protected TextDocument parent;
32
 
32
 
33
    public TextNode(Element local, final Class<S> styleClass) {
33
    public TextNode(Element local, final Class<S> styleClass) {
-
 
34
        this(local, styleClass, null);
-
 
35
    }
-
 
36
 
-
 
37
    protected TextNode(Element local, final Class<S> styleClass, final TextDocument parent) {
34
        super(local, styleClass);
38
        super(local, styleClass);
35
        this.parent = null;
39
        this.parent = parent;
36
    }
40
    }
37
 
41
 
38
    @Override
42
    @Override
39
    public final ODSingleXMLDocument getODDocument() {
43
    public final TextDocument getODDocument() {
40
        return this.parent;
44
        return this.parent;
41
    }
45
    }
42
 
46
 
43
    public final void setDocument(ODSingleXMLDocument doc) {
47
    public final void setDocument(TextDocument doc) {
44
        if (doc != this.parent) {
48
        if (doc != this.parent) {
45
            if (doc == null) {
49
            if (doc == null) {
46
                this.parent = null;
50
                this.parent = null;
47
                this.getElement().detach();
51
                this.getElement().detach();
48
            } else if (doc.getDocument() != this.getElement().getDocument())
52
            } else if (doc.getContentDocument() != this.getElement().getDocument()) {
49
                doc.add(this);
53
                doc.add(this);
50
            else {
54
            } else {
51
                this.checkDocument(doc);
55
                this.checkDocument(doc);
52
                this.parent = doc;
56
                this.parent = doc;
53
            }
57
            }
54
        }
58
        }
55
    }
59
    }
56
 
60
 
57
    protected abstract void checkDocument(ODSingleXMLDocument doc);
61
    protected abstract void checkDocument(ODDocument doc);
58
}
62
}