#include "core/fpdfapi/edit/cpdf_npagetooneexporter.h"
#include <algorithm>
#include <memory>
#include <sstream>
#include <utility>
#include "constants/page_object.h"
#include "core/fpdfapi/edit/cpdf_contentstream_write_utils.h"
#include "core/fpdfapi/page/cpdf_page.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fpdfapi/parser/cpdf_name.h"
#include "core/fpdfapi/parser/cpdf_number.h"
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fpdfapi/parser/cpdf_reference.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/cpdf_stream_acc.h"
#include "core/fxcrt/check.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/fx_string_wrappers.h"
#include "core/fxcrt/span.h"
namespace {
class NupState { … };
NupState::NupState(const CFX_SizeF& pagesize,
size_t pages_on_x_axis,
size_t pages_on_y_axis)
: … { … }
std::pair<size_t, size_t> NupState::ConvertPageOrder() const { … }
CPDF_NPageToOneExporter::NupPageSettings NupState::CalculatePageEdit(
size_t sub_x,
size_t sub_y,
const CFX_SizeF& pagesize) const { … }
CPDF_NPageToOneExporter::NupPageSettings NupState::CalculateNewPagePosition(
const CFX_SizeF& pagesize) { … }
ByteString GenerateSubPageContentStream(
const ByteString& xobject_name,
const CPDF_NPageToOneExporter::NupPageSettings& settings) { … }
}
CPDF_NPageToOneExporter::CPDF_NPageToOneExporter(CPDF_Document* dest_doc,
CPDF_Document* src_doc)
: … { … }
CPDF_NPageToOneExporter::~CPDF_NPageToOneExporter() = default;
bool CPDF_NPageToOneExporter::ExportNPagesToOne(
pdfium::span<const uint32_t> page_indices,
const CFX_SizeF& dest_page_size,
size_t pages_on_x_axis,
size_t pages_on_y_axis) { … }
ByteString CPDF_NPageToOneExporter::GenerateSubPageContentStreamForTesting(
const ByteString& xobject_name,
const NupPageSettings& settings) { … }
ByteString CPDF_NPageToOneExporter::AddSubPage(
const RetainPtr<CPDF_Page>& src_page,
const NupPageSettings& settings) { … }
RetainPtr<CPDF_Stream> CPDF_NPageToOneExporter::MakeXObjectFromPageRaw(
RetainPtr<CPDF_Page> src_page) { … }
ByteString CPDF_NPageToOneExporter::MakeXObjectFromPage(
RetainPtr<CPDF_Page> src_page) { … }
std::unique_ptr<XObjectContext>
CPDF_NPageToOneExporter::CreateXObjectContextFromPage(int src_page_index) { … }
void CPDF_NPageToOneExporter::FinishPage(
RetainPtr<CPDF_Dictionary> dest_page_dict,
const ByteString& content) { … }
XObjectContext::XObjectContext() = default;
XObjectContext::~XObjectContext() = default;