static void copyToc(const QUrl &docUrl, Poppler::Document *doc, QDomNode node, QList<Choice> &choices, int indent) { while (!node.isNull()) { if (node.isElement()) { QDomElement el = node.toElement(); QString destName = el.attribute("DestinationName", QString()); if (!destName.isNull()) { Poppler::LinkDestination *dest = doc->linkDestination(destName); QUrl refUrl(docUrl); refUrl.setFragment("page:" + QString::number(dest->pageNumber() - 1)); delete dest; QString displayName(QString(indent * 2, ' ') + el.nodeName()); choices << Choice(displayName, refUrl.toString()); } } if (node.hasChildNodes()) { copyToc(docUrl, doc, node.firstChild(), choices, indent + 1); } node = node.nextSibling(); } }
void CHttpUrl::ParseUrl(std::string const &url) { try { boost::string_ref refUrl(url); size_t begin = 0; m_protocol = CheckProtocol(refUrl, begin); if (m_protocol == Protocol::HTTPS) { m_port = 443u; } else { m_port = 80u; } m_domain = ValidateDomainName(ParseDomainName(url.substr(begin), begin)); m_document = ValidateDocumentName(url.substr(begin)); } catch (std::invalid_argument const &e) { throw CUrlParsingError(e.what()); } }