| 1 |
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the libepubgen project. |
| 4 |
* |
| 5 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 6 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 8 |
*/ |
| 9 |
|
| 10 |
#ifndef INCLUDED_EPUBSPLITGUARD_H |
| 11 |
#define INCLUDED_EPUBSPLITGUARD_H |
| 12 |
|
| 13 |
#include <libepubgen/libepubgen-decls.h> |
| 14 |
|
| 15 |
namespace libepubgen |
| 16 |
{ |
| 17 |
|
| 18 |
class EPUBSplitGuard |
| 19 |
{ |
| 20 |
public: |
| 21 |
explicit EPUBSplitGuard(EPUBSplitMethod method,bool splitOnSecondPageSpan); |
| 22 |
|
| 23 |
void setSplitHeadingLevel(unsigned level); |
| 24 |
void setCurrentHeadingLevel(unsigned level); |
| 25 |
void setSplitSize(unsigned size); |
| 26 |
void setHtmlEverInPageSpan(bool value); |
| 27 |
/// Allows overwriting the value given in the constructor. |
| 28 |
void setSplitMethod(EPUBSplitMethod method); |
| 29 |
void setSplitOnSecondPageSpan(bool value); |
| 30 |
|
| 31 |
void openLevel(); |
| 32 |
void closeLevel(); |
| 33 |
void incrementSize(unsigned size); |
| 34 |
|
| 35 |
bool splitOnPageBreak() const; |
| 36 |
bool splitOnHeading(unsigned level) const; |
| 37 |
bool splitOnSecondPageSpan() const; |
| 38 |
bool inHeading(bool any) const; |
| 39 |
bool splitOnSize() const; |
| 40 |
|
| 41 |
void onSplit(); |
| 42 |
|
| 43 |
private: |
| 44 |
bool canSplit(EPUBSplitMethod method) const; |
| 45 |
|
| 46 |
private: |
| 47 |
EPUBSplitMethod m_method; |
| 48 |
bool m_splitOnSecondPageSpan; |
| 49 |
bool m_htmlEverInPageSpan; |
| 50 |
unsigned m_headingLevel; |
| 51 |
unsigned m_currentHeadingLevel; |
| 52 |
unsigned m_size; |
| 53 |
unsigned m_currentSize; |
| 54 |
unsigned m_nestingLevel; |
| 55 |
}; |
| 56 |
|
| 57 |
} |
| 58 |
|
| 59 |
#endif // INCLUDED_EPUBSPLITGUARD |
| 60 |
|
| 61 |
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ |