| 960 | |
| 961 | |
| 962 | void 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 | |
| 983 | QString OPFResource::GetGuideSemanticCodeForResource(const Resource *resource, const OPFParser &p, QString tgt_id) const |
| 984 | { |
no test coverage detected