97 lines
2.1 KiB
C++
97 lines
2.1 KiB
C++
#pragma once
|
|
|
|
#include <pdfengine/layout_types.hpp>
|
|
#include <pdfengine/geometry/rect.hpp>
|
|
#include <pdfengine/geometry/matrix.hpp>
|
|
#include <pdfengine/geometry/quad.hpp>
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <memory>
|
|
|
|
namespace pdfengine {
|
|
|
|
struct LayoutGlyph {
|
|
std::string character;
|
|
uint32_t charCode = 0;
|
|
geometry::Rect bounds;
|
|
geometry::Matrix transform;
|
|
float advanceWidth = 0.0f;
|
|
};
|
|
|
|
struct TextRun {
|
|
std::string text;
|
|
TextStyle style;
|
|
geometry::Rect bounds;
|
|
geometry::Matrix transform;
|
|
std::vector<LayoutGlyph> glyphs;
|
|
};
|
|
|
|
struct LayoutLine {
|
|
std::string text;
|
|
geometry::Rect bounds;
|
|
float baselineY = 0.0f;
|
|
float lineHeight = 12.0f;
|
|
std::vector<TextRun> runs;
|
|
};
|
|
|
|
struct LayoutBlock {
|
|
std::string id;
|
|
LayoutBlockType type = LayoutBlockType::Paragraph;
|
|
geometry::Rect bounds;
|
|
geometry::Matrix transform;
|
|
int zIndex = 0;
|
|
int readingOrder = 0;
|
|
|
|
BlockPermissions permissions;
|
|
VisualStyle visualStyle;
|
|
TextStyle textStyle;
|
|
LayoutStyle layoutStyle;
|
|
|
|
std::vector<LayoutLine> children;
|
|
std::string parentId;
|
|
std::vector<std::string> dependsOn; // Block ID dependencies (e.g. caption -> image)
|
|
|
|
size_t layoutTreeVersion = 1;
|
|
size_t contentRevision = 1;
|
|
size_t layoutRevision = 1;
|
|
std::string sourceObjectId;
|
|
};
|
|
|
|
enum class RegionType {
|
|
Header,
|
|
Body,
|
|
Sidebar,
|
|
Footer
|
|
};
|
|
|
|
struct PageRegion {
|
|
std::string id;
|
|
RegionType type = RegionType::Body;
|
|
geometry::Rect bounds;
|
|
std::vector<std::shared_ptr<LayoutBlock>> blocks;
|
|
};
|
|
|
|
struct PhysicalLayoutTree {
|
|
int pageIndex = 0;
|
|
float width = 0.0f;
|
|
float height = 0.0f;
|
|
std::vector<PageRegion> regions;
|
|
std::vector<std::shared_ptr<LayoutBlock>> allBlocks;
|
|
};
|
|
|
|
struct LogicalLayoutNode {
|
|
std::string id;
|
|
std::string title;
|
|
LayoutBlockType type = LayoutBlockType::Paragraph;
|
|
std::shared_ptr<LayoutBlock> block;
|
|
std::vector<std::shared_ptr<LogicalLayoutNode>> children;
|
|
};
|
|
|
|
struct LogicalLayoutTree {
|
|
std::string documentTitle;
|
|
std::vector<std::shared_ptr<LogicalLayoutNode>> sections;
|
|
};
|
|
|
|
} // namespace pdfengine
|