mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:07:45 +00:00
LibPDF: Move Page into its own file Page.h
This commit is contained in:
parent
88872ca42d
commit
f4f8a6a1bf
2 changed files with 66 additions and 47 deletions
|
@ -15,28 +15,10 @@
|
||||||
#include <LibPDF/Encryption.h>
|
#include <LibPDF/Encryption.h>
|
||||||
#include <LibPDF/Error.h>
|
#include <LibPDF/Error.h>
|
||||||
#include <LibPDF/ObjectDerivatives.h>
|
#include <LibPDF/ObjectDerivatives.h>
|
||||||
|
#include <LibPDF/Page.h>
|
||||||
|
|
||||||
namespace PDF {
|
namespace PDF {
|
||||||
|
|
||||||
struct Rectangle {
|
|
||||||
float lower_left_x;
|
|
||||||
float lower_left_y;
|
|
||||||
float upper_right_x;
|
|
||||||
float upper_right_y;
|
|
||||||
|
|
||||||
float width() const { return upper_right_x - lower_left_x; }
|
|
||||||
float height() const { return upper_right_y - lower_left_y; }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Page {
|
|
||||||
NonnullRefPtr<DictObject> resources;
|
|
||||||
RefPtr<Object> contents;
|
|
||||||
Rectangle media_box;
|
|
||||||
Rectangle crop_box;
|
|
||||||
float user_unit;
|
|
||||||
int rotate;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Destination {
|
struct Destination {
|
||||||
enum class Type {
|
enum class Type {
|
||||||
XYZ,
|
XYZ,
|
||||||
|
@ -204,34 +186,6 @@ private:
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
template<>
|
|
||||||
struct Formatter<PDF::Rectangle> : Formatter<FormatString> {
|
|
||||||
ErrorOr<void> format(FormatBuilder& builder, PDF::Rectangle const& rectangle)
|
|
||||||
{
|
|
||||||
return Formatter<FormatString>::format(builder,
|
|
||||||
"Rectangle {{ ll=({}, {}), ur=({}, {}) }}"sv,
|
|
||||||
rectangle.lower_left_x,
|
|
||||||
rectangle.lower_left_y,
|
|
||||||
rectangle.upper_right_x,
|
|
||||||
rectangle.upper_right_y);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
|
||||||
struct Formatter<PDF::Page> : Formatter<FormatString> {
|
|
||||||
ErrorOr<void> format(FormatBuilder& builder, PDF::Page const& page)
|
|
||||||
{
|
|
||||||
return Formatter<FormatString>::format(builder,
|
|
||||||
"Page {{\n resources={}\n contents={}\n media_box={}\n crop_box={}\n user_unit={}\n rotate={}\n}}"sv,
|
|
||||||
page.resources->to_deprecated_string(1),
|
|
||||||
page.contents->to_deprecated_string(1),
|
|
||||||
page.media_box,
|
|
||||||
page.crop_box,
|
|
||||||
page.user_unit,
|
|
||||||
page.rotate);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct Formatter<PDF::Destination> : Formatter<FormatString> {
|
struct Formatter<PDF::Destination> : Formatter<FormatString> {
|
||||||
ErrorOr<void> format(FormatBuilder& builder, PDF::Destination const& destination)
|
ErrorOr<void> format(FormatBuilder& builder, PDF::Destination const& destination)
|
||||||
|
|
65
Userland/Libraries/LibPDF/Page.h
Normal file
65
Userland/Libraries/LibPDF/Page.h
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021-2022, Matthew Olsson <mattco@serenityos.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/RefPtr.h>
|
||||||
|
#include <LibPDF/Forward.h>
|
||||||
|
|
||||||
|
namespace PDF {
|
||||||
|
|
||||||
|
struct Rectangle {
|
||||||
|
float lower_left_x;
|
||||||
|
float lower_left_y;
|
||||||
|
float upper_right_x;
|
||||||
|
float upper_right_y;
|
||||||
|
|
||||||
|
float width() const { return upper_right_x - lower_left_x; }
|
||||||
|
float height() const { return upper_right_y - lower_left_y; }
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Page {
|
||||||
|
NonnullRefPtr<DictObject> resources;
|
||||||
|
RefPtr<Object> contents;
|
||||||
|
Rectangle media_box;
|
||||||
|
Rectangle crop_box;
|
||||||
|
float user_unit;
|
||||||
|
int rotate;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace AK {
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct Formatter<PDF::Rectangle> : Formatter<FormatString> {
|
||||||
|
ErrorOr<void> format(FormatBuilder& builder, PDF::Rectangle const& rectangle)
|
||||||
|
{
|
||||||
|
return Formatter<FormatString>::format(builder,
|
||||||
|
"Rectangle {{ ll=({}, {}), ur=({}, {}) }}"sv,
|
||||||
|
rectangle.lower_left_x,
|
||||||
|
rectangle.lower_left_y,
|
||||||
|
rectangle.upper_right_x,
|
||||||
|
rectangle.upper_right_y);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct Formatter<PDF::Page> : Formatter<FormatString> {
|
||||||
|
ErrorOr<void> format(FormatBuilder& builder, PDF::Page const& page)
|
||||||
|
{
|
||||||
|
return Formatter<FormatString>::format(builder,
|
||||||
|
"Page {{\n resources={}\n contents={}\n media_box={}\n crop_box={}\n user_unit={}\n rotate={}\n}}"sv,
|
||||||
|
page.resources->to_deprecated_string(1),
|
||||||
|
page.contents->to_deprecated_string(1),
|
||||||
|
page.media_box,
|
||||||
|
page.crop_box,
|
||||||
|
page.user_unit,
|
||||||
|
page.rotate);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue