filters

kword13parser.h

00001 /*
00002    This file is part of the KDE project
00003    Copyright (C) 2004 Nicolas GOUTTE <goutte@kde.org>
00004 
00005    This program is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU General Public License
00007    as published by the Free Software Foundation; either version 2
00008    of the License, or (at your option) any later version.
00009 
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014 
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software
00017    Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef KWORD_1_3_PARSER_H
00022 #define KWORD_1_3_PARSER_H
00023 
00024 #include <qxml.h>
00025 #include <qptrstack.h>
00026 
00027 class KWord13Paragraph;
00028 class KWord13Document;
00029 class KWord13Frameset;
00030 class KWord13Layout;
00031 class KWord13Format;
00032 
00038 enum KWord13StackItemType
00039 {
00040     KWord13TypeUnknown  = 0,
00041     KWord13TypeBottom,      
00042     KWord13TypeIgnore,      
00043     KWord13TypeEmpty,       
00044     KWord13TypeDocument,    
00045     KWord13TypePaper,       
00046     KWord13TypeFrameset,    
00047     KWord13TypeUnknownFrameset, 
00048     KWord13TypeParagraph,   
00049     KWord13TypeText,        
00050     KWord13TypeLayout,      
00051     KWord13TypeFormat,      
00052     KWord13TypeLayoutFormatOne,
00053     KWord13TypeFormatsPlural,
00054     KWord13TypeVariable,        
00055     KWord13TypePicturesPlural,  
00056     KWord13TypePictureFrameset, 
00057     KWord13TypePicture,         
00058     KWord13TypeAnchor           
00059 };
00060 
00061 class KWord13StackItem
00062 {
00063 public:
00064     KWord13StackItem();
00065     ~KWord13StackItem();
00066 public:
00067     QString itemName;   
00068     KWord13StackItemType elementType;
00069     KWord13Frameset* m_currentFrameset;
00070 };
00071 
00072 class KWord13StackItemStack : public QPtrStack<KWord13StackItem>
00073 {
00074 public:
00075         KWord13StackItemStack(void) { }
00076         ~KWord13StackItemStack(void) { }
00077 };
00078 
00079 class KWord13Parser : public QXmlDefaultHandler
00080 {
00081 public:
00082     KWord13Parser( KWord13Document* kwordDocument );
00083     virtual ~KWord13Parser( void );
00084 protected: //QXml
00086     virtual bool startElement( const QString&, const QString&, const QString& name, const QXmlAttributes& attributes);
00088     virtual bool endElement( const QString&, const QString& , const QString& qName);
00090     virtual bool characters ( const QString & ch );
00091     virtual bool warning(const QXmlParseException& exception);
00092     virtual bool error(const QXmlParseException& exception);
00093     virtual bool fatalError(const QXmlParseException& exception);
00094 protected:
00096     bool startElementFormatOneProperty( const QString& name, const QXmlAttributes& attributes, KWord13StackItem *stackItem);
00098     bool startElementLayoutProperty( const QString& name, const QXmlAttributes& attributes, KWord13StackItem *stackItem);
00100     bool startElementName( const QString&, const QXmlAttributes& attributes, KWord13StackItem *stackItem );
00102     bool startElementFormat( const QString&, const QXmlAttributes& attributes, KWord13StackItem *stackItem );
00104     bool startElementLayout( const QString&, const QXmlAttributes&, KWord13StackItem *stackItem );
00106     bool startElementParagraph( const QString& name, const QXmlAttributes& attributes, KWord13StackItem *stackItem );
00108     bool startElementFrame( const QString& name, const QXmlAttributes& attributes, KWord13StackItem *stackItem );
00110     bool startElementFrameset( const QString& name, const QXmlAttributes& attributes, KWord13StackItem *stackItem );
00112     bool startElementDocumentAttributes( const QString& name, const QXmlAttributes& attributes,
00113         KWord13StackItem *stackItem, const KWord13StackItemType& allowedParentType, const KWord13StackItemType& newType );
00115     bool startElementKey( const QString& name, const QXmlAttributes& attributes, KWord13StackItem *stackItem );
00117     bool startElementAnchor( const QString& name, const QXmlAttributes& attributes, KWord13StackItem *stackItem );
00123     QString calculatePictureKey( const QString& filename,
00124      const QString& year,  const QString& month,  const QString& day,
00125      const QString& hour,  const QString& minute,  const QString& second,
00126      const QString& microsecond ) const;
00127 protected:
00128     QString indent; //DEBUG
00129     KWord13StackItemStack parserStack;
00130     KWord13Document* m_kwordDocument;
00131     KWord13Paragraph* m_currentParagraph; 
00132     KWord13Layout* m_currentLayout; 
00133     KWord13Format* m_currentFormat; 
00134 };
00135 
00136 #endif // KWORD_1_3_PARSER_H
KDE Home | KDE Accessibility Home | Description of Access Keys