Created
March 15, 2014 18:05
-
-
Save takahashim/9571380 to your computer and use it in GitHub Desktop.
SigilでEPUB3を開いて保存しても壊さないようにするpatchその2 (※Preferece->Clean SourceでOpenもSaveもチェックを外しておくこと)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ git diff | |
diff --git a/src/Sigil/ResourceObjects/OPFResource.cpp b/src/Sigil/ResourceObjects/OPFResource.cpp | |
index bfb11e9..1918925 100644 | |
--- a/src/Sigil/ResourceObjects/OPFResource.cpp | |
+++ b/src/Sigil/ResourceObjects/OPFResource.cpp | |
@@ -1196,8 +1196,9 @@ void OPFResource::AddModificationDateMeta() | |
XhtmlDoc::GetTagMatchingDescendants(*document, "date", DUBLIN_CORE_NS); | |
foreach(xc::DOMElement * meta, metas) { | |
QString name = XtoQ(meta->getAttribute(QtoX("opf:event"))); | |
+ QString epub_version = GetEpubVersion(*document); | |
- if (name == "modification") { | |
+ if (name == "modification" || epub_version == "3.0") { | |
meta->setTextContent(QtoX(date)); | |
UpdateTextFromDom(*document); | |
return; | |
@@ -1438,6 +1439,17 @@ void OPFResource::FillWithDefaultText() | |
} | |
+QString OPFResource::GetEpubVersion(const xc::DOMDocument &document) const | |
+{ | |
+ xc::DOMElement *package = GetPackageElement(document); | |
+ if (!package) { | |
+ return NULL; | |
+ } | |
+ QString epub_version = XtoQ(package->getAttribute(QtoX("version"))); | |
+ return epub_version; | |
+} | |
+ | |
+ | |
QString OPFResource::GetUniqueID(const QString &preferred_id, const xc::DOMDocument &document) const | |
{ | |
xc::DOMElement *element = document.getElementById(QtoX(preferred_id)); | |
diff --git a/src/Sigil/ResourceObjects/OPFResource.h b/src/Sigil/ResourceObjects/OPFResource.h | |
index a50e74e..69ab34b 100644 | |
--- a/src/Sigil/ResourceObjects/OPFResource.h | |
+++ b/src/Sigil/ResourceObjects/OPFResource.h | |
@@ -271,6 +271,8 @@ private: | |
void FillWithDefaultText(); | |
+ QString GetEpubVersion(const xc::DOMDocument &document) const; | |
+ | |
QString GetUniqueID(const QString &preferred_id, const xc::DOMDocument &document) const; | |
QString GetResourceMimetype(const Resource &resource) const; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment