<commit_before><?php
/**
 * File containing the ezcDocumentPdfPage class
 *
 * @package Document
 * @version //autogen//
 * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
 * @license http://ez.no/licenses/new_bsd New BSD License
 * @access private
 */

/**
 * PDF page class
 *
 * Class containing context information about a single rendered page.
 *
 * It especially encodes information about already covered / blocked areas on
 * one PDF page, and offers methods to check if a new content block fits on the
 * page an, where it does fir on the page.
 *
 * @package Document
 * @access private
 * @version //autogen//
 */
class ezcDocumentPdfPage implements ezcDocumentPdfLocateable
{
    /**
     * Already covered areas, given as an arrays of ezcDocumentPdfBoundingBox
     * objects.
     * 
     * @var array
     */
    protected $covered = array();

    /**
     * Current horizontal rendering position on page
     * 
     * @var float
     */
    public $x;

    /**
     * Current vertical rendering position on page
     * 
     * @var float
     */
    public $y;

    /**
     * Width of current page - given in millimeters
     * 
     * @var float
     */
    protected $width;

    /**
     * Height of current page - given in millimeters
     * 
     * @var float
     */
    protected $height;

    /**
     * Inner width of current page - given in millimeters
     * 
     * @var float
     */
    protected $innerWidth;

    /**
     * Inner height of current page - given in millimeters
     * 
     * @var float
     */
    protected $innerHeight;

    /**
     * Array of pages sizes
     *
     * Associates known page size identifiers the actual size in millimeters.
     *
     * @var array
     */
    protected static $pageSizes = array(
        'A0'        => array( 841, 1189 ),
        'A1'        => array( 594, 841 ),
        'A2'        => array( 420, 594 ),
        'A3'        => array( 297, 420 ),
        'A4'        => array( 210, 297 ),
        'A5'        => array( 148, 210 ),
        'A6'        => array( 105, 148 ),
        'A7'        => array( 74, 105 ),
        'A8'        => array( 52, 74 ),
        'A9'        => array( 37, 52 ),
        'A10'       => array( 26, 37 ),
        'B0'        => array( 1000, 1414 ),
        'B1'        => array( 707, 1000 ),
        'B2'        => array( 500, 707 ),
        'B3'        => array( 353, 500 ),
        'B4'        => array( 250, 353 ),
        'B5'        => array( 176, 250 ),
        'B6'        => array( 125, 176 ),
        'B7'        => array( 88, 125 ),
        'B8'        => array( 62, 88 ),
        'B9'        => array( 44, 62 ),
        'B10'       => array( 31, 44 ),
        'C0'        => array( 917, 1297 ),
        'C1'        => array( 648, 917 ),
        'C2'        => array( 458, 648 ),
        'C3'        => array( 324, 458 ),
        'C4'        => array( 229, 324 ),
        'C5'        => array( 162, 229 ),
        'C6'        => array( 114, 162 ),
        'C7'        => array( 81, 114 ),
        'C8'        => array( 57, 81 ),
        'C9'        => array( 40, 57 ),
        'C10'       => array( 28, 40 ),
        'RA0'       => array( 860, 1220 ),
        'RA1'       => array( 610, 860 ),
        'RA2'       => array( 430, 610 ),
        'RA3'       => array( 305, 430 ),
        'RA4'       => array( 215, 305 ),
        'SRA0'      => array( 900, 1280 ),
        'SRA1'      => array( 640, 900 ),
        'SRA2'      => array( 450, 640 ),
        'SRA3'      => array( 320, 450 ),
        'SRA4'      => array( 225, 320 ),
        'LETTER'    => array( 215.9, 279.4 ),
        'LEGAL'     => array( 215.9, 355.6 ),
        'EXECUTIVE' => array( 184.1, 266.7 ),
        'FOLIO'     => array( 215.9, 330.2 ),
    );


    /**
     * Construct new fresh page from its dimensions
     * 
     * @param float $width 
     * @param float $height 
     * @return void
     */
    public function __construct( $width, $height, $innerWidth, $innerHeight )
    {
        $this->width       = (float) $width;
        $this->height      = (float) $height;
        $this->innerWidth  = (float) $innerWidth;
        $this->innerHeight = (float) $innerHeight;
    }

    /**
     * Create from user readable soze specification
     *
     * Create page from common page size abbreviations, like "A4" and page
     * orientation.
     * 
     * @param mixed $size 
     * @param mixed $orientation 
     * @param array $margin 
     * @param array $padding 
     * @return ezcDocumentPdfPage
     */
    public static function createFromSpecification( $size, $orientation, array $margin, array $padding )
    {
        if ( !isset( self::$pageSizes[$size] ) )
        {
            throw new ezcBaseValueException( "page-size", $size, implode( ', ', self::$pageSizes ) );
        }

        // Calculate border sizes, depending on assigned margin and
        // padding
        $topBorder    = $margin['top'] + $padding['top'];
        $leftBorder   = $margin['left'] + $padding['left'];
        $bottomBorder = $margin['bottom'] + $padding['bottom'];
        $rightBorder  = $margin['right'] + $padding['right'];

        switch ( $orientation )
        {<commit_msg>- Fixed tests by making inner width and height optional to constructor<commit_after><?php
/**
 * File containing the ezcDocumentPdfPage class
 *
 * @package Document
 * @version //autogen//
 * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
 * @license http://ez.no/licenses/new_bsd New BSD License
 * @access private
 */

/**
 * PDF page class
 *
 * Class containing context information about a single rendered page.
 *
 * It especially encodes information about already covered / blocked areas on
 * one PDF page, and offers methods to check if a new content block fits on the
 * page an, where it does fir on the page.
 *
 * @package Document
 * @access private
 * @version //autogen//
 */
class ezcDocumentPdfPage implements ezcDocumentPdfLocateable
{
    /**
     * Already covered areas, given as an arrays of ezcDocumentPdfBoundingBox
     * objects.
     * 
     * @var array
     */
    protected $covered = array();

    /**
     * Current horizontal rendering position on page
     * 
     * @var float
     */
    public $x;

    /**
     * Current vertical rendering position on page
     * 
     * @var float
     */
    public $y;

    /**
     * Width of current page - given in millimeters
     * 
     * @var float
     */
    protected $width;

    /**
     * Height of current page - given in millimeters
     * 
     * @var float
     */
    protected $height;

    /**
     * Inner width of current page - given in millimeters
     * 
     * @var float
     */
    protected $innerWidth;

    /**
     * Inner height of current page - given in millimeters
     * 
     * @var float
     */
    protected $innerHeight;

    /**
     * Array of pages sizes
     *
     * Associates known page size identifiers the actual size in millimeters.
     *
     * @var array
     */
    protected static $pageSizes = array(
        'A0'        => array( 841, 1189 ),
        'A1'        => array( 594, 841 ),
        'A2'        => array( 420, 594 ),
        'A3'        => array( 297, 420 ),
        'A4'        => array( 210, 297 ),
        'A5'        => array( 148, 210 ),
        'A6'        => array( 105, 148 ),
        'A7'        => array( 74, 105 ),
        'A8'        => array( 52, 74 ),
        'A9'        => array( 37, 52 ),
        'A10'       => array( 26, 37 ),
        'B0'        => array( 1000, 1414 ),
        'B1'        => array( 707, 1000 ),
        'B2'        => array( 500, 707 ),
        'B3'        => array( 353, 500 ),
        'B4'        => array( 250, 353 ),
        'B5'        => array( 176, 250 ),
        'B6'        => array( 125, 176 ),
        'B7'        => array( 88, 125 ),
        'B8'        => array( 62, 88 ),
        'B9'        => array( 44, 62 ),
        'B10'       => array( 31, 44 ),
        'C0'        => array( 917, 1297 ),
        'C1'        => array( 648, 917 ),
        'C2'        => array( 458, 648 ),
        'C3'        => array( 324, 458 ),
        'C4'        => array( 229, 324 ),
        'C5'        => array( 162, 229 ),
        'C6'        => array( 114, 162 ),
        'C7'        => array( 81, 114 ),
        'C8'        => array( 57, 81 ),
        'C9'        => array( 40, 57 ),
        'C10'       => array( 28, 40 ),
        'RA0'       => array( 860, 1220 ),
        'RA1'       => array( 610, 860 ),
        'RA2'       => array( 430, 610 ),
        'RA3'       => array( 305, 430 ),
        'RA4'       => array( 215, 305 ),
        'SRA0'      => array( 900, 1280 ),
        'SRA1'      => array( 640, 900 ),
        'SRA2'      => array( 450, 640 ),
        'SRA3'      => array( 320, 450 ),
        'SRA4'      => array( 225, 320 ),
        'LETTER'    => array( 215.9, 279.4 ),
        'LEGAL'     => array( 215.9, 355.6 ),
        'EXECUTIVE' => array( 184.1, 266.7 ),
        'FOLIO'     => array( 215.9, 330.2 ),
    );


    /**
     * Construct new fresh page from its dimensions
     * 
     * @param float $width 
     * @param float $height 
     * @param mixed $innerWidth 
     * @param mixed $innerHeight 
     * @return void
     */
    public function __construct( $width, $height, $innerWidth = null, $innerHeight = null )
    {
        $this->width       = (float) $width;
        $this->height      = (float) $height;
        $this->innerWidth  = $innerWidth === null ? $this->width : (float) $innerWidth;
        $this->innerHeight = $innerHeight === null ? $this->height : (float) $innerHeight;
    }

    /**
     * Create from user readable soze specification
     *
     * Create page from common page size abbreviations, like "A4" and page
     * orientation.
     * 
     * @param mixed $size 
     * @param mixed $orientation 
     * @param array $margin 
     * @param array $padding 
     * @return ezcDocumentPdfPage
     */
    public static function createFromSpecification( $size, $orientation, array $margin, array $padding )
    {
        if ( !isset( self::$pageSizes[$size] ) )
        {
            throw new ezcBaseValueException( "page-size", $size, implode( ', ', self::$pageSizes ) );
        }

        // Calculate border sizes, depending on assigned margin and
        // padding
        $topBorder    = $margin['top'] + $padding['top'];
        $leftBorder   = $margin['left'] + $padding['left'];
        $bottomBorder = $margin['bottom'] + $padding['bottom'];
        $rightBorder  = $margin['right'] + $padding['right'];

        switch ( $orientation )
        {
{'fraction_non_alphanumeric': 0.14278999811994736, 'fraction_numerical': 0.062229742432788115, 'mean_word_length': 1.6392954601835772, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 107, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5686974', 'n_tokens_mistral': 3849, 'n_tokens_neox': 3212, 'n_words': 989}