EPUBSplitGuard.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 libepubgen 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 INCLUDED_EPUBSPLITGUARD_H
00011 #define INCLUDED_EPUBSPLITGUARD_H
00012 
00013 #include <libepubgen/libepubgen.h>
00014 
00015 namespace libepubgen
00016 {
00017 
00018 class EPUBSplitGuard
00019 {
00020 public:
00021   explicit EPUBSplitGuard(EPUBSplitMethod method);
00022 
00023   void setSplitHeadingLevel(unsigned level);
00024   void setCurrentHeadingLevel(unsigned level);
00025   void setSplitSize(unsigned size);
00027   void setSplitMethod(EPUBSplitMethod method);
00028 
00029   void openLevel();
00030   void closeLevel();
00031   void incrementSize(unsigned size);
00032 
00033   bool splitOnPageBreak() const;
00034   bool splitOnHeading(unsigned level) const;
00035   bool inHeading(bool any) const;
00036   bool splitOnSize() const;
00037 
00038   void onSplit();
00039 
00040 private:
00041   bool canSplit(EPUBSplitMethod method) const;
00042 
00043 private:
00044   EPUBSplitMethod m_method;
00045   unsigned m_headingLevel;
00046   unsigned m_currentHeadingLevel;
00047   unsigned m_size;
00048   unsigned m_currentSize;
00049   unsigned m_nestingLevel;
00050 };
00051 
00052 }
00053 
00054 #endif // INCLUDED_EPUBSPLITGUARD
00055 
00056 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */