void KoDocumentInfoDlg::slotToggleEncryption() { KoDocument* doc = dynamic_cast< KoDocument* >(d->m_info->parent()); if (!doc) return; d->m_toggleEncryption = !d->m_toggleEncryption; if (doc->specialOutputFlag() == KoDocument::SaveEncrypted) { if (d->m_toggleEncryption) { QPixmap p = KIconLoader::global()->loadIcon("object-unlocked", KIconLoader::Small); d->m_aboutUi->lblEncrypted->setText(i18n("This document will be decrypted")); d->m_aboutUi->lblEncryptedPic->setPixmap(p); d->m_aboutUi->pbEncrypt->setText(i18n("Do not decrypt")); } else { QPixmap p = KIconLoader::global()->loadIcon("object-locked", KIconLoader::Small); d->m_aboutUi->lblEncrypted->setText(i18n("This document is encrypted")); d->m_aboutUi->lblEncryptedPic->setPixmap(p); d->m_aboutUi->pbEncrypt->setText(i18n("D&ecrypt")); } } else { if (d->m_toggleEncryption) { QPixmap p = KIconLoader::global()->loadIcon("object-locked", KIconLoader::Small); d->m_aboutUi->lblEncrypted->setText(i18n("This document will be encrypted.")); d->m_aboutUi->lblEncryptedPic->setPixmap(p); d->m_aboutUi->pbEncrypt->setText(i18n("Do not encrypt")); } else { QPixmap p = KIconLoader::global()->loadIcon("object-unlocked", KIconLoader::Small); d->m_aboutUi->lblEncrypted->setText(i18n("This document is not encrypted")); d->m_aboutUi->lblEncryptedPic->setPixmap(p); d->m_aboutUi->pbEncrypt->setText(i18n("&Encrypt")); } } }
KoDocument* openFile(const QString &filename) { const QString mimetype = KMimeType::findByPath(filename)->name(); QString error; KoPart *part = KMimeTypeTrader::self()->createInstanceFromQuery<KoPart>( mimetype, QLatin1String("Calligra/Part"), 0, QString(), QVariantList(), &error ); if (!error.isEmpty()) { qWarning() << "Error creating document" << mimetype << error; return 0; } KoDocument *document = part->document(); if (0 != document) { KUrl url; url.setPath(filename); document->setCheckAutoSaveFile(false); document->setAutoErrorHandlingEnabled(false); if (document->openUrl(filename)) { document->setReadWrite(false); } else { kWarning(31000)<< "openUrl failed" << filename << mimetype << error; delete document; document = 0; } } return document; }
void KoView::newView() { assert( ( d!=0L && d->m_doc ) ); KoDocument *thisDocument = d->m_doc; KoMainWindow *shell = new KoMainWindow( thisDocument->instance() ); shell->setRootDocument(thisDocument); shell->show(); }
void KoDocumentInfoAbout::saveParameters() { KoDocument* doc = dynamic_cast< KoDocument* >( m_docInfo->parent() ); if ( m_firstSave && doc && !doc->isAutosaving() ) m_editingCycles++; m_modificationDate = QDateTime::currentDateTime(); m_firstSave = false; }
KoFilter::ConversionStatus MpxjImport::convert(const QByteArray& from, const QByteArray& to) { kDebug(planMpxjDbg()) << from << to; if ( to != "application/x-vnd.kde.plan" || ! mimeTypes().contains( from ) ) { kDebug(planMpxjDbg())<<"Bad mime types:"<<from<<"->"<<to; return KoFilter::BadMimeType; } bool batch = false; if ( m_chain->manager() ) { batch = m_chain->manager()->getBatchMode(); } if (batch) { //TODO kDebug(planMpxjDbg()) << "batch mode not implemented"; return KoFilter::NotImplemented; } KoDocument *part = m_chain->outputDocument(); if ( ! part ) { kDebug(planMpxjDbg()) << "could not open document"; return KoFilter::InternalError; } QString inputFile = m_chain->inputFile(); kDebug(planMpxjDbg())<<"Import from:"<<inputFile; QTemporaryDir *tmp = new QTemporaryDir(); QString outFile( tmp->path() + "/maindoc.xml" ); kDebug(planMpxjDbg())<<"Temp file:"<<outFile; KoFilter::ConversionStatus sts = doImport( inputFile.toUtf8(), outFile.toUtf8() ); kDebug(planMpxjDbg())<<"doImport returned:"<<(sts == KoFilter::OK); if ( sts == KoFilter::OK ) { QFile file( outFile ); KoXmlDocument doc; if ( ! doc.setContent( &file ) ) { kDebug(planMpxjDbg()) << "could not read maindoc.xml"; sts = KoFilter::InternalError; } else if ( ! part->loadXML( doc, 0 ) ) { kDebug(planMpxjDbg()) << "failed to load maindoc.xml"; sts = KoFilter::InternalError; } } delete tmp; return sts; }
KoFilter::ConversionStatus ExcelExport::convert(const QByteArray& from, const QByteArray& to) { if (to != "application/vnd.ms-excel") return KoFilter::NotImplemented; if (from != "application/vnd.oasis.opendocument.spreadsheet") return KoFilter::NotImplemented; d->outputFile = m_chain->outputFile(); KoDocument* document = m_chain->inputDocument(); if (!document) return KoFilter::StupidError; d->inputDoc = qobject_cast<const Calligra::Sheets::Doc*>(document); if (!d->inputDoc) { kWarning() << "document isn't a Calligra::Sheets::Doc but a " << document->metaObject()->className(); return KoFilter::WrongFormat; } CFBWriter w(false); w.open(d->outputFile); w.setRootClassId(QUuid("{00020820-0000-0000-c000-000000000046 }")); QIODevice* a = w.openSubStream("Workbook"); XlsRecordOutputStream o(a); d->out = &o; { BOFRecord b(0); b.setType(BOFRecord::Workbook); b.setRecordSize(16); o.writeRecord(b); } o.writeRecord(InterfaceHdrRecord(0)); o.writeRecord(MmsReservedRecord(0)); o.writeRecord(InterfaceEndRecord(0)); { LastWriteAccessRecord lwar(0); lwar.setUserName(" "); // TODO: figure out real username lwar.setUnusedBlob(QByteArray(112 - 3 - 2*lwar.userName().length(), ' ')); o.writeRecord(lwar); } o.writeRecord(CodePageRecord(0)); o.writeRecord(DSFReservedRecord(0)); { RRTabIdRecord rrti(0); rrti.setSheetCount(d->inputDoc->map()->count()); for (int i = 0; i < d->inputDoc->map()->count(); i++) { rrti.setSheetId(i, i+1); } o.writeRecord(rrti); } o.writeRecord(WinProtectRecord(0)); o.writeRecord(ProtectRecord(0)); o.writeRecord(PasswordRecord(0)); o.writeRecord(Prot4RevRecord(0)); o.writeRecord(Prot4RevPassRecord(0)); o.writeRecord(Window1Record(0)); o.writeRecord(BackupRecord(0)); o.writeRecord(HideObjRecord(0)); o.writeRecord(DateModeRecord(0)); o.writeRecord(CalcPrecisionRecord(0)); o.writeRecord(RefreshAllRecord(0)); o.writeRecord(BookBoolRecord(0)); QHash<QPair<QFont, QColor>, unsigned> fonts; fonts[qMakePair(QFont(), QColor())] = 0; { FontRecord fnt(0); fnt.setFontName("Arial"); d->fontRecords.append(fnt); fnt.setFontWeight(700); d->fontRecords.append(fnt); fnt.setFontWeight(400); fnt.setItalic(true); d->fontRecords.append(fnt); fnt.setFontWeight(700); d->fontRecords.append(fnt); } QList<XFRecord> xfs; for (int i = 0; i < d->inputDoc->map()->count(); i++) { collectStyles(d->inputDoc->map()->sheet(i), xfs, fonts); } foreach (const FontRecord& fnt, d->fontRecords) { o.writeRecord(fnt); } QMap<int, QString> formats; formats.insert(5, QString::fromUtf8("#,##0\\ \"€\";\\-#,##0\\ \"€\"")); formats.insert(6, QString::fromUtf8("#,##0\\ \"€\";[Red]\\-#,##0\\ \"€\"")); formats.insert(7, QString::fromUtf8("#,##0.00\\ \"€\";\\-#,##0.00\\ \"€\"")); formats.insert(8, QString::fromUtf8("#,##0.00\\ \"€\";[Red]\\-#,##0.00\\ \"€\"")); formats.insert(41, QString::fromUtf8("_-* #,##0\\ _€_-;\\-* #,##0\\ _€_-;_-* \"-\"\\ _€_-;_-@_-")); formats.insert(42, QString::fromUtf8("_-* #,##0\\ \"€\"_-;\\-* #,##0\\ \"€\"_-;_-* \"-\"\\ \"€\"_-;_-@_-")); formats.insert(43, QString::fromUtf8("_-* #,##0.00\\ _€_-;\\-* #,##0.00\\ _€_-;_-* \"-\"??\\ _€_-;_-@_-")); formats.insert(44, QString::fromUtf8("_-* #,##0.00\\ \"€\"_-;\\-* #,##0.00\\ \"€\"_-;_-* \"-\"??\\ \"€\"_-;_-@_-")); for (QMap<int, QString>::ConstIterator i = formats.constBegin(); i != formats.constEnd(); ++i) { FormatRecord fr(0); fr.setIndex(i.key()); fr.setFormatString(i.value()); o.writeRecord(fr); } // 15 style xfs, followed by one cell xf and then our own xfs for (int i = 0; i < 15; i++) { o.writeRecord(XFRecord(0)); } { XFRecord xf(0); xf.setIsStyleXF(false); xf.setParentStyle(0); o.writeRecord(xf); } foreach (const XFRecord& xf, xfs) { o.writeRecord(xf); }
bool convertPdf(const QUrl &uIn, const QString &inputFormat, const QUrl &uOut, const QString &outputFormat, const QString &orientation, const QString &papersize, const QString &margin) { Q_UNUSED(outputFormat); QString error; KoDocumentEntry documentEntry = KoDocumentEntry::queryByMimeType(inputFormat); KoPart *part = documentEntry.createKoPart(); if (!part) { return false; } KoDocument *doc = part->document(); doc->setCheckAutoSaveFile(false); doc->setAutoErrorHandlingEnabled(false); if (!doc->openUrl(uIn)) { qDebug() << "The document" << uIn.path() << "of format" << inputFormat << "failed to open with the error" << error; doc->deleteLater(); return false; } doc->setReadWrite(false); KoView *view = part->createView(doc); KoPrintJob *printJob = view->createPdfPrintJob(); // We should now have a print job - but check to make sure if (!printJob) { qDebug() << "The document" << uIn.path() << "of format" << inputFormat << "was unable to provide a print job for PDF export"; doc->deleteLater(); return false; } printJob->printer().setOutputFileName(uOut.path()); printJob->printer().setOutputFormat(QPrinter::PdfFormat); printJob->printer().setColorMode(QPrinter::Color); if (orientation == "Portrait") printJob->printer().setOrientation(QPrinter::Portrait); else if (orientation == "Landscape") printJob->printer().setOrientation(QPrinter::Landscape); if (papersize == "A0") printJob->printer().setPaperSize(QPrinter::A0); else if (papersize == "A1") printJob->printer().setPaperSize(QPrinter::A1); else if (papersize == "A2") printJob->printer().setPaperSize(QPrinter::A2); else if (papersize == "A3") printJob->printer().setPaperSize(QPrinter::A3); else if (papersize == "A4") printJob->printer().setPaperSize(QPrinter::A4); else if (papersize == "A5") printJob->printer().setPaperSize(QPrinter::A5); else if (papersize == "A6") printJob->printer().setPaperSize(QPrinter::A6); else if (papersize == "A7") printJob->printer().setPaperSize(QPrinter::A7); else if (papersize == "A8") printJob->printer().setPaperSize(QPrinter::A8); else if (papersize == "A9") printJob->printer().setPaperSize(QPrinter::A9); else if (papersize == "B0") printJob->printer().setPaperSize(QPrinter::B0); else if (papersize == "B1") printJob->printer().setPaperSize(QPrinter::B1); else if (papersize == "B2") printJob->printer().setPaperSize(QPrinter::B2); else if (papersize == "B3") printJob->printer().setPaperSize(QPrinter::B3); else if (papersize == "B4") printJob->printer().setPaperSize(QPrinter::B4); else if (papersize == "B5") printJob->printer().setPaperSize(QPrinter::B5); else if (papersize == "B6") printJob->printer().setPaperSize(QPrinter::B6); else if (papersize == "B7") printJob->printer().setPaperSize(QPrinter::B7); else if (papersize == "B8") printJob->printer().setPaperSize(QPrinter::B8); else if (papersize == "B9") printJob->printer().setPaperSize(QPrinter::B9); else if (papersize == "B10") printJob->printer().setPaperSize(QPrinter::B10); else if (papersize == "C5E") printJob->printer().setPaperSize(QPrinter::C5E); else if (papersize == "Comm10E") printJob->printer().setPaperSize(QPrinter::Comm10E); else if (papersize == "DLE") printJob->printer().setPaperSize(QPrinter::DLE); else if (papersize == "Executive") printJob->printer().setPaperSize(QPrinter::Executive); else if (papersize == "Folio") printJob->printer().setPaperSize(QPrinter::Folio); else if (papersize == "Ledger") printJob->printer().setPaperSize(QPrinter::Ledger); else if (papersize == "Legal") printJob->printer().setPaperSize(QPrinter::Legal); else if (papersize == "Letter") printJob->printer().setPaperSize(QPrinter::Letter); else if (papersize == "Tabloid") printJob->printer().setPaperSize(QPrinter::Tabloid); bool _marginOk; qreal _margin = margin.toDouble(&_marginOk); if (!_marginOk) _margin = 0.2; printJob->printer().setPageMargins(_margin, _margin, _margin, _margin, QPrinter::Point); printJob->startPrinting(); doc->deleteLater(); return true; }
KoDocumentInfoDlg::KoDocumentInfoDlg(QWidget* parent, KoDocumentInfo* docInfo, KoDocumentRdf* docRdf) : KPageDialog(parent) , d(new KoDocumentInfoDlgPrivate) { d->m_info = docInfo; d->m_rdf = docRdf; setCaption(i18n("Document Information")); setInitialSize(QSize(500, 500)); setFaceType(KPageDialog::List); setButtons(KDialog::Ok | KDialog::Cancel); setDefaultButton(KDialog::Ok); d->m_aboutUi = new Ui::KoDocumentInfoAboutWidget(); QWidget *infodlg = new QWidget(); d->m_aboutUi->setupUi(infodlg); if (!KoEncryptionChecker::isEncryptionSupported()) { d->m_aboutUi->lblEncryptedDesc->setVisible(false); d->m_aboutUi->lblEncrypted->setVisible(false); d->m_aboutUi->pbEncrypt->setVisible(false); d->m_aboutUi->lblEncryptedPic->setVisible(false); } KPageWidgetItem *page = new KPageWidgetItem(infodlg, i18n("General")); page->setHeader(i18n("General")); // Ugly hack, the mimetype should be a parameter, instead KoDocument* doc = dynamic_cast< KoDocument* >(d->m_info->parent()); if (doc) { KMimeType::Ptr mime = KMimeType::mimeType(doc->mimeType()); if (! mime) mime = KMimeType::defaultMimeTypePtr(); page->setIcon(KIcon(KIconLoader::global()->loadMimeTypeIcon(mime->iconName(), KIconLoader::Desktop, 48))); } addPage(page); d->m_pages.append(page); initAboutTab(); d->m_authorUi = new Ui::KoDocumentInfoAuthorWidget(); QWidget *authordlg = new QWidget(); d->m_authorUi->setupUi(authordlg); page = new KPageWidgetItem(authordlg, i18n("Author")); page->setHeader(i18n("Author")); page->setIcon(KIcon("user-identity")); addPage(page); d->m_pages.append(page); initAuthorTab(); // Saving encryption implies saving the document, this is done after closing the dialog connect(this, SIGNAL(hidden()), this, SLOT(slotSaveEncryption())); if (d->m_rdf) { d->m_rdfEditWidget = 0; #ifdef SHOULD_BUILD_RDF d->m_rdfEditWidget = new KoDocumentRdfEditWidget(this, d->m_rdf); page = new KPageWidgetItem(d->m_rdfEditWidget->widget(), i18n("Rdf")); page->setHeader(i18n("Rdf")); page->setIcon(KIcon("text-rdf")); addPage(page); d->m_pages.append(page); #endif } }
void KoDocumentInfoDlg::initAboutTab() { KoDocument* doc = dynamic_cast< KoDocument* >(d->m_info->parent()); if (!doc) return; d->m_aboutUi->filePathLabel->setText(doc->localFilePath()); d->m_aboutUi->leTitle->setText(d->m_info->aboutInfo("title")); d->m_aboutUi->leSubject->setText(d->m_info->aboutInfo("subject")); d->m_aboutUi->leKeywords->setToolTip(i18n("Use ';' (Example: Office;KDE;KOffice)")); if (!d->m_info->aboutInfo("keyword").isEmpty()) d->m_aboutUi->leKeywords->setText(d->m_info->aboutInfo("keyword")); d->m_aboutUi->meComments->setPlainText(d->m_info->aboutInfo("comments")); if (!doc->mimeType().isEmpty()) { KMimeType::Ptr docmime = KMimeType::mimeType(doc->mimeType()); if (docmime) d->m_aboutUi->lblType->setText(docmime->comment()); } if (!d->m_info->aboutInfo("creation-date").isEmpty()) { QDateTime t = QDateTime::fromString(d->m_info->aboutInfo("creation-date"), Qt::ISODate); QString s = KGlobal::locale()->formatDateTime(t); d->m_aboutUi->lblCreated->setText(s + ", " + d->m_info->aboutInfo("initial-creator")); } if (!d->m_info->aboutInfo("date").isEmpty()) { QDateTime t = QDateTime::fromString(d->m_info->aboutInfo("date"), Qt::ISODate); QString s = KGlobal::locale()->formatDateTime(t); d->m_aboutUi->lblModified->setText(s + ", " + d->m_info->authorInfo("creator")); } d->m_aboutUi->lblRevision->setText(d->m_info->aboutInfo("editing-cycles")); if ( doc->supportedSpecialFormats() & KoDocument::SaveEncrypted ) { if (doc->specialOutputFlag() == KoDocument::SaveEncrypted) { if (d->m_toggleEncryption) { QPixmap p = KIconLoader::global()->loadIcon("object-unlocked", KIconLoader::Small); d->m_aboutUi->lblEncrypted->setText(i18n("This document will be decrypted")); d->m_aboutUi->lblEncryptedPic->setPixmap(p); d->m_aboutUi->pbEncrypt->setText(i18n("Do not decrypt")); } else { QPixmap p = KIconLoader::global()->loadIcon("object-locked", KIconLoader::Small); d->m_aboutUi->lblEncrypted->setText(i18n("This document is encrypted")); d->m_aboutUi->lblEncryptedPic->setPixmap(p); d->m_aboutUi->pbEncrypt->setText(i18n("D&ecrypt")); } } else { if (d->m_toggleEncryption) { QPixmap p = KIconLoader::global()->loadIcon("object-locked", KIconLoader::Small); d->m_aboutUi->lblEncrypted->setText(i18n("This document will be encrypted.")); d->m_aboutUi->lblEncryptedPic->setPixmap(p); d->m_aboutUi->pbEncrypt->setText(i18n("Do not encrypt")); } else { QPixmap p = KIconLoader::global()->loadIcon("object-unlocked", KIconLoader::Small); d->m_aboutUi->lblEncrypted->setText(i18n("This document is not encrypted")); d->m_aboutUi->lblEncryptedPic->setPixmap(p); d->m_aboutUi->pbEncrypt->setText(i18n("&Encrypt")); } } } else { d->m_aboutUi->lblEncrypted->setText(i18n("This document does not support encryption")); d->m_aboutUi->pbEncrypt->setEnabled( false ); } connect(d->m_aboutUi->pbReset, SIGNAL(clicked()), this, SLOT(slotResetMetaData())); connect(d->m_aboutUi->pbEncrypt, SIGNAL(clicked()), this, SLOT(slotToggleEncryption())); }
bool KoApplication::start() { ResetStarting resetStarting; // reset m_starting to false when we're done Q_UNUSED(resetStarting); // Find the *.desktop file corresponding to the kapp instance name KoDocumentEntry entry = KoDocumentEntry(KoDocument::readNativeService()); if (entry.isEmpty()) { kError(30003) << KGlobal::mainComponent().componentName() << "part.desktop not found." << endl; kError(30003) << "Run 'kde4-config --path services' to see which directories were searched, assuming kde startup had the same environment as your current shell." << endl; kError(30003) << "Check your installation (did you install KOffice in a different prefix than KDE, without adding the prefix to /etc/kderc ?)" << endl; return false; } // Get the command line arguments which we have to parse KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); int argsCount = args->count(); KCmdLineArgs *koargs = KCmdLineArgs::parsedArgs("koffice"); QString dpiValues = koargs->getOption("dpi"); if (!dpiValues.isEmpty()) { int sep = dpiValues.indexOf(QRegExp("[x, ]")); int dpiX; int dpiY = 0; bool ok = true; if (sep != -1) { dpiY = dpiValues.mid(sep + 1).toInt(&ok); dpiValues.truncate(sep); } if (ok) { dpiX = dpiValues.toInt(&ok); if (ok) { if (!dpiY) dpiY = dpiX; KoGlobal::setDPI(dpiX, dpiY); } } } // No argument -> create an empty document if (!argsCount) { QString errorMsg; KoDocument* doc = entry.createDoc(&errorMsg); if (!doc) { if (!errorMsg.isEmpty()) KMessageBox::error(0, errorMsg); return false; } KoMainWindow *shell = new KoMainWindow(doc->componentData()); shell->show(); QObject::connect(doc, SIGNAL(sigProgress(int)), shell, SLOT(slotProgress(int))); // for initDoc to fill in the recent docs list // and for KoDocument::slotStarted doc->addShell(shell); if (doc->checkAutoSaveFile()) { shell->setRootDocument(doc); } else { doc->showStartUpWidget(shell); } // FIXME This needs to be moved someplace else QObject::disconnect(doc, SIGNAL(sigProgress(int)), shell, SLOT(slotProgress(int))); } else { const bool print = koargs->isSet("print"); const bool exportAsPdf = koargs->isSet("export-pdf"); QString pdfFileName = koargs->getOption("export-filename"); const bool doTemplate = koargs->isSet("template"); koargs->clear(); // Loop through arguments short int n = 0; // number of documents open short int nPrinted = 0; for (int i = 0; i < argsCount; i++) { // For now create an empty document QString errorMsg; KoDocument* doc = entry.createDoc(&errorMsg, 0); if (doc) { // show a shell asap KoMainWindow *shell = new KoMainWindow(doc->componentData()); shell->show(); // are we just trying to open a template? if (doTemplate) { QStringList paths; if (args->url(i).isLocalFile() && QFile::exists(args->url(i).toLocalFile())) { paths << QString(args->url(i).toLocalFile()); kDebug(30003) << "using full path..."; } else { QString desktopName(args->arg(i)); QString appName = KGlobal::mainComponent().componentName(); paths = KGlobal::dirs()->findAllResources("data", appName + "/templates/*/" + desktopName); if (paths.isEmpty()) { paths = KGlobal::dirs()->findAllResources("data", appName + "/templates/" + desktopName); } if (paths.isEmpty()) { KMessageBox::error(0L, i18n("No template found for: %1 ", desktopName)); delete shell; } else if (paths.count() > 1) { KMessageBox::error(0L, i18n("Too many templates found for: %1", desktopName)); delete shell; } } if (!paths.isEmpty()) { KUrl templateBase; templateBase.setPath(paths[0]); KDesktopFile templateInfo(paths[0]); QString templateName = templateInfo.readUrl(); KUrl templateURL; templateURL.setPath(templateBase.directory() + '/' + templateName); if (shell->openDocument(doc, templateURL)) { doc->resetURL(); doc->setEmpty(); doc->setTitleModified(); kDebug(30003) << "Template loaded..."; n++; } else { KMessageBox::error(0L, i18n("Template %1 failed to load.", templateURL.prettyUrl())); delete shell; } } // now try to load } else if (shell->openDocument(doc, args->url(i))) { if (print) { shell->slotFilePrint(); // delete shell; done by ~KoDocument nPrinted++; } else if (exportAsPdf) { KoPrintJob *job = shell->exportToPdf(pdfFileName); if (job) connect (job, SIGNAL(destroyed(QObject*)), shell, SLOT(slotFileQuit()), Qt::QueuedConnection); nPrinted++; } else { // Normal case, success n++; } } else { // .... if failed // delete doc; done by openDocument // delete shell; done by ~KoDocument } } } if (print || exportAsPdf) return nPrinted > 0; if (n == 0) // no doc, e.g. all URLs were malformed return false; } args->clear(); // not calling this before since the program will quit there. return true; }