filters

kword13parser.h
1/*
2 This file is part of the KDE project
3 Copyright (C) 2004 Nicolas GOUTTE <goutte@kde.org>
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KWORD_1_3_PARSER_H
22#define KWORD_1_3_PARSER_H
23
24#include <tqxml.h>
25#include <tqptrstack.h>
26
28class KWord13Document;
29class KWord13Frameset;
30class KWord13Layout;
31class KWord13Format;
32
38enum KWord13StackItemType
39{
40 KWord13TypeUnknown = 0,
41 KWord13TypeBottom,
42 KWord13TypeIgnore,
43 KWord13TypeEmpty,
44 KWord13TypeDocument,
45 KWord13TypePaper,
46 KWord13TypeFrameset,
47 KWord13TypeUnknownFrameset,
48 KWord13TypeParagraph,
49 KWord13TypeText,
50 KWord13TypeLayout,
51 KWord13TypeFormat,
52 KWord13TypeLayoutFormatOne,
53 KWord13TypeFormatsPlural,
54 KWord13TypeVariable,
55 KWord13TypePicturesPlural,
56 KWord13TypePictureFrameset,
57 KWord13TypePicture,
58 KWord13TypeAnchor
59};
60
61class KWord13StackItem
62{
63public:
64 KWord13StackItem();
65 ~KWord13StackItem();
66public:
67 TQString itemName;
68 KWord13StackItemType elementType;
69 KWord13Frameset* m_currentFrameset;
70};
71
72class KWord13StackItemStack : public TQPtrStack<KWord13StackItem>
73{
74public:
75 KWord13StackItemStack(void) { }
76 ~KWord13StackItemStack(void) { }
77};
78
79class KWord13Parser : public TQXmlDefaultHandler
80{
81public:
82 KWord13Parser( KWord13Document* kwordDocument );
83 virtual ~KWord13Parser( void );
84protected: //TQXml
86 virtual bool startElement( const TQString&, const TQString&, const TQString& name, const TQXmlAttributes& attributes);
88 virtual bool endElement( const TQString&, const TQString& , const TQString& qName);
90 virtual bool characters ( const TQString & ch );
91 virtual bool warning(const TQXmlParseException& exception);
92 virtual bool error(const TQXmlParseException& exception);
93 virtual bool fatalError(const TQXmlParseException& exception);
94protected:
96 bool startElementFormatOneProperty( const TQString& name, const TQXmlAttributes& attributes, KWord13StackItem *stackItem);
98 bool startElementLayoutProperty( const TQString& name, const TQXmlAttributes& attributes, KWord13StackItem *stackItem);
100 bool startElementName( const TQString&, const TQXmlAttributes& attributes, KWord13StackItem *stackItem );
102 bool startElementFormat( const TQString&, const TQXmlAttributes& attributes, KWord13StackItem *stackItem );
104 bool startElementLayout( const TQString&, const TQXmlAttributes&, KWord13StackItem *stackItem );
106 bool startElementParagraph( const TQString& name, const TQXmlAttributes& attributes, KWord13StackItem *stackItem );
108 bool startElementFrame( const TQString& name, const TQXmlAttributes& attributes, KWord13StackItem *stackItem );
110 bool startElementFrameset( const TQString& name, const TQXmlAttributes& attributes, KWord13StackItem *stackItem );
112 bool startElementDocumentAttributes( const TQString& name, const TQXmlAttributes& attributes,
113 KWord13StackItem *stackItem, const KWord13StackItemType& allowedParentType, const KWord13StackItemType& newType );
115 bool startElementKey( const TQString& name, const TQXmlAttributes& attributes, KWord13StackItem *stackItem );
117 bool startElementAnchor( const TQString& name, const TQXmlAttributes& attributes, KWord13StackItem *stackItem );
123 TQString calculatePictureKey( const TQString& filename,
124 const TQString& year, const TQString& month, const TQString& day,
125 const TQString& hour, const TQString& minute, const TQString& second,
126 const TQString& microsecond ) const;
127protected:
128 TQString indent; //DEBUG
129 KWord13StackItemStack parserStack;
130 KWord13Document* m_kwordDocument;
131 KWord13Paragraph* m_currentParagraph;
132 KWord13Layout* m_currentLayout;
133 KWord13Format* m_currentFormat;
134};
135
136#endif // KWORD_1_3_PARSER_H
Basic classes for all format classes.
Layout or style.