10#include <QtCore/QList>
66 std::unique_ptr<istd::IChangeable>
pagePtr;
76 typedef std::vector<Page>
Pages;
89 return int(m_documentPages.size());
96 Q_ASSERT(pageIndex <
int(m_documentPages.size()));
97 Q_ASSERT(pageIndex >= 0);
98 Q_ASSERT(m_documentPages.at(pageIndex).pagePtr !=
nullptr);
100 return *m_documentPages.at(pageIndex).pagePtr.get();
107 Q_ASSERT(pageIndex <
int(m_documentPages.size()));
108 Q_ASSERT(pageIndex >= 0);
110 return &m_documentPages.at(pageIndex).pageMetaInfo;
119 m_documentPages.clear();
126 Q_ASSERT(pageIndex <
int(m_documentPages.size()));
127 Q_ASSERT(pageIndex >= 0);
131 auto it = m_documentPages.begin();
133 m_documentPages.erase(it);
158 return GetPagesCount();
165 Q_ASSERT(index <
int(m_documentPages.size()));
166 Q_ASSERT(index >= 0);
182 return GetOptionName(index).toUtf8();
207 return BaseClass2::Serialize(archive);
211 return isMetaInfoOk && archive.
ProcessGroupList(pagesTag, pageTag, GetPagesCount(),
212 [&](
int pageIndex,
auto& archive) {
213 this->InsertPage(
nullptr,
nullptr, pageIndex);
215 return SerializePage(archive, m_documentPages[pageIndex]);
217 [&](
int pagesCount) {
218 if (pagesCount <= 0) {
222 int oldCount = GetPagesCount();
223 for (
int i = pagesCount - 1; i >= oldCount; --i) {
226 for (
int i = oldCount; i < pagesCount; ++i) {
227 this->InsertPage(
nullptr,
nullptr, i);
243 if (sourcePtr !=
nullptr) {
246 m_documentPages.clear();
249 Q_ASSERT(sourcePageInfo.pagePtr !=
nullptr);
252 if (pagePtr ==
nullptr) {
256 if (!pagePtr->
CopyFrom(*sourcePageInfo.pagePtr)) {
260 if (!m_documentPages[m_documentPages.size()].pageMetaInfo.CopyFrom(sourcePageInfo.pageMetaInfo)) {
265 if (!BaseClass2::CopyFrom(
object, mode)) {
274 if (docPtr !=
nullptr) {
277 m_documentPages.clear();
280 for (
int pageIndex = 0; pageIndex < pagesCount; ++pageIndex) {
282 if (pagePtr ==
nullptr) {
287 if (!pagePtr->
CopyFrom(sourcePage)) {
292 if (metaInfoPtr !=
nullptr) {
293 if (!m_documentPages[pageIndex].pageMetaInfo.CopyFrom(*metaInfoPtr)) {
299 if (!BaseClass2::CopyFrom(
object, mode)) {
308 if (docProviderPtr !=
nullptr) {
310 if (sourceDocPtr !=
nullptr) {
312 return CopyFrom(*sourceDocPtr, mode);
340 if (serializablePagePtr !=
nullptr) {
341 retVal = retVal && archive.
ProcessObject(pageContentTag, *serializablePagePtr);
344 qWarning(
"Page object doesn't support serialization");
Simple interface for a structured document.
virtual const istd::IChangeable & GetDocumentPage(int pageIndex) const =0
Get the document page.
virtual const idoc::IDocumentMetaInfo * GetPageMetaInfo(int pageIndex) const =0
Get meta info of the given page if exists.
virtual int GetPagesCount() const =0
Get number of pages in the document.
Common interface for a provider of a multi-page document.
virtual const IMultiPageDocument * GetDocument() const =0
Get multi-page document instance.
Generic implementation of IMultiPageDocument interface.
bool IsOptionEnabled(int index) const override
Return true if the option is enabled and can be selected.
bool ResetData(CompatibilityMode mode) override
Reset data to its default state.
bool CopyFrom(const istd::IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS) override
Copy this object from another one.
int GetPagesCount() const override
CStandardDocumentMetaInfo BaseClass2
virtual bool SerializePage(iser::IArchive &archive, Page &pageItem)
Serialize a single page item into or from the archive.
bool Serialize(iser::IArchive &archive) override
Load or store state of this object as a archive stream.
bool RemovePage(int pageIndex) override
int GetOptionsFlags() const override
Get constraints flags.
std::vector< Page > Pages
QString GetOptionDescription(int index) const override
Get human readable description for a option with the index index.
void ResetPages() override
QByteArray GetOptionId(int index) const override
Get option ID.
const idoc::IDocumentMetaInfo * GetPageMetaInfo(int pageIndex) const override
const istd::IChangeable & GetDocumentPage(int pageIndex) const override
QString GetOptionName(int index) const override
Get name of specified option.
int GetOptionsCount() const override
Get number of managed options.
const IDocumentMetaInfo & GetDocumentMetaInfo() const override
Constraints of selection from set of possibilities.
Process tag used to group data in archive stream.
@ Group
Normal tag used for grouping of tags or processed elements.
@ Multiple
Multiple tag containing variable number of child tags.
Represent input/output persistence archive.
virtual bool ProcessGroupList(const CArchiveTag &listTag, const CArchiveTag &groupTag, int count, std::function< bool(int, IArchive &)> groupArchiveFn, std::function< bool(int)> resizeFn=nullptr)=0
Process list of elements in groups.
virtual bool ProcessObject(const CArchiveTag &tag, ISerializable &object)=0
Process object enclosed by some tag.
virtual bool ProcessGroup(const CArchiveTag &tag, std::function< bool(IArchive &)> groupArchiveFn)=0
Process some group of elements encapsulated in single tag.
virtual bool IsChanging() const =0
Check if this archive processing change the object state.
Common class for all classes which objects can be archived or restored from archive.
Help class which provides the automatic update mechanism of the model.
Common interface for data model objects, which can be changed.
CompatibilityMode
Control how relationship betweeen objects are interpreted.
@ CM_WITHOUT_REFS
External references are simple ignored.
virtual bool CopyFrom(const IChangeable &object, CompatibilityMode mode=CM_WITHOUT_REFS)
Copy this object from another one.
Contains the system indenendent basic implementations of Document/View design pattern.
idoc::TMultiPageDocumentWrap< idoc::IMultiPageDocument > CMultiPageDocumentBase
idoc::CStandardDocumentMetaInfo pageMetaInfo
std::unique_ptr< istd::IChangeable > pagePtr