[fbreader] Prevent a crash in <aside> blocks
This commit is contained in:
parent
556c3bd351
commit
85a121633b
4 changed files with 55 additions and 30 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2004-2010 Geometer Plus <contact@geometerplus.com>
|
* Copyright (C) 2004-2010 Geometer Plus <contact@geometerplus.com>
|
||||||
* Copyright (C) 2016 Slava Monich <slava.monich@jolla.com>
|
* Copyright (C) 2016-2019 Slava Monich <slava.monich@jolla.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -32,6 +32,8 @@ BookReader::BookReader(BookModel &model) : myModel(model) {
|
||||||
|
|
||||||
myTextParagraphExists = false;
|
myTextParagraphExists = false;
|
||||||
myContentsParagraphExists = false;
|
myContentsParagraphExists = false;
|
||||||
|
myBookTextParagraphExists = false;
|
||||||
|
myBookContentsParagraphExists = false;
|
||||||
|
|
||||||
myInsideTitle = false;
|
myInsideTitle = false;
|
||||||
mySectionContainsRegularContents = false;
|
mySectionContainsRegularContents = false;
|
||||||
|
@ -41,10 +43,20 @@ BookReader::~BookReader() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookReader::setMainTextModel() {
|
void BookReader::setMainTextModel() {
|
||||||
|
if (myCurrentTextModel != myModel.myBookTextModel) {
|
||||||
myCurrentTextModel = myModel.myBookTextModel;
|
myCurrentTextModel = myModel.myBookTextModel;
|
||||||
|
myTextParagraphExists = myBookTextParagraphExists;
|
||||||
|
myContentsParagraphExists = myBookContentsParagraphExists;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BookReader::setFootnoteTextModel(const std::string &id) {
|
void BookReader::setFootnoteTextModel(const std::string &id) {
|
||||||
|
if (myCurrentTextModel == myModel.myBookTextModel) {
|
||||||
|
myBookTextParagraphExists = myTextParagraphExists;
|
||||||
|
myBookContentsParagraphExists = myContentsParagraphExists;
|
||||||
|
}
|
||||||
|
myTextParagraphExists = false;
|
||||||
|
myContentsParagraphExists = false;
|
||||||
std::map<std::string,shared_ptr<ZLTextModel> >::iterator it = myModel.myFootnotes.find(id);
|
std::map<std::string,shared_ptr<ZLTextModel> >::iterator it = myModel.myFootnotes.find(id);
|
||||||
if (it != myModel.myFootnotes.end()) {
|
if (it != myModel.myFootnotes.end()) {
|
||||||
myCurrentTextModel = (*it).second;
|
myCurrentTextModel = (*it).second;
|
||||||
|
@ -54,6 +66,14 @@ void BookReader::setFootnoteTextModel(const std::string &id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BookReader::setFootnoteTextModel(const std::string &id, const std::string &alt)
|
||||||
|
{
|
||||||
|
setFootnoteTextModel(id);
|
||||||
|
if (!alt.empty() && myModel.myFootnotes.find(alt) == myModel.myFootnotes.end()) {
|
||||||
|
myModel.myFootnotes.insert(std::make_pair(alt, myCurrentTextModel));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BookReader::unsetTextModel() {
|
void BookReader::unsetTextModel() {
|
||||||
myCurrentTextModel = 0;
|
myCurrentTextModel = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2004-2010 Geometer Plus <contact@geometerplus.com>
|
* Copyright (C) 2004-2010 Geometer Plus <contact@geometerplus.com>
|
||||||
|
* Copyright (C) 2016-2019 Slava Monich <slava.monich@jolla.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -40,6 +41,7 @@ public:
|
||||||
|
|
||||||
void setMainTextModel();
|
void setMainTextModel();
|
||||||
void setFootnoteTextModel(const std::string &id);
|
void setFootnoteTextModel(const std::string &id);
|
||||||
|
void setFootnoteTextModel(const std::string &id, const std::string &alt);
|
||||||
void unsetTextModel();
|
void unsetTextModel();
|
||||||
|
|
||||||
void insertEndOfSectionParagraph();
|
void insertEndOfSectionParagraph();
|
||||||
|
@ -91,6 +93,8 @@ private:
|
||||||
|
|
||||||
bool myTextParagraphExists;
|
bool myTextParagraphExists;
|
||||||
bool myContentsParagraphExists;
|
bool myContentsParagraphExists;
|
||||||
|
bool myBookTextParagraphExists;
|
||||||
|
bool myBookContentsParagraphExists;
|
||||||
std::stack<ZLTextTreeParagraph*> myTOCStack;
|
std::stack<ZLTextTreeParagraph*> myTOCStack;
|
||||||
bool myLastTOCParagraphIsEmpty;
|
bool myLastTOCParagraphIsEmpty;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2004-2010 Geometer Plus <contact@geometerplus.com>
|
* Copyright (C) 2004-2010 Geometer Plus <contact@geometerplus.com>
|
||||||
* Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
|
* Copyright (C) 2016-2019 Slava Monich <slava.monich@jolla.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -394,7 +394,7 @@ XHTMLTagFootnoteAction::XHTMLTagFootnoteAction() {
|
||||||
void XHTMLTagFootnoteAction::doAtStart(XHTMLReader &reader, const char **xmlattributes) {
|
void XHTMLTagFootnoteAction::doAtStart(XHTMLReader &reader, const char **xmlattributes) {
|
||||||
const char *id = reader.attributeValue(xmlattributes, "id");
|
const char *id = reader.attributeValue(xmlattributes, "id");
|
||||||
if (id) {
|
if (id) {
|
||||||
bookReader(reader).setFootnoteTextModel(id);
|
bookReader(reader).setFootnoteTextModel(id, reader.myReferenceName + "#" + id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2004-2010 Geometer Plus <contact@geometerplus.com>
|
* Copyright (C) 2004-2010 Geometer Plus <contact@geometerplus.com>
|
||||||
* Copyright (C) 2016-2018 Slava Monich <slava.monich@jolla.com>
|
* Copyright (C) 2016-2019 Slava Monich <slava.monich@jolla.com>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -126,6 +126,7 @@ private:
|
||||||
friend class XHTMLTagParagraphWithControlAction;
|
friend class XHTMLTagParagraphWithControlAction;
|
||||||
friend class XHTMLTagBodyAction;
|
friend class XHTMLTagBodyAction;
|
||||||
friend class XHTMLTagImageAction;
|
friend class XHTMLTagImageAction;
|
||||||
|
friend class XHTMLTagFootnoteAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __XHTMLREADER_H__ */
|
#endif /* __XHTMLREADER_H__ */
|
||||||
|
|
Loading…
Reference in a new issue