MCPcopy Create free account
hub / github.com/Sigil-Ebook/Sigil / AddGuideSemanticCode

Method AddGuideSemanticCode

src/ResourceObjects/OPFResource.cpp:962–981  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

960
961
962void OPFResource::AddGuideSemanticCode(HTMLResource *html_resource, QString new_code, bool toggle, QString tgt_id)
963{
964 //first get primary book language
965 QString lang = GetPrimaryBookLanguage();
966 QWriteLocker locker(&GetLock());
967 QString source = CleanSource::ProcessXML(GetText(),"application/oebps-package+xml");
968 OPFParser p;
969 p.parse(source);
970 QString current_code = GetGuideSemanticCodeForResource(html_resource, p, tgt_id);
971
972 if ((current_code != new_code) || !toggle) {
973 RemoveDuplicateGuideCodes(new_code, p);
974 SetGuideSemanticCodeForResource(new_code, html_resource, p, lang, tgt_id);
975 } else {
976 // If the current code is the same as the new one,
977 // we toggle it off.
978 RemoveGuideReferenceForResource(html_resource, p, tgt_id);
979 }
980 UpdateText(p);
981}
982
983QString OPFResource::GetGuideSemanticCodeForResource(const Resource *resource, const OPFParser &p, QString tgt_id) const
984{

Callers 5

AddCoverMethod · 0.80
foreachFunction · 0.80
CreateIndexMethod · 0.80
CreateHTMLTOCMethod · 0.80
AddSemanticCodeMethod · 0.80

Calls 1

parseMethod · 0.45

Tested by

no test coverage detected