void TestLinks::checkDests_xr02() { Poppler::Document *doc; doc = Poppler::Document::load(TESTDATADIR "/unittestcases/xr02.pdf"); QVERIFY( doc ); std::auto_ptr< Poppler::LinkDestination > dest; dest.reset( doc->linkDestination("section.1") ); QVERIFY( isDestinationValid_pageNumber( dest.get(), doc ) ); QVERIFY( !isDestinationValid_name( dest.get() ) ); dest.reset( doc->linkDestination("section.2") ); QVERIFY( isDestinationValid_pageNumber( dest.get(), doc ) ); QVERIFY( !isDestinationValid_name( dest.get() ) ); dest.reset( doc->linkDestination("section.3") ); QVERIFY( !isDestinationValid_pageNumber( dest.get(), doc ) ); QVERIFY( isDestinationValid_name( dest.get() ) ); delete doc; }
void TestLinks::checkDocumentWithNoDests() { Poppler::Document *doc; doc = Poppler::Document::load(TESTDATADIR "/unittestcases/WithAttachments.pdf"); QVERIFY( doc ); std::auto_ptr< Poppler::LinkDestination > dest; dest.reset( doc->linkDestination("no.dests.in.this.document") ); QVERIFY( !isDestinationValid_pageNumber( dest.get(), doc ) ); QVERIFY( isDestinationValid_name( dest.get() ) ); delete doc; }
void addSynopsisChildren(QDomNode *parent, int level) { if (!parent || parent->isNull()) return; // keep track of the current listViewItem QDomNode n = parent->firstChild(); while (!n.isNull()) { PDFTocEntry *tocEntry = new PDFTocEntry; tocEntry->level = level; // convert the node to an element (sure it is) QDomElement e = n.toElement(); tocEntry->title = e.tagName(); // Apparently we can have external links in the ToC. // Not doing this for now, but leave it in here as a note to self // if (!e.attribute("ExternalFileName").isNull()) item.setAttribute("ExternalFileName", e.attribute("ExternalFileName")); if (!e.attribute("DestinationName").isNull()) { Poppler::LinkDestination *dest = document->linkDestination(e.attribute("DestinationName")); if (dest) { tocEntry->pageNumber = dest->pageNumber(); delete dest; } //item.setAttribute("ViewportName", e.attribute("DestinationName")); } if (!e.attribute("Destination").isNull()) { //fillViewportFromLinkDestination( vp, Poppler::LinkDestination(e.attribute("Destination")) ); //item.setAttribute( "Viewport", vp.toString() ); Poppler::LinkDestination dest(e.attribute("Destination")); tocEntry->pageNumber = dest.pageNumber(); } // if (!e.attribute("Open").isNull()) item.setAttribute("Open", e.attribute("Open")); // if (!e.attribute("DestinationURI").isNull()) item.setAttribute("URL", e.attribute("DestinationURI")); // Add the entry to the list of ToC entries entries.append(tocEntry); // descend recursively and advance to the next node ++level; if (e.hasChildNodes()) addSynopsisChildren(&n, level); --level; n = n.nextSibling(); } }