void TocManager::refresh() { Poppler::Document *doc = Poppler::Document::load(_path); if (doc) { QList<Choice> choices; QUrl docUrl("file:" + _path); QDomDocument *toc = doc->toc(); if (toc) { QDomNode child = toc->documentElement(); copyToc(docUrl, doc, child, choices, 0); /* while (!child.isNull()) { if (child.isElement()) { QDomElement el = child.toElement(); QString destName = el.attribute("DestinationName", ""); Poppler::LinkDestination *dest = doc->linkDestination(destName); QUrl url("file:" + _path + "#page:" + QString::number(dest->pageNumber())); choices << Choice(el.nodeName(), url.toString()); delete dest; } child = child.nextSibling(); } */ delete toc; } else { qDebug() << "NO TOC"; } emit contentsChanged(choices); } delete doc; }
void TopicTemplate::resolveString(const std::string& varName, const std::vector<Wt::WString>& args, std::ostream& result) { if (varName == "doc-link") { std::string className = args[0].toUTF8(); #ifndef WT_TARGET_JAVA boost::replace_all(className, "-", "::"); #else boost::replace_all(className, "Render-", "render."); #endif result << "<a href=\"" << docUrl(className) << "\" target=\"_blank\">"; #ifdef WT_TARGET_JAVA boost::replace_all(className, "render.", ""); #endif // WT_TARGET_JAVA result << className << "</a>"; } else if (varName == "src") { std::string exampleName = args[0].toUTF8(); result << "<fieldset class=\"src\">" << "<legend>source</legend>" << tr("src-" + exampleName).toUTF8() << "</fieldset>"; } else WTemplate::resolveString(varName, args, result); }
bool KateBuildView::buildCurrentTarget() { if (m_proc->state() != QProcess::NotRunning) { displayBuildResult(i18n("Already building..."), KTextEditor::Message::Warning); return false; } QFileInfo docFInfo = docUrl().toLocalFile(); // docUrl() saves the current document QModelIndex ind = m_targetsUi->targetsView->currentIndex(); m_previousIndex = ind; if (!ind.isValid()) { KMessageBox::sorry(0, i18n("No target available for building.")); return false; } QString buildCmd = m_targetsUi->targetsModel.command(ind); QString cmdName = m_targetsUi->targetsModel.cmdName(ind); QString workDir = m_targetsUi->targetsModel.workDir(ind); QString targetSet = m_targetsUi->targetsModel.targetName(ind); QString dir = workDir; if (workDir.isEmpty()) { dir = docFInfo.absolutePath(); if (dir.isEmpty()) { KMessageBox::sorry(0, i18n("There is no local file or directory specified for building.")); return false; } } // Check if the command contains the file name or directory if (buildCmd.contains(QStringLiteral("%f")) || buildCmd.contains(QStringLiteral("%d")) || buildCmd.contains(QStringLiteral("%n"))) { if (docFInfo.absoluteFilePath().isEmpty()) { return false; } buildCmd.replace(QStringLiteral("%n"), docFInfo.baseName()); buildCmd.replace(QStringLiteral("%f"), docFInfo.absoluteFilePath()); buildCmd.replace(QStringLiteral("%d"), docFInfo.absolutePath()); } m_filenameDetectorGccWorked = false; m_currentlyBuildingTarget = QStringLiteral("%1: %2").arg(targetSet).arg(cmdName); m_buildCancelled = false; QString msg = i18n("Building target <b>%1</b> ...", m_currentlyBuildingTarget); m_buildUi.buildStatusLabel->setText(msg); m_buildUi.buildStatusLabel2->setText(msg); return startProcess(dir, buildCmd); }
static void retrieveNode(txExecutionState* aExecutionState, const nsAString& aUri, const nsAString& aBaseUri, txNodeSet* aNodeSet) { nsAutoString absUrl; URIUtils::resolveHref(aUri, aBaseUri, absUrl); PRInt32 hash = absUrl.RFindChar(PRUnichar('#')); PRUint32 urlEnd, fragStart, fragEnd; if (hash == kNotFound) { urlEnd = absUrl.Length(); fragStart = 0; fragEnd = 0; } else { urlEnd = hash; fragStart = hash + 1; fragEnd = absUrl.Length(); } nsDependentSubstring docUrl(absUrl, 0, urlEnd); nsDependentSubstring frag(absUrl, fragStart, fragEnd); const txXPathNode* loadNode = aExecutionState->retrieveDocument(docUrl); if (loadNode) { if (frag.IsEmpty()) { aNodeSet->add(*loadNode); } else { txXPathTreeWalker walker(*loadNode); if (walker.moveToElementById(frag)) { aNodeSet->add(walker.getCurrentPosition()); } } } }