summaryrefslogtreecommitdiffstats
path: root/filters/kword/rtf/import/rtfimport_dom.h
blob: f6717174435c4130d86bb26d4b7e62046bbedf99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
   This file is part of the KDE project
   Copyright (C) 2001 Ewald Snel <ewald@rambo.its.tudelft.nl>
   Copyright (C) 2001 Tomasz Grobelny <grotk@poczta.onet.pl>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.
*/

#ifndef __RTFIMPORT_DOM_H__
#define __RTFIMPORT_DOM_H__

#include <tqstring.h>

class TQColor;
class TQDateTime;
class TQTextCodec;

/**
 * Escape the special XML characters and be careful to catch any unallowed control character
 */
TQString CheckAndEscapeXmlText(const TQString& strText);

class DomNode
{
public:
    DomNode();
    /**
     * Creates a new document.
     * @param doctype the document type (tag)
     */
    DomNode( const char *doctype );
    /**
     * Creates a new document node (no memory allocation).
     * @param level the document depth of the node
     */
    void clear( int level=0 );
    /**
     * Adds a new node.
     * @param name the name of the new node (tag)
     */
    void addNode( const char *name );
    /**
     * Adds a text node.
     * @param text the text to write into the document node
     */
    void addTextNode( const char *text, TQTextCodec* codec );
    /**
     * Add border to existing frameset (see KWord DTD).
     */
    void addBorder( int id, const TQColor &color, int style, double width );
    /**
     * Add color attributes to document node.
     * @param color the color
     */
    void addColor( const TQColor &color );
    /**
    * Add rectangle attributes to document node.
    */
    void addRect( int left, int top, int right, int bottom );
    /**
     * Add pixmap or clipart key.
     * @param dt date/time
     * @param filename the filename of the image
     * @param name the relative path to the image in the store (optional)
     */
    void addKey( const TQDateTime& dt, const TQString& filename, const TQString& name = TQString() );
    /**
     * Add frameset to document (see KWord DTD).
     */
    void addFrameSet( const char *name, int frameType, int frameInfo );
    /**
     * Add frame to existing frameset (see KWord DTD).
     */
    void addFrame( int left, int top, int right, int bottom,
		   int autoCreateNewFrame, int newFrameBehaviour,
		   int sheetSide );
    /**
     * Sets a new attribute to a string value.
     */
    void setAttribute( const TQString& attribute, const TQString& value );
    /**
     * Sets a new attribute to an integer value.
     */
    void setAttribute( const char *name, int value );
    /**
     * Sets a new attribute to a double value.
     */
    void setAttribute( const char *name, double value );
    /**
     * Closes a document node.
     * @param name the node (tag) to close
     */
    void closeNode( const char *name );
    /**
     * Closes the current XML tag (if open).
     * @param nl add a newline
     */
    void closeTag( bool nl );
    /**
     * Appends a child node.
     * @param child the node to append to this document node
     */
    void appendNode( const DomNode &child );
    /**
     * Appends XML text to node
     */
    void append( const TQCString& cstr);
    void append( const TQString& _str);
    void append( const char ch);
    /**
     * Returns true if node is empty.
     */
    bool isEmpty() const;
    /**
     * Returns the data of the document node.
     */
    TQString toString() const;

private:
    TQString str;
    int documentLevel;
    bool hasChildren;
    bool hasAttributes;
};

#endif