FB2TableContext.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libe-book project.
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 
00010 #ifndef FB2TABLECONTEXT_H_INCLUDED
00011 #define FB2TABLECONTEXT_H_INCLUDED
00012 
00013 #include "FB2ParserContext.h"
00014 
00015 namespace libebook
00016 {
00017 
00018 class FB2TableModel;
00019 
00020 class FB2TableContext : public FB2BlockFormatContextBase
00021 {
00022   // disable copying
00023   FB2TableContext(const FB2TableContext &other);
00024   FB2TableContext &operator=(const FB2TableContext &other);
00025 
00026 public:
00027   FB2TableContext(FB2ParserContext *parentContext, const FB2BlockFormat &format);
00028   virtual ~FB2TableContext();
00029 
00030 private:
00031   virtual FB2XMLParserContext *element(const FB2TokenData &name, const FB2TokenData &ns);
00032   virtual void startOfElement();
00033   virtual void endOfElement();
00034   virtual void attribute(const FB2TokenData &name, const FB2TokenData *ns, const char *value);
00035 
00036 private:
00037   FB2TableModel *m_model;
00038 };
00039 
00040 class FB2CellContext : public FB2StyleContextBase
00041 {
00042   // disable copying
00043   FB2CellContext(const FB2CellContext &other);
00044   FB2CellContext &operator=(const FB2CellContext &other);
00045 
00046 public:
00047   FB2CellContext(FB2ParserContext *parentContext, FB2TableModel *model, const FB2BlockFormat &format, bool header);
00048 
00049 private:
00050   virtual void startOfElement();
00051   virtual void endOfElement();
00052   virtual void attribute(const FB2TokenData &name, const FB2TokenData *ns, const char *value);
00053   virtual void endOfAttributes();
00054 
00055   void openCell();
00056 
00057 private:
00058   FB2TableModel *const m_model;
00059   const bool m_header;
00060   bool m_opened;
00061   int m_columnSpan;
00062   int m_rowSpan;
00063   size_t m_coveredColumns;
00064 };
00065 
00066 class FB2TrContext : public FB2BlockFormatContextBase
00067 {
00068   // no copying
00069   FB2TrContext(const FB2TrContext &);
00070   FB2TrContext &operator=(const FB2TrContext &);
00071 
00072 public:
00073   FB2TrContext(FB2ParserContext *parentContext, FB2TableModel *model, const FB2BlockFormat &format);
00074 
00075 private:
00076   virtual FB2XMLParserContext *element(const FB2TokenData &name, const FB2TokenData &ns);
00077   virtual void endOfElement();
00078   virtual void attribute(const FB2TokenData &name, const FB2TokenData *ns, const char *value);
00079 
00080   void openRow(bool header);
00081 
00082 private:
00083   FB2TableModel *m_model;
00084   bool m_opened;
00085 };
00086 
00087 }
00088 
00089 #endif // FB2TABLECONTEXT_H_INCLUDED
00090 
00091 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */