2021-04-30 20:12:10 +02:00
|
|
|
// Copyright (C) 2019-2021 Jakub Melka
|
2019-11-17 17:41:07 +01:00
|
|
|
//
|
2021-08-10 19:22:56 +02:00
|
|
|
// This file is part of PDF4QT.
|
2019-11-17 17:41:07 +01:00
|
|
|
//
|
2021-08-10 19:22:56 +02:00
|
|
|
// PDF4QT is free software: you can redistribute it and/or modify
|
2019-11-17 17:41:07 +01:00
|
|
|
// it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
2021-04-30 20:12:10 +02:00
|
|
|
// with the written consent of the copyright owner, any later version.
|
2019-11-17 17:41:07 +01:00
|
|
|
//
|
2021-08-10 19:22:56 +02:00
|
|
|
// PDF4QT is distributed in the hope that it will be useful,
|
2019-11-17 17:41:07 +01:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
2021-08-10 19:22:56 +02:00
|
|
|
// along with PDF4QT. If not, see <https://www.gnu.org/licenses/>.
|
2019-11-17 17:41:07 +01:00
|
|
|
|
|
|
|
#ifndef PDFOUTLINE_H
|
|
|
|
#define PDFOUTLINE_H
|
|
|
|
|
|
|
|
#include "pdfglobal.h"
|
|
|
|
#include "pdfobject.h"
|
|
|
|
#include "pdfaction.h"
|
|
|
|
|
|
|
|
#include <QSharedPointer>
|
|
|
|
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
namespace pdf
|
|
|
|
{
|
|
|
|
class PDFDocument;
|
|
|
|
|
|
|
|
/// Outline item
|
2021-08-10 19:22:56 +02:00
|
|
|
class PDF4QTLIBSHARED_EXPORT PDFOutlineItem
|
2019-11-17 17:41:07 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit PDFOutlineItem() = default;
|
|
|
|
|
|
|
|
const QString& getTitle() const { return m_title; }
|
|
|
|
void setTitle(const QString& title) { m_title = title; }
|
|
|
|
|
|
|
|
size_t getChildCount() const { return m_children.size(); }
|
2020-11-15 18:15:10 +01:00
|
|
|
size_t getTotalCount() const;
|
2019-11-17 17:41:07 +01:00
|
|
|
const PDFOutlineItem* getChild(size_t index) const { return m_children[index].get(); }
|
|
|
|
void addChild(QSharedPointer<PDFOutlineItem> child) { m_children.emplace_back(qMove(child)); }
|
2019-11-28 18:20:32 +01:00
|
|
|
QSharedPointer<PDFOutlineItem> getChildPtr(size_t index) const { return m_children[index]; }
|
2019-11-17 17:41:07 +01:00
|
|
|
|
2021-08-07 16:23:37 +02:00
|
|
|
static QSharedPointer<PDFOutlineItem> parse(const PDFObjectStorage* storage, const PDFObject& root);
|
2019-11-17 17:41:07 +01:00
|
|
|
|
|
|
|
const PDFAction* getAction() const;
|
2020-12-31 15:51:03 +01:00
|
|
|
PDFAction* getAction();
|
2019-11-17 17:41:07 +01:00
|
|
|
void setAction(const PDFActionPtr& action);
|
|
|
|
|
2019-11-24 15:43:27 +01:00
|
|
|
QColor getTextColor() const;
|
|
|
|
void setTextColor(const QColor& textColor);
|
|
|
|
|
|
|
|
bool isFontItalics() const;
|
|
|
|
void setFontItalics(bool fontItalics);
|
|
|
|
|
|
|
|
bool isFontBold() const;
|
|
|
|
void setFontBold(bool fontBold);
|
|
|
|
|
|
|
|
PDFObjectReference getStructureElement() const;
|
|
|
|
void setStructureElement(PDFObjectReference structureElement);
|
|
|
|
|
2020-12-31 15:51:03 +01:00
|
|
|
void apply(const std::function<void(PDFOutlineItem*)>& functor);
|
|
|
|
|
2019-11-17 17:41:07 +01:00
|
|
|
private:
|
2021-08-07 16:23:37 +02:00
|
|
|
static void parseImpl(const PDFObjectStorage* storage,
|
2019-11-17 17:41:07 +01:00
|
|
|
PDFOutlineItem* parent,
|
|
|
|
PDFObjectReference currentItem,
|
|
|
|
std::set<PDFObjectReference>& visitedOutlineItems);
|
|
|
|
|
|
|
|
QString m_title;
|
|
|
|
std::vector<QSharedPointer<PDFOutlineItem>> m_children;
|
|
|
|
PDFActionPtr m_action;
|
2019-11-24 15:43:27 +01:00
|
|
|
PDFObjectReference m_structureElement;
|
|
|
|
QColor m_textColor;
|
|
|
|
bool m_fontItalics = false;
|
|
|
|
bool m_fontBold = false;
|
2019-11-17 17:41:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace pdf
|
|
|
|
|
|
|
|
#endif // PDFOUTLINE_H
|