FB2TableContext.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* libe-book
00003  * Version: MPL 2.0 / LGPLv2.1+
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  *
00009  * Alternatively, the contents of this file may be used under the terms
00010  * of the GNU Lesser General Public License Version 2.1 or later
00011  * (LGPLv2.1+), in which case the provisions of the LGPLv2.1+ are
00012  * applicable instead of those above.
00013  *
00014  * For further information visit http://libebook.sourceforge.net
00015  */
00016 
00017 #ifndef FB2TABLECONTEXT_H_INCLUDED
00018 #define FB2TABLECONTEXT_H_INCLUDED
00019 
00020 #include "FB2ParserContext.h"
00021 
00022 namespace libebook
00023 {
00024 
00025 class FB2TableModel;
00026 
00027 class FB2TableContext : public FB2BlockFormatContextBase
00028 {
00029   // disable copying
00030   FB2TableContext(const FB2TableContext &other);
00031   FB2TableContext &operator=(const FB2TableContext &other);
00032 
00033 public:
00034   FB2TableContext(FB2ParserContext *parentContext, const FB2BlockFormat &format);
00035   virtual ~FB2TableContext();
00036 
00037 private:
00038   virtual FB2XMLParserContext *element(const EBOOKToken &name, const EBOOKToken &ns);
00039   virtual void startOfElement();
00040   virtual void endOfElement();
00041   virtual void attribute(const EBOOKToken &name, const EBOOKToken *ns, const char *value);
00042 
00043 private:
00044   FB2TableModel *m_model;
00045 };
00046 
00047 class FB2CellContext : public FB2StyleContextBase
00048 {
00049   // disable copying
00050   FB2CellContext(const FB2CellContext &other);
00051   FB2CellContext &operator=(const FB2CellContext &other);
00052 
00053 public:
00054   FB2CellContext(FB2ParserContext *parentContext, FB2TableModel *model, const FB2BlockFormat &format, bool header);
00055 
00056 private:
00057   virtual void startOfElement();
00058   virtual void endOfElement();
00059   virtual void attribute(const EBOOKToken &name, const EBOOKToken *ns, const char *value);
00060   virtual void endOfAttributes();
00061 
00062   void openCell();
00063 
00064 private:
00065   FB2TableModel *const m_model;
00066   const bool m_header;
00067   bool m_opened;
00068   int m_columnSpan;
00069   int m_rowSpan;
00070   size_t m_coveredColumns;
00071 };
00072 
00073 class FB2TrContext : public FB2BlockFormatContextBase
00074 {
00075   // no copying
00076   FB2TrContext(const FB2TrContext &);
00077   FB2TrContext &operator=(const FB2TrContext &);
00078 
00079 public:
00080   FB2TrContext(FB2ParserContext *parentContext, FB2TableModel *model, const FB2BlockFormat &format);
00081 
00082 private:
00083   virtual FB2XMLParserContext *element(const EBOOKToken &name, const EBOOKToken &ns);
00084   virtual void endOfElement();
00085   virtual void attribute(const EBOOKToken &name, const EBOOKToken *ns, const char *value);
00086 
00087   void openRow(bool header);
00088 
00089 private:
00090   FB2TableModel *m_model;
00091   bool m_opened;
00092 };
00093 
00094 }
00095 
00096 #endif // FB2TABLECONTEXT_H_INCLUDED
00097 
00098 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */