Write the HORIZONTALPAGEBREAKS BIFF record.

@access private
321389
function _storeHbreak()
    {
        // Return if the user hasn't specified pagebreaks
        if (empty($this->_hbreaks)) {
            return;
        }

        // Sort and filter array of page breaks
        $breaks = $this->_hbreaks;
        sort($breaks, SORT_NUMERIC);
        if ($breaks[0] == 0) { // don't use first break if it's 0
            array_shift($breaks);
        }

        $record  = 0x001b;               // Record identifier
        $cbrk    = count($breaks);       // Number of page breaks
        if ($this->_BIFF_version == 0x0600) {
            $length  = 2 + 6*$cbrk;      // Bytes to follow
        } else {
            $length  = 2 + 2*$cbrk;      // Bytes to follow
        }

        $header  = pack("vv", $record, $length);
        $data    = pack("v",  $cbrk);

        // Append each page break
        foreach ($breaks as $break) {
            if ($this->_BIFF_version == 0x0600) {
                $data .= pack("vvv", $break, 0x0000, 0x00ff);
            } else {
                $data .= pack("v", $break);
            }
        }

        $this->_prepend($header.$data);
    }
1151448
function _storeHcenter()
    {
        $record   = 0x0083;              // Record identifier
        $length   = 0x0002;              // Bytes to follow

        $fHCenter = $this->_hcenter;     // Horizontal centering

        $header    = pack("vv", $record, $length);
        $data      = pack("v",  $fHCenter);

        $this->_prepend($header.$data);
    }
1337417
function AcceptPageBreak()
	{
		if (count($this->cellBorderBuffer)) {
			$this->printcellbuffer();
		} // *TABLES*
		/* -- COLUMNS -- */
		if ($this->ColActive == 1) {
			if ($this->CurrCol < $this->NbCol - 1) {
				// Go to the next column
				$this->CurrCol++;
				$this->SetCol($this->CurrCol);
				$this->y = $this->y0;
				$this->ChangeColumn = 1; // Number (and direction) of columns changed +1, +2, -2 etc.
				// DIRECTIONALITY RTL
				if ($this->directionality == 'rtl') {
					$this->ChangeColumn = -($this->ChangeColumn);
				} // *OTL*
				// Stay on the page
				return false;
			} else {
				// Go back to the first column - NEW PAGE
				if (count($this->columnbuffer)) {
					$this->printcolumnbuffer();
				}
				$this->SetCol(0);
				$this->y0 = $this->tMargin;
				$this->ChangeColumn = -($this->NbCol - 1);
				// DIRECTIONALITY RTL
				if ($this->directionality == 'rtl') {
					$this->ChangeColumn = -($this->ChangeColumn);
				} // *OTL*
				// Page break
				return true;
			}
		} /* -- END COLUMNS -- */
		/* -- TABLES -- */ elseif ($this->table_rotate) {
			if ($this->tablebuffer) {
				$this->printtablebuffer();
			}
			return true;
		} /* -- END TABLES -- */ else { // *COLUMNS*
			$this->ChangeColumn = 0;
			return $this->autoPageBreak;
		} // *COLUMNS*
		return $this->autoPageBreak;
	}
711287
private  function _writeGuts()
	{
		$record	  = 0x0080;   // Record identifier
		$length	  = 0x0008;   // Bytes to follow

		$dxRwGut	 = 0x0000;   // Size of row gutter
		$dxColGut	= 0x0000;   // Size of col gutter

		// determine maximum row outline level
		$maxRowOutlineLevel = 0;
		foreach ($this->_phpSheet->getRowDimensions() as $rowDimension) {
			$maxRowOutlineLevel = max($maxRowOutlineLevel, $rowDimension->getOutlineLevel());
		}

		$col_level   = 0;

		// Calculate the maximum column outline level. The equivalent calculation
		// for the row outline level is carried out in _writeRow().
		$colcount = count($this->_colinfo);
		for ($i = 0; $i < $colcount; ++$i) {
			$col_level = max($this->_colinfo[$i][5], $col_level);
		}

		// Set the limits for the outline levels (0 <= x <= 7).
		$col_level = max(0, min($col_level, 7));

		// The displayed level is one greater than the max outline levels
		if ($maxRowOutlineLevel) {
			++$maxRowOutlineLevel;
		}
		if ($col_level) {
			++$col_level;
		}

		$header	  = pack("vv",   $record, $length);
		$data		= pack("vvvv", $dxRwGut, $dxColGut, $maxRowOutlineLevel, $col_level);

		$this->_append($header.$data);
	}
921032
public function write()
    {
        $lines = array();

        foreach ($this->data as $fetch) {
            $data = array($fetch['url'], $fetch['length'], $fetch['filename']);
            array_push($lines, join(' ', $data) . "\n");
        }

        if (count($lines) == 0) {
            if (file_exists($this->fileName)) {
                unlink($this->fileName);
            }
        } else {
            writeFileText($this->fileName, $this->fileEncoding, join('', $lines));
        }
    }
1208448
private function writeColumns(): void
  {
    $content = '';
    foreach ($this->columns as $table)
    {
      $width1 = 0;
      $width2 = 0;
      foreach ($table as $column)
      {
        $width1 = max(mb_strlen($column['column_name']), $width1);
        $width2 = max(mb_strlen((string)$column['length']), $width2);
      }

      foreach ($table as $column)
      {
        if (isset($column['length']))
        {
          if (isset($column['constant_name']))
          {
            $line_format = sprintf("%%s.%%-%ds %%%dd %%s\n", $width1, $width2);
            $content     .= sprintf($line_format,
                                    $column['table_name'],
                                    $column['column_name'],
                                    $column['length'],
                                    $column['constant_name']);
          }
          else
          {
            $line_format = sprintf("%%s.%%-%ds %%%dd\n", $width1, $width2);
            $content     .= sprintf($line_format,
                                    $column['table_name'],
                                    $column['column_name'],
                                    $column['length']);
          }
        }
      }

      $content .= "\n";
    }

    // Save the columns, width and constants to the filesystem.
    $this->writeTwoPhases($this->constantsFilename, $content);
  }
421339
protected function write()
	{
		$file		= new FS_File_Writer( $this->fileName );
		$newLines	= array();
		$currentSection	= "";
		foreach( $this->lines as $line )
		{
			if( $this->usesSections() && preg_match( $this->patternSection, $line ) )
			{
				$lastSection = $currentSection;
#				$newAdded = array();
				if( $lastSection )
				{
					foreach( $this->added as $nr => $property )
					{
						if( $property['section'] == $lastSection )
						{
							if( !trim( $newLines[count($newLines)-1] ) )
								array_pop( $newLines );
							$newLines[]	= $this->buildLine( $property['key'], $property['value'], $property['comment'] );
							$newLines[]	= "";
							unset( $this->added[$nr] );
						}
#						else $newAdded[] = $property;
					}
				}
				$currentSection =  substr( trim( $line ), 1, -1 );
				if( !in_array( $currentSection, $this->sections ) )
					continue;
			}
			else if( preg_match( $this->patternProperty, $line ) )
			{
				$pos		= strpos( $line, "=" );
				$key		= trim( substr( $line, 0, $pos ) );
				$pureKey	= preg_replace( $this->patternDisabled, "", $key );
				$parts		= explode(  "//", trim( substr( $line, $pos+1 ) ) );
				if( count( $parts ) > 1 )
					$comment = trim( $parts[1] );
				if( $this->usesSections() )
				{
					if( in_array( $currentSection, $this->sections ) )
					{
						if( isset( $this->deleted[$currentSection] ) && in_array( $pureKey, $this->deleted[$currentSection] ) )
							unset( $line );
						else if( isset( $this->renamed[$currentSection] ) && in_array( $pureKey, array_keys( $this->renamed[$currentSection] ) ) )
						{
							$newKey	= $key	= $this->renamed[$currentSection][$pureKey];
							if( !$this->isActiveProperty( $newKey, $currentSection) )
								$key = $this->signDisabled.$key;
							$comment	= isset( $this->comments[$currentSection][$newKey] ) ? $this->comments[$currentSection][$newKey] : "";
							$line = $this->buildLine( $key, $this->properties[$currentSection][$newKey], $comment );
						}
						else
						{
							if( $this->isActiveProperty( $pureKey, $currentSection ) && preg_match( $this->patternDisabled, $key ) )
								$key = substr( $key, 1 );
							else if( !$this->isActiveProperty( $pureKey, $currentSection ) && !preg_match( $this->patternDisabled, $key ) )
								$key = $this->signDisabled.$key;
							$comment	= isset( $this->comments[$currentSection][$pureKey] ) ? $this->comments[$currentSection][$pureKey] : "";
							$line = $this->buildLine( $key, $this->properties[$currentSection][$pureKey], $comment );
						}
					}
					else
						unset( $line );
				}
				else
				{
					if( in_array( $pureKey, $this->deleted ) )
						unset( $line);
					else if( in_array( $pureKey, array_keys( $this->renamed ) ) )
					{
						$newKey	= $key	= $this->renamed[$pureKey];
						if( !$this->isActiveProperty( $newKey ) )
							$key = $this->signDisabled.$key;
						$line = $this->buildLine( $newKey, $this->properties[$newKey], $this->comments[$newKey] );
					}
					else
					{
						if( $this->isActiveProperty( $pureKey ) && preg_match( $this->patternDisabled, $key ) )
							$key = substr( $key, 1 );
						else if( !$this->isActiveProperty( $pureKey) && !preg_match( $this->patternDisabled, $key ) )
							$key = $this->signDisabled.$key;
						$line = $this->buildLine( $key, $this->properties[$pureKey], $this->getComment( $pureKey ) );
					}
				}
			}
			if( isset( $line ) )
				$newLines[] = $line;
		}
		foreach( $this->added as $property )
		{
			$newLine	= $this->buildLine( $property['key'], $property['value'], $property['comment'] );
			$newLines[]	= $newLine;
		}
		$result			= $file->writeArray( $newLines );
		$this->added	= array();
		$this->deleted	= array();
		$this->renamed	= array();
		$this->read();
		return $result;
	}
1141154
private function _writeZoom()
	{
		// If scale is 100 we don't need to write a record
		if ($this->_phpSheet->getSheetView()->getZoomScale() == 100) {
			return;
		}

		$record	  = 0x00A0;			   // Record identifier
		$length	  = 0x0004;			   // Bytes to follow

		$header	  = pack("vv", $record, $length);
		$data		= pack("vv", $this->_phpSheet->getSheetView()->getZoomScale(), 100);
		$this->_append($header . $data);
	}
358176
function flushLinebreaks() {
    if ($this->lineBreaks && !empty($this->output)) {
      $this->out(str_repeat("\n".$this->indent, $this->lineBreaks), true);
    }
    $this->lineBreaks = 0;
  }
36770
def write_record(self, event_str):
        """"""
        header = struct.pack('Q', len(event_str))
        header += struct.pack('I', masked_crc32c(header))
        footer = struct.pack('I', masked_crc32c(event_str))
        self._writer.write(header + event_str + footer)
508792
private function _writeProtect()
	{
		// Exit unless sheet protection has been specified
		if (!$this->_phpSheet->getProtection()->getSheet()) {
			return;
		}

		$record	  = 0x0012;			 // Record identifier
		$length	  = 0x0002;			 // Bytes to follow

		$fLock	  = 1;	// Worksheet is protected

		$header	  = pack("vv", $record, $length);
		$data	  = pack("v",  $fLock);

		$this->_append($header.$data);
	}
730664
public function write() {
        // Determine the width of the last column.
        $columnWidths = array_sum($this->columnWidths);
        $totalWidth = $this->indent + $columnWidths + $this->padding * (count($this->columnWidths) - 1);

        $lastWidth = end($this->columnWidths) + $this->maxWidth - $totalWidth;
        $lastWidth = max($lastWidth, 10); // min width of 10
        $this->columnWidths[count($this->columnWidths) - 1] = $lastWidth;

        // Loop through each row and write it.
        foreach ($this->rows as $row) {
            $rowLines = [];
            $lineCount = 0;

            // Split the cells into lines.
            foreach ($row as $i => $cell) {
                list($text,) = $cell;
                $width = $this->columnWidths[$i];

                $lines = Cli::breakLines($text, $width, $i < count($this->columnWidths) - 1);
                $rowLines[] = $lines;
                $lineCount = max($lineCount, count($lines));
            }

            // Write all of the lines.
            for ($i = 0; $i < $lineCount; $i++) {
                foreach ($rowLines as $j => $lines) {
                    $padding = $j === 0 ? $this->indent : $this->padding;

                    if (isset($lines[$i])) {
                        if ($this->formatOutput) {
                            if(isset($row[$j])) {
                                $wrap = $row[$j][1];
                            } else {
                                // if we're out of array, use the latest wraps
                                $wrap = $row[count($row)-1][1];
                            }

                            echo str_repeat(' ', $padding).$wrap[0].$lines[$i].$wrap[1];
                        } else {
                            echo str_repeat(' ', $padding).$lines[$i];
                        }
                    } elseif ($j < count($this->columnWidths) - 1) {
                        // This is an empty line. Write the spaces.
                        echo str_repeat(' ', $padding + $this->columnWidths[$j]);
                    }
                }
                echo PHP_EOL;
            }
        }
    }
432709
private function _writeSupbookInternal()
	{
		$record    = 0x01AE;   // Record identifier
		$length    = 0x0004;   // Bytes to follow

		$header    = pack("vv", $record, $length);
		$data      = pack("vv", $this->_phpExcel->getSheetCount(), 0x0401);
		return $this->writeData($header . $data);
	}
11397
function _storeFooter()
    {
        $record  = 0x0015;               // Record identifier

        $str      = $this->_footer;       // Footer string
        $cch      = strlen($str);         // Length of footer string
        if ($this->_BIFF_version == 0x0600) {
            $encoding = 0x0;                  // TODO: Unicode support
            $length   = 3 + $cch;             // Bytes to follow
        } else {
            $length  = 1 + $cch;
        }

        $header    = pack("vv", $record, $length);
        if ($this->_BIFF_version == 0x0600) {
            $data      = pack("vC",  $cch, $encoding);
        } else {
            $data      = pack("C",  $cch);
        }

        $this->_prepend($header . $data . $str);
    }
1329066
private function _writeFooter()
	{
		$record  = 0x0015;			   // Record identifier

		/* removing for now
		// need to fix character count (multibyte!)
		if (strlen($this->_phpSheet->getHeaderFooter()->getOddFooter()) <= 255) {
			$str = $this->_phpSheet->getHeaderFooter()->getOddFooter();
		} else {
			$str = '';
		}
		*/

		$recordData = PHPExcel_Shared_String::UTF8toBIFF8UnicodeLong($this->_phpSheet->getHeaderFooter()->getOddFooter());
		$length = strlen($recordData);

		$header	= pack("vv", $record, $length);

		$this->_append($header . $recordData);
	}
1027127
public function render()
    {
        $writer = $this->_rtf->getWriter();

        //headers
        $headers = $this->_headers ? $this->_headers : $this->_rtf->getHeaders();
        if (!empty($headers)) {
            foreach ($headers as $header) {
                $header->render();
            }
        }

        //footers
        $footers = $this->_footers ? $this->_footers : $this->_rtf->getFooters();
        if (!empty($footers)) {
            foreach ($footers as $footer) {
                $footer->render();
            }
        }

        //borders
        if ($this->_border) {
            if ($this->_borderSurroundsHeader) {
                $writer->write('\pgbrdrhead');
            }
            if ($this->_borderSurroundsFooter) {
                $writer->write('\pgbrdrfoot');
            }
            $writer->write($this->_border->getContent('\pg'));
        }
        else if ($border = $this->_rtf->getBorder()) {
            if ($this->_rtf->borderSurroundsHeader()) {
                $writer->write('\pgbrdrhead');
            }
            if ($this->_rtf->borderSurroundsFooter()) {
                $writer->write('\pgbrdrfoot');
            }
            $writer->write($border->getContent('\pg'));
        }

        //do not break within the section
        if ($this->_doNotBreak) {
            $writer->write('\sbknone ');
        }

        //set column index, when using more than one column for this section
        if ($this->_numberOfColumns > 1) {
            $writer->write('\cols' . $this->_numberOfColumns . ' ');
        }

        if (empty($this->_columnWidths)) {
            if ($this->_spaceBetweenColumns) {
                  $writer->write('\colsx' . PHPRtfLite_Unit::getUnitInTwips($this->_spaceBetweenColumns) . ' ');
            }
        }
        else {
            $width = 0;
            foreach ($this->_columnWidths as $value) {
                $width += PHPRtfLite_Unit::getUnitInTwips($value);
            }

            $printableWidth = $this->_rtf->getPaperWidth() - $this->_rtf->getMarginLeft() - $this->_rtf->getMarginRight();
            $space = round((PHPRtfLite_Unit::getUnitInTwips($printableWidth) - $width) / (count($this->_columnWidths) - 1));

            $i = 1;
            foreach ($this->_columnWidths as $key => $value) {
                $writer->write('\colno' . $i . '\colw' . PHPRtfLite_Unit::getUnitInTwips($value));
                if (!empty($this->_columnWidths[$key])) {
                    $writer->write('\colsr' . $space);
                }
                $i++;
            }
            $writer->write(' ');
        }

        if ($this->_lineBetweenColumns) {
            $writer->write('\linebetcol ');
        }

        /*---Page part---*/
        if ($this->_isLandscape) {
            $writer->write('\lndscpsxn ');
        }

        if ($this->_paperWidth) {
            $writer->write('\pgwsxn' . PHPRtfLite_Unit::getUnitInTwips($this->_paperWidth) . ' ');
        }

        if ($this->_paperHeight) {
            $writer->write('\pghsxn' . PHPRtfLite_Unit::getUnitInTwips($this->_paperHeight) . ' ');
        }

        if ($this->_marginLeft) {
            $writer->write('\marglsxn' . PHPRtfLite_Unit::getUnitInTwips($this->_marginLeft) . ' ');
        }

        if ($this->_marginRight) {
            $writer->write('\margrsxn' . PHPRtfLite_Unit::getUnitInTwips($this->_marginRight) . ' ');
        }

        if ($this->_marginTop) {
            $writer->write('\margtsxn' . PHPRtfLite_Unit::getUnitInTwips($this->_marginTop) . ' ');
        }

        if ($this->_marginBottom) {
            $writer->write('\margbsxn' . PHPRtfLite_Unit::getUnitInTwips($this->_marginBottom) . ' ');
        }

        if ($this->_gutter) {
            $writer->write('\guttersxn' . PHPRtfLite_Unit::getUnitInTwips($this->_gutter) . ' ');
        }

        if ($this->_useMirrorMargins) {
            $writer->write('\margmirsxn ');
        }

        if ($this->_font) {
            $writer->write($this->_font->getContent());
        }

        $writer->write("\r\n");
        parent::render();
        $writer->write("\r\n");
    }
210617
function _storeVbreak()
    {
        // Return if the user hasn't specified pagebreaks
        if (empty($this->_vbreaks)) {
            return;
        }

        // 1000 vertical pagebreaks appears to be an internal Excel 5 limit.
        // It is slightly higher in Excel 97/200, approx. 1026
        $breaks = array_slice($this->_vbreaks,0,1000);

        // Sort and filter array of page breaks
        sort($breaks, SORT_NUMERIC);
        if ($breaks[0] == 0) { // don't use first break if it's 0
            array_shift($breaks);
        }

        $record  = 0x001a;               // Record identifier
        $cbrk    = count($breaks);       // Number of page breaks
        if ($this->_BIFF_version == 0x0600) {
            $length  = 2 + 6*$cbrk;      // Bytes to follow
        } else {
            $length  = 2 + 2*$cbrk;      // Bytes to follow
        }

        $header  = pack("vv",  $record, $length);
        $data    = pack("v",   $cbrk);

        // Append each page break
        foreach ($breaks as $break) {
            if ($this->_BIFF_version == 0x0600) {
                $data .= pack("vvv", $break, 0x0000, 0xffff);
            } else {
                $data .= pack("v", $break);
            }
        }

        $this->_prepend($header . $data);
    }