Commit c0fc05ed authored by Adam Reichold's avatar Adam Reichold Committed by Albert Astals Cid

Remove the intermediate Outline type since all items are owned by the document...

Remove the intermediate Outline type since all items are owned by the document and the top-level items will always be eagerly loaded anyway.
parent 13b5eae9
......@@ -586,7 +586,7 @@ namespace Poppler {
QDomDocument *Document::toc() const
{
::Outline * outline = m_doc->doc->getOutline();
Outline * outline = m_doc->doc->getOutline();
if ( !outline )
return nullptr;
......@@ -601,13 +601,19 @@ namespace Poppler {
return toc;
}
Outline *Document::outline() const
QVector<OutlineItem> Document::outline() const
{
if (auto *outline = m_doc->doc->getOutline()) {
return new Outline{new OutlineData{outline, m_doc}};
QVector<OutlineItem> result;
if (::Outline *outline = m_doc->doc->getOutline()) {
if (const GooList *items = outline->getItems()) {
for (void *item : *items) {
result.push_back(OutlineItem{new OutlineItemData{static_cast<::OutlineItem *>(item), m_doc}});
}
}
}
return nullptr;
return result;
}
LinkDestination *Document::linkDestination( const QString &name )
......
......@@ -40,13 +40,6 @@ struct OutlineItemData
mutable QString uri;
};
struct OutlineData
{
OutlineData(const ::Outline *data, DocumentData *documentData) : data{data}, documentData{documentData} {}
const ::Outline *data;
DocumentData *documentData;
};
}
#endif
......@@ -163,27 +163,4 @@ QVector<OutlineItem> OutlineItem::children() const
return result;
}
Outline::Outline(OutlineData *data) : m_data{data} {}
Outline::~Outline()
{
delete m_data;
m_data = nullptr;
}
QVector<OutlineItem> Outline::items() const
{
QVector<OutlineItem> result;
const ::Outline *data = m_data->data;
if (const GooList *items = data->getItems()) {
for (void *item : *items) {
result.push_back(OutlineItem{new OutlineItemData{static_cast<::OutlineItem *>(item), m_data->documentData}});
}
}
return result;
}
}
......@@ -71,7 +71,6 @@ namespace Poppler {
class PSConverter;
struct OutlineItemData;
struct OutlineData;
/**
Debug/error function.
......@@ -982,7 +981,7 @@ delete it;
};
class POPPLER_QT5_EXPORT OutlineItem {
friend class Outline;
friend class Document;
public:
OutlineItem();
~OutlineItem();
......@@ -1012,20 +1011,6 @@ delete it;
OutlineItemData *m_data;
};
class POPPLER_QT5_EXPORT Outline {
friend class Document;
public:
~Outline();
QVector<OutlineItem> items() const;
private:
Q_DISABLE_COPY(Outline)
Outline(OutlineData *data);
OutlineData *m_data;
};
/**
\brief PDF document.
......@@ -1620,7 +1605,7 @@ QString subject = m_doc->info("Subject");
*/
QDomDocument *toc() const;
Outline *outline() const;
QVector<OutlineItem> outline() const;
/**
Tries to resolve the named destination \p name.
......
......@@ -20,15 +20,10 @@ void TestOutline::checkOutline_xr02()
};
QVERIFY(document.get());
std::unique_ptr<Poppler::Outline> outline{
document->outline()
};
QVERIFY(outline.get());
const auto items = outline->items();
QCOMPARE(items.size(), 2);
const auto outline = document->outline();
QCOMPARE(outline.size(), 2);
const auto &foo = items[0];
const auto &foo = outline[0];
QVERIFY(!foo.isNull());
QCOMPARE(foo.name(), QStringLiteral("foo"));
QCOMPARE(foo.isOpen(), false);
......@@ -39,7 +34,7 @@ void TestOutline::checkOutline_xr02()
QVERIFY(foo.uri().isEmpty());
QVERIFY(foo.children().isEmpty());
const auto &bar = items[1];
const auto &bar = outline[1];
QVERIFY(!bar.isNull());
QCOMPARE(bar.name(), QStringLiteral("bar"));
QCOMPARE(bar.isOpen(), false);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment