Document Context

Shared rendering and layout state used across the entire document pipeline. Holds the active backend, cached sub-backends (text, shape, image, page), page metrics, section nodes, and the layout cursor.

class DocraftDocumentContext

Context Facade: Orchestrates document rendering and layout services.

This is the primary entry point for the document rendering pipeline. It composes four services:

  • RenderingService: backend + capability caching

  • LayoutService: cursor + page metrics

  • TypographyService: font management

  • NavigationService: document structure (header/body/footer) + page nav

Responsibilities:

  • Wiring and lifetime management of services

  • Renderer setup and delegation

  • Direct access to four service bundles

Public Functions

DocraftDocumentContext()

Constructs a context with a default PDF backend.

explicit DocraftDocumentContext(const std::shared_ptr<backend::IDocraftCapabilityProvidersFactory> &capability_providers_factory)

Constructs a context with backend providers factory.

~DocraftDocumentContext()

Destructor.

services::RenderingService &edit_rendering()

Returns the rendering service (backend + capability caching).

const services::RenderingService &rendering() const
services::LayoutService &edit_layout()

Returns the layout service (cursor + page metrics).

const services::LayoutService &layout() const
services::TypographyService &edit_typography()

Returns the typography service (font management).

const services::TypographyService &typography() const
services::NavigationService &edit_navigation()

Returns the navigation service (sections + page navigation).

const services::NavigationService &navigation() const
void set_renderer(const std::shared_ptr<renderer::DocraftAbstractRenderer> &renderer)

Sets the renderer responsible for translating document nodes to backend calls.

Parameters:

renderer – Renderer instance.

std::shared_ptr<renderer::DocraftAbstractRenderer> renderer() const

Returns the current renderer.

Returns:

Shared pointer to the renderer (may be nullptr).

std::shared_ptr<renderer::DocraftAbstractRenderer> edit_renderer()