_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q251300 | MemoryCacheItemPool.commit | validation | public function commit()
{
foreach ($this->deferred as $item) {
/* @var $item \Psr6NullCache\CacheItem */
$this->save($item);
}
$this->deferred = [];
return true;
} | php | {
"resource": ""
} |
q251301 | MetaHandler.set | validation | public function set($key, $value)
{
$meta = $this->metaModel::where('key', $key)->first();
if ($meta === null) {
$meta = new $this->metaModel;
$meta->key = $key;
}
$meta->value = $value;
$meta->save();
} | php | {
"resource": ""
} |
q251302 | MetaHandler.create | validation | public function create($key, $value)
{
$exists = $this->metaModel::where('key', $key)
->exists();
if ($exists) {
$message = "Can't create meta (key: $key). ";
$message .= "Meta already exists";
throw new \Exception($message);
}
$meta = new $this->metaModel;
$meta->key = $key;
$meta->value = $value;
$meta->save();
} | php | {
"resource": ""
} |
q251303 | MetaHandler.update | validation | public function update($key, $value)
{
try {
$meta = $this->metaModel::where('key', $key)
->firstOrFail();
} catch (\Exception $e) {
$message = "Can't update meta (key: $key). ";
$message .= "Meta doesn't exist";
throw new \Exception($message);
}
$meta->value = $value;
$meta->save();
} | php | {
"resource": ""
} |
q251304 | MetaHandler.get | validation | public function get($key, $default = null)
{
$meta = $this->metaModel::where('key', $key)
->first();
return $meta === null
? $default
: $meta->value;
} | php | {
"resource": ""
} |
q251305 | MetaHandler.all | validation | public function all()
{
$meta = $this->metaModel::get(['key', 'value', 'type']);
$data = [];
foreach ($meta as $m) {
$data[$m->key] = $m->value;
}
return $data;
} | php | {
"resource": ""
} |
q251306 | ParametersData.setPieces | validation | public function setPieces($pieces)
{
if ($pieces && !$pieces instanceof PieceBag) {
$pieces = new PieceBag(is_array($pieces) ? $pieces : []);
}
return $this->setParameter('pieces', $pieces);
} | php | {
"resource": ""
} |
q251307 | FakerController.actionGenerate | validation | public function actionGenerate()
{
$input = $this->parseArguments(func_get_args());
$container = new Container();
$container->set(GeneratorInterface::class, array_merge(['class' => $this->generator_fqn], $input['generator']));
$container->set(DbProviderInterface::class, array_merge(['class' => $this->dbprovider_fqn], $input['dbprovider']));
$this->generator_obj = $container->get(GeneratorInterface::class);
if (!$this->force && !$this->confirmGeneration()) {
return;
}
$this->dbprovider_obj = $container->get(DbProviderInterface::class);
Console::startProgress(0, $this->count);
foreach ($this->dbprovider_obj->export($this->count) as $count) {
Console::updateProgress($this->count - $count, $this->count);
}
Console::endProgress(true);
} | php | {
"resource": ""
} |
q251308 | Renderer.registerTags | validation | protected function registerTags()
{
// register the "normal" tags, ie tags that are not form controls (widgets, see below)
$tags = array('error', 'hint', 'label', 'radioset', 'checkboxset');
foreach ($tags as $tag) {
$tagClass = str_replace(' ', '', ucwords(str_replace('-', ' ', $tag)));
$this->registerTag($tag, __NAMESPACE__ . '\Tag\\' . $tagClass);
}
// register the "widget" tags, ie tags that are inputs
$widgets = array(
'text',
'file',
'textarea',
'radio',
'checkbox',
'select',
'multiselect',
'checkboxset',
'radioset',
'email',
'password',
'radioset',
'checkboxset',
// buttons
'button',
'submit',
'reset',
// containers
'group',
'fieldset',
'collection',
'form'
);
foreach ($widgets as $widget) {
$widgetClass = str_replace(' ', '', ucwords(str_replace('-', ' ', $widget)));
$this->registerTag('widget-' . $widget, __NAMESPACE__ . '\Widget\\' . $widgetClass);
}
} | php | {
"resource": ""
} |
q251309 | Renderer.registerDecorators | validation | protected function registerDecorators()
{
$decorators = array('AutoId');
foreach ($decorators as $decoratorClass) {
$decoratorClass = '\\Sirius\FormRenderer\\Decorator\\' . $decoratorClass;
$this->addDecorator(new $decoratorClass);
}
} | php | {
"resource": ""
} |
q251310 | Renderer.addDecorator | validation | public function addDecorator(TagDecoratorInterface $decorator, $priority = 0)
{
$this->decorators->add($decorator, $priority);
return $this;
} | php | {
"resource": ""
} |
q251311 | Renderer.make | validation | public function make($tag, $props = null, $content = null)
{
$tag = parent::make($tag, $props, $content);
$tag = $this->decorators->apply($tag, $this);
return $tag;
} | php | {
"resource": ""
} |
q251312 | Renderer.render | validation | public function render(InputFilter $inputFilter)
{
$inputFilter->prepare(); // ensure it is prepare
$props = $inputFilter->getAttributes();
$treeBuilder = new TreeBuilder($inputFilter);
$props = array_merge($props, $treeBuilder->getTree());
return $this->make('widget-form', $props);
} | php | {
"resource": ""
} |
q251313 | TargetGroup.fromXML | validation | function fromXML($xmlElement)
{
$this->id = $xmlElement->id;
$this->name = $xmlElement->name;
$this->author = $xmlElement->author;
$this->state = $xmlElement->state;
$this->type = $xmlElement->type;
$this->contactFilterName = $xmlElement->contact_filter_name;
$this->contactFilterId = $xmlElement->contact_filter_id;
$this->evaluated = $xmlElement->evaluated;
$this->created = $xmlElement->created;
$this->updated = $xmlElement->updated;
$this->countActiveContacts = $xmlElement->count_active_contacts;
$this->countContacts = $xmlElement->count_contacts;
} | php | {
"resource": ""
} |
q251314 | Drawing.allDrawings | validation | public function allDrawings(Spreadsheet $spreadsheet)
{
// Get an array of all drawings
$aDrawings = [];
// Loop through PhpSpreadsheet
$sheetCount = $spreadsheet->getSheetCount();
for ($i = 0; $i < $sheetCount; ++$i) {
// Loop through images and add to array
$iterator = $spreadsheet->getSheet($i)->getDrawingCollection()->getIterator();
while ($iterator->valid()) {
$aDrawings[] = $iterator->current();
$iterator->next();
}
}
return $aDrawings;
} | php | {
"resource": ""
} |
q251315 | SynchronizationMode.init | validation | static function init()
{
if (self::$initialized == false) {
self::$UPDATE = new SynchronizationMode(1);
self::$IGNORE = new SynchronizationMode(2);
self::$initialized = true;
}
} | php | {
"resource": ""
} |
q251316 | StringHelper.controlCharacterOOXML2PHP | validation | public static function controlCharacterOOXML2PHP($value)
{
self::buildCharacterSets();
return str_replace(array_keys(self::$controlCharacters), array_values(self::$controlCharacters), $value);
} | php | {
"resource": ""
} |
q251317 | StringHelper.controlCharacterPHP2OOXML | validation | public static function controlCharacterPHP2OOXML($value)
{
self::buildCharacterSets();
return str_replace(array_values(self::$controlCharacters), array_keys(self::$controlCharacters), $value);
} | php | {
"resource": ""
} |
q251318 | StringHelper.sanitizeUTF8 | validation | public static function sanitizeUTF8($value)
{
if (self::getIsIconvEnabled()) {
$value = @iconv('UTF-8', 'UTF-8', $value);
return $value;
}
$value = mb_convert_encoding($value, 'UTF-8', 'UTF-8');
return $value;
} | php | {
"resource": ""
} |
q251319 | StringHelper.convertEncoding | validation | public static function convertEncoding($value, $to, $from)
{
if (self::getIsIconvEnabled()) {
$result = iconv($from, $to . '//IGNORE//TRANSLIT', $value);
if (false !== $result) {
return $result;
}
}
return mb_convert_encoding($value, $to, $from);
} | php | {
"resource": ""
} |
q251320 | StringHelper.strCaseReverse | validation | public static function strCaseReverse($pValue)
{
$characters = self::mbStrSplit($pValue);
foreach ($characters as &$character) {
if (self::mbIsUpper($character)) {
$character = mb_strtolower($character, 'UTF-8');
} else {
$character = mb_strtoupper($character, 'UTF-8');
}
}
return implode('', $characters);
} | php | {
"resource": ""
} |
q251321 | StringHelper.getCurrencyCode | validation | public static function getCurrencyCode()
{
if (!empty(self::$currencyCode)) {
return self::$currencyCode;
}
self::$currencyCode = '$';
$localeconv = localeconv();
if (!empty($localeconv['currency_symbol'])) {
self::$currencyCode = $localeconv['currency_symbol'];
return self::$currencyCode;
}
if (!empty($localeconv['int_curr_symbol'])) {
self::$currencyCode = $localeconv['int_curr_symbol'];
return self::$currencyCode;
}
return self::$currencyCode;
} | php | {
"resource": ""
} |
q251322 | AujaServiceProvider.registerManager | validation | protected function registerManager()
{
$this->app->singleton('auja', function ($app) {
$config = $app['config']['auja-laravel'] ?: $app['config']['auja-laravel::config'];
return new Auja($app, $app['auja.configurator'], $config['models']);
});
$this->app->bind('Label305\AujaLaravel\Auja', 'auja');
} | php | {
"resource": ""
} |
q251323 | AujaServiceProvider.registerConfigurator | validation | protected function registerConfigurator()
{
$this->app->singleton('auja.database', function($app) {
$config = $app['config']['auja-laravel'] ?: $app['config']['auja-laravel::config'];
switch ($config['database']) {
case 'mysql':
return new MySQLDatabaseHelper();
break;
default:
throw new NoDatabaseHelperException('No Auja database helper for ' . $config['database']);
break;
}
});
$this->app->bind('Label305\AujaLaravel\Database\DatabaseHelper', 'auja.database');
$this->app->singleton('auja.configurator', function($app) {
return new AujaConfigurator($app, $app['auja.database']);
});
$this->app->bind('Label305\AujaLaravel\Config\AujaConfigurator', 'auja.configurator');
} | php | {
"resource": ""
} |
q251324 | AujaServiceProvider.registerRouter | validation | protected function registerRouter()
{
$this->app->singleton('auja.router', function($app) {
$config = $app['config']['auja-laravel'] ?: $app['config']['auja-laravel::config'];
return new AujaRouter($app['auja'], $app['router'], $config['route']);
});
$this->app->bind('Label305\AujaLaravel\Routing\AujaRouter', 'auja.router');
} | php | {
"resource": ""
} |
q251325 | Cli.write | validation | protected function write( $stream, $text )
{
$fp = fopen( $stream, 'a' );
fwrite( $fp, $text );
fclose( $fp );
} | php | {
"resource": ""
} |
q251326 | Cli.setMapping | validation | public function setMapping( $severity, $pipe )
{
if ( !isset( $this->mapping[$severity] ) )
{
throw new \RuntimeException( "Unknown severity: " . $severity );
}
if ( ( $pipe !== self::SILENCE ) &&
( $pipe !== self::STDOUT ) &&
( $pipe !== self::STDERR ) )
{
throw new \RuntimeException( "Unknown output pipe: " . $pipe );
}
$this->mapping[$severity] = $pipe;
} | php | {
"resource": ""
} |
q251327 | Logger.writeDebugLog | validation | public function writeDebugLog(...$args)
{
// Only write the debug log if logging is enabled
if ($this->writeDebugLog) {
$message = implode($args);
$cellReference = implode(' -> ', $this->cellStack->showStack());
if ($this->echoDebugLog) {
echo $cellReference,
($this->cellStack->count() > 0 ? ' => ' : ''),
$message,
PHP_EOL;
}
$this->debugLog[] = $cellReference .
($this->cellStack->count() > 0 ? ' => ' : '') .
$message;
}
} | php | {
"resource": ""
} |
q251328 | Ods.createZip | validation | private function createZip($pFilename)
{
// Create new ZIP file and open it for writing
$zip = new ZipArchive();
if (file_exists($pFilename)) {
unlink($pFilename);
}
// Try opening the ZIP file
if ($zip->open($pFilename, ZipArchive::OVERWRITE) !== true) {
if ($zip->open($pFilename, ZipArchive::CREATE) !== true) {
throw new WriterException("Could not open $pFilename for writing.");
}
}
return $zip;
} | php | {
"resource": ""
} |
q251329 | Transaction.addAttachmentFromBinaryData | validation | function addAttachmentFromBinaryData($filename, $mimetype, $contents) {
$attachment = new Attachment($filename, $mimetype, base64_encode($contents));
$this->attachments[] = $attachment;
} | php | {
"resource": ""
} |
q251330 | Transaction.addAttachmentFromBase64Data | validation | function addAttachmentFromBase64Data($filename, $mimetype, $contents) {
$attachment = new Attachment($filename, $mimetype, $contents);
$this->attachments[] = $attachment;
} | php | {
"resource": ""
} |
q251331 | Services_Libravatar.getUrl | validation | public function getUrl($identifier, $options = array())
{
// If no identifier has been passed, set it to a null.
// This way, there'll always be something returned.
if (!$identifier) {
$identifier = null;
} else {
$identifier = $this->normalizeIdentifier($identifier);
}
// Load all options
$options = $this->checkOptionsArray($options);
$https = $this->https;
if (isset($options['https'])) {
$https = (bool)$options['https'];
}
$algorithm = $this->algorithm;
if (isset($options['algorithm'])) {
$algorithm = $this->processAlgorithm($options['algorithm']);
}
$default = $this->default;
if (isset($options['default'])) {
$default = $this->processDefault($options['default']);
}
$size = $this->size;
if (isset($options['size'])) {
$size = $this->processSize($options['size']);
}
$identifierHash = $this->identifierHash($identifier, $algorithm);
// Get the domain so we can determine the SRV stuff for federation
$domain = $this->domainGet($identifier);
// If https has been specified in $options, make sure we make the
// correct SRV lookup
$service = $this->srvGet($domain, $https);
$protocol = $https ? 'https' : 'http';
$params = array();
if ($size !== null) {
$params['size'] = $size;
}
if ($default !== null) {
$params['default'] = $default;
}
$paramString = '';
if (count($params) > 0) {
$paramString = '?' . http_build_query($params);
}
// Compose the URL from the pieces we generated
$url = $protocol . '://' . $service . '/avatar/' . $identifierHash
. $paramString;
// Return the URL string
return $url;
} | php | {
"resource": ""
} |
q251332 | Services_Libravatar.checkOptionsArray | validation | protected function checkOptionsArray($options)
{
//this short options are deprecated!
if (isset($options['s'])) {
$options['size'] = $options['s'];
unset($options['s']);
}
if (isset($options['d'])) {
$options['default'] = $options['d'];
unset($options['d']);
}
$allowedOptions = array(
'algorithm' => true,
'default' => true,
'https' => true,
'size' => true,
);
foreach ($options as $key => $value) {
if (!isset($allowedOptions[$key])) {
throw new InvalidArgumentException(
'Invalid option in array: ' . $key
);
}
}
return $options;
} | php | {
"resource": ""
} |
q251333 | Services_Libravatar.identifierHash | validation | protected function identifierHash($identifier, $hash = 'md5')
{
if (filter_var($identifier, FILTER_VALIDATE_EMAIL) || $identifier === null) {
// If email, we can select our algorithm. Default to md5 for
// gravatar fallback.
return hash($hash, $identifier);
}
//no email, so the identifier has to be an OpenID
return hash('sha256', $identifier);
} | php | {
"resource": ""
} |
q251334 | Services_Libravatar.domainGet | validation | protected function domainGet($identifier)
{
if ($identifier === null) {
return null;
}
// What are we, email or openid? Split ourself up and get the
// important bit out.
if (filter_var($identifier, FILTER_VALIDATE_EMAIL)) {
$email = explode('@', $identifier);
return $email[1];
}
//OpenID
$url = parse_url($identifier);
if (!isset($url['host'])) {
//invalid URL
return null;
}
$domain = $url['host'];
if (isset($url['port']) && $url['scheme'] === 'http'
&& $url['port'] != 80
|| isset($url['port']) && $url['scheme'] === 'https'
&& $url['port'] != 443
) {
$domain .= ':' . $url['port'];
}
return $domain;
} | php | {
"resource": ""
} |
q251335 | Services_Libravatar.srvGet | validation | protected function srvGet($domain, $https = false)
{
// Are we going secure? Set up a fallback too.
if (isset($https) && $https === true) {
$subdomain = '_avatars-sec._tcp.';
$fallback = 'seccdn.';
$port = 443;
} else {
$subdomain = '_avatars._tcp.';
$fallback = 'cdn.';
$port = 80;
}
if ($domain === null) {
// No domain means invalid email address/openid
return $fallback . 'libravatar.org';
}
// Lets try get us some records based on the choice of subdomain
// and the domain we had passed in.
$srv = dns_get_record($subdomain . $domain, DNS_SRV);
// Did we get anything? No?
if (count($srv) == 0) {
// Then let's try Libravatar.org.
return $fallback . 'libravatar.org';
}
// Sort by the priority. We must get the lowest.
usort($srv, array($this, 'comparePriority'));
$top = $srv[0];
$sum = 0;
// Try to adhere to RFC2782's weighting algorithm, page 3
// "arrange all SRV RRs (that have not been ordered yet) in any order,
// except that all those with weight 0 are placed at the beginning of
// the list."
shuffle($srv);
$srvs = array();
foreach ($srv as $s) {
if ($s['weight'] == 0) {
array_unshift($srvs, $s);
} else {
array_push($srvs, $s);
}
}
foreach ($srvs as $s) {
if ($s['pri'] == $top['pri']) {
// "Compute the sum of the weights of those RRs"
$sum += (int) $s['weight'];
// "and with each RR associate the running sum in the selected
// order."
$pri[$sum] = $s;
}
}
// "Then choose a uniform random number between 0 and the sum computed
// (inclusive)"
$random = rand(0, $sum);
// "and select the RR whose running sum value is the first in the selected
// order which is greater than or equal to the random number selected"
foreach ($pri as $k => $v) {
if ($k >= $random) {
$target = $v['target'];
if ($v['port'] !== $port) {
$target.= ':'. $v['port'];
}
return $target;
}
}
} | php | {
"resource": ""
} |
q251336 | Services_Libravatar.processDefault | validation | protected function processDefault($url)
{
if ($url === null) {
return $url;
}
$url = (string)$url;
switch ($url) {
case '404':
case 'mm':
case 'identicon':
case 'monsterid':
case 'wavatar':
case 'retro':
break;
default:
$valid = filter_var($url, FILTER_VALIDATE_URL);
if (!$valid) {
throw new InvalidArgumentException('Invalid default avatar URL');
}
break;
}
return $url;
} | php | {
"resource": ""
} |
q251337 | Services_Libravatar.processSize | validation | protected function processSize($size)
{
if ($size === null) {
return $size;
}
$size = (int)$size;
if ($size <= 0) {
throw new InvalidArgumentException('Size has to be larger than 0');
}
return (int)$size;
} | php | {
"resource": ""
} |
q251338 | Worksheet.writeBIFF8CellRangeAddressFixed | validation | private function writeBIFF8CellRangeAddressFixed($range)
{
$explodes = explode(':', $range);
// extract first cell, e.g. 'A1'
$firstCell = $explodes[0];
// extract last cell, e.g. 'B6'
if (count($explodes) == 1) {
$lastCell = $firstCell;
} else {
$lastCell = $explodes[1];
}
$firstCellCoordinates = Coordinate::coordinateFromString($firstCell); // e.g. [0, 1]
$lastCellCoordinates = Coordinate::coordinateFromString($lastCell); // e.g. [1, 6]
return pack('vvvv', $firstCellCoordinates[1] - 1, $lastCellCoordinates[1] - 1, Coordinate::columnIndexFromString($firstCellCoordinates[0]) - 1, Coordinate::columnIndexFromString($lastCellCoordinates[0]) - 1);
} | php | {
"resource": ""
} |
q251339 | Worksheet.setOutline | validation | public function setOutline($visible = true, $symbols_below = true, $symbols_right = true, $auto_style = false)
{
$this->outlineOn = $visible;
$this->outlineBelow = $symbols_below;
$this->outlineRight = $symbols_right;
$this->outlineStyle = $auto_style;
// Ensure this is a boolean vale for Window2
if ($this->outlineOn) {
$this->outlineOn = 1;
}
} | php | {
"resource": ""
} |
q251340 | Worksheet.writeString | validation | private function writeString($row, $col, $str, $xfIndex)
{
$this->writeLabelSst($row, $col, $str, $xfIndex);
} | php | {
"resource": ""
} |
q251341 | Worksheet.writeRichTextString | validation | private function writeRichTextString($row, $col, $str, $xfIndex, $arrcRun)
{
$record = 0x00FD; // Record identifier
$length = 0x000A; // Bytes to follow
$str = StringHelper::UTF8toBIFF8UnicodeShort($str, $arrcRun);
// check if string is already present
if (!isset($this->stringTable[$str])) {
$this->stringTable[$str] = $this->stringUnique++;
}
++$this->stringTotal;
$header = pack('vv', $record, $length);
$data = pack('vvvV', $row, $col, $xfIndex, $this->stringTable[$str]);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251342 | Worksheet.writeStringRecord | validation | private function writeStringRecord($stringValue)
{
$record = 0x0207; // Record identifier
$data = StringHelper::UTF8toBIFF8UnicodeLong($stringValue);
$length = strlen($data);
$header = pack('vv', $record, $length);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251343 | Worksheet.writeUrlInternal | validation | public function writeUrlInternal($row1, $col1, $row2, $col2, $url)
{
$record = 0x01B8; // Record identifier
$length = 0x00000; // Bytes to follow
// Strip URL type
$url = preg_replace('/^internal:/', '', $url);
// Pack the undocumented parts of the hyperlink stream
$unknown1 = pack('H*', 'D0C9EA79F9BACE118C8200AA004BA90B02000000');
// Pack the option flags
$options = pack('V', 0x08);
// Convert the URL type and to a null terminated wchar string
$url .= "\0";
// character count
$url_len = StringHelper::countCharacters($url);
$url_len = pack('V', $url_len);
$url = StringHelper::convertEncoding($url, 'UTF-16LE', 'UTF-8');
// Calculate the data length
$length = 0x24 + strlen($url);
// Pack the header data
$header = pack('vv', $record, $length);
$data = pack('vvvv', $row1, $row2, $col1, $col2);
// Write the packed data
$this->append($header . $data . $unknown1 . $options . $url_len . $url);
return 0;
} | php | {
"resource": ""
} |
q251344 | Worksheet.writeDimensions | validation | private function writeDimensions()
{
$record = 0x0200; // Record identifier
$length = 0x000E;
$data = pack('VVvvv', $this->firstRowIndex, $this->lastRowIndex + 1, $this->firstColumnIndex, $this->lastColumnIndex + 1, 0x0000); // reserved
$header = pack('vv', $record, $length);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251345 | Worksheet.writeWindow2 | validation | private function writeWindow2()
{
$record = 0x023E; // Record identifier
$length = 0x0012;
$grbit = 0x00B6; // Option flags
$rwTop = 0x0000; // Top row visible in window
$colLeft = 0x0000; // Leftmost column visible in window
// The options flags that comprise $grbit
$fDspFmla = 0; // 0 - bit
$fDspGrid = $this->phpSheet->getShowGridlines() ? 1 : 0; // 1
$fDspRwCol = $this->phpSheet->getShowRowColHeaders() ? 1 : 0; // 2
$fFrozen = $this->phpSheet->getFreezePane() ? 1 : 0; // 3
$fDspZeros = 1; // 4
$fDefaultHdr = 1; // 5
$fArabic = $this->phpSheet->getRightToLeft() ? 1 : 0; // 6
$fDspGuts = $this->outlineOn; // 7
$fFrozenNoSplit = 0; // 0 - bit
// no support in PhpSpreadsheet for selected sheet, therefore sheet is only selected if it is the active sheet
$fSelected = ($this->phpSheet === $this->phpSheet->getParent()->getActiveSheet()) ? 1 : 0;
$fPaged = 1; // 2
$fPageBreakPreview = $this->phpSheet->getSheetView()->getView() === SheetView::SHEETVIEW_PAGE_BREAK_PREVIEW;
$grbit = $fDspFmla;
$grbit |= $fDspGrid << 1;
$grbit |= $fDspRwCol << 2;
$grbit |= $fFrozen << 3;
$grbit |= $fDspZeros << 4;
$grbit |= $fDefaultHdr << 5;
$grbit |= $fArabic << 6;
$grbit |= $fDspGuts << 7;
$grbit |= $fFrozenNoSplit << 8;
$grbit |= $fSelected << 9;
$grbit |= $fPaged << 10;
$grbit |= $fPageBreakPreview << 11;
$header = pack('vv', $record, $length);
$data = pack('vvv', $grbit, $rwTop, $colLeft);
// FIXME !!!
$rgbHdr = 0x0040; // Row/column heading and gridline color index
$zoom_factor_page_break = ($fPageBreakPreview ? $this->phpSheet->getSheetView()->getZoomScale() : 0x0000);
$zoom_factor_normal = $this->phpSheet->getSheetView()->getZoomScaleNormal();
$data .= pack('vvvvV', $rgbHdr, 0x0000, $zoom_factor_page_break, $zoom_factor_normal, 0x00000000);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251346 | Worksheet.writeDefaultRowHeight | validation | private function writeDefaultRowHeight()
{
$defaultRowHeight = $this->phpSheet->getDefaultRowDimension()->getRowHeight();
if ($defaultRowHeight < 0) {
return;
}
// convert to twips
$defaultRowHeight = (int) 20 * $defaultRowHeight;
$record = 0x0225; // Record identifier
$length = 0x0004; // Number of bytes to follow
$header = pack('vv', $record, $length);
$data = pack('vv', 1, $defaultRowHeight);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251347 | Worksheet.writeDefcol | validation | private function writeDefcol()
{
$defaultColWidth = 8;
$record = 0x0055; // Record identifier
$length = 0x0002; // Number of bytes to follow
$header = pack('vv', $record, $length);
$data = pack('v', $defaultColWidth);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251348 | Worksheet.writeColinfo | validation | private function writeColinfo($col_array)
{
if (isset($col_array[0])) {
$colFirst = $col_array[0];
}
if (isset($col_array[1])) {
$colLast = $col_array[1];
}
if (isset($col_array[2])) {
$coldx = $col_array[2];
} else {
$coldx = 8.43;
}
if (isset($col_array[3])) {
$xfIndex = $col_array[3];
} else {
$xfIndex = 15;
}
if (isset($col_array[4])) {
$grbit = $col_array[4];
} else {
$grbit = 0;
}
if (isset($col_array[5])) {
$level = $col_array[5];
} else {
$level = 0;
}
$record = 0x007D; // Record identifier
$length = 0x000C; // Number of bytes to follow
$coldx *= 256; // Convert to units of 1/256 of a char
$ixfe = $xfIndex;
$reserved = 0x0000; // Reserved
$level = max(0, min($level, 7));
$grbit |= $level << 8;
$header = pack('vv', $record, $length);
$data = pack('vvvvvv', $colFirst, $colLast, $coldx, $ixfe, $grbit, $reserved);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251349 | Worksheet.writeSelection | validation | private function writeSelection()
{
// look up the selected cell range
$selectedCells = Coordinate::splitRange($this->phpSheet->getSelectedCells());
$selectedCells = $selectedCells[0];
if (count($selectedCells) == 2) {
list($first, $last) = $selectedCells;
} else {
$first = $selectedCells[0];
$last = $selectedCells[0];
}
list($colFirst, $rwFirst) = Coordinate::coordinateFromString($first);
$colFirst = Coordinate::columnIndexFromString($colFirst) - 1; // base 0 column index
--$rwFirst; // base 0 row index
list($colLast, $rwLast) = Coordinate::coordinateFromString($last);
$colLast = Coordinate::columnIndexFromString($colLast) - 1; // base 0 column index
--$rwLast; // base 0 row index
// make sure we are not out of bounds
$colFirst = min($colFirst, 255);
$colLast = min($colLast, 255);
$rwFirst = min($rwFirst, 65535);
$rwLast = min($rwLast, 65535);
$record = 0x001D; // Record identifier
$length = 0x000F; // Number of bytes to follow
$pnn = $this->activePane; // Pane position
$rwAct = $rwFirst; // Active row
$colAct = $colFirst; // Active column
$irefAct = 0; // Active cell ref
$cref = 1; // Number of refs
if (!isset($rwLast)) {
$rwLast = $rwFirst; // Last row in reference
}
if (!isset($colLast)) {
$colLast = $colFirst; // Last col in reference
}
// Swap last row/col for first row/col as necessary
if ($rwFirst > $rwLast) {
list($rwFirst, $rwLast) = [$rwLast, $rwFirst];
}
if ($colFirst > $colLast) {
list($colFirst, $colLast) = [$colLast, $colFirst];
}
$header = pack('vv', $record, $length);
$data = pack('CvvvvvvCC', $pnn, $rwAct, $colAct, $irefAct, $cref, $rwFirst, $rwLast, $colFirst, $colLast);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251350 | Worksheet.writeMergedCells | validation | private function writeMergedCells()
{
$mergeCells = $this->phpSheet->getMergeCells();
$countMergeCells = count($mergeCells);
if ($countMergeCells == 0) {
return;
}
// maximum allowed number of merged cells per record
$maxCountMergeCellsPerRecord = 1027;
// record identifier
$record = 0x00E5;
// counter for total number of merged cells treated so far by the writer
$i = 0;
// counter for number of merged cells written in record currently being written
$j = 0;
// initialize record data
$recordData = '';
// loop through the merged cells
foreach ($mergeCells as $mergeCell) {
++$i;
++$j;
// extract the row and column indexes
$range = Coordinate::splitRange($mergeCell);
list($first, $last) = $range[0];
list($firstColumn, $firstRow) = Coordinate::coordinateFromString($first);
list($lastColumn, $lastRow) = Coordinate::coordinateFromString($last);
$recordData .= pack('vvvv', $firstRow - 1, $lastRow - 1, Coordinate::columnIndexFromString($firstColumn) - 1, Coordinate::columnIndexFromString($lastColumn) - 1);
// flush record if we have reached limit for number of merged cells, or reached final merged cell
if ($j == $maxCountMergeCellsPerRecord or $i == $countMergeCells) {
$recordData = pack('v', $j) . $recordData;
$length = strlen($recordData);
$header = pack('vv', $record, $length);
$this->append($header . $recordData);
// initialize for next record, if any
$recordData = '';
$j = 0;
}
}
} | php | {
"resource": ""
} |
q251351 | Worksheet.writeSheetLayout | validation | private function writeSheetLayout()
{
if (!$this->phpSheet->isTabColorSet()) {
return;
}
$recordData = pack(
'vvVVVvv',
0x0862,
0x0000, // unused
0x00000000, // unused
0x00000000, // unused
0x00000014, // size of record data
$this->colors[$this->phpSheet->getTabColor()->getRGB()], // color index
0x0000 // unused
);
$length = strlen($recordData);
$record = 0x0862; // Record identifier
$header = pack('vv', $record, $length);
$this->append($header . $recordData);
} | php | {
"resource": ""
} |
q251352 | Worksheet.writeSheetProtection | validation | private function writeSheetProtection()
{
// record identifier
$record = 0x0867;
// prepare options
$options = (int) !$this->phpSheet->getProtection()->getObjects()
| (int) !$this->phpSheet->getProtection()->getScenarios() << 1
| (int) !$this->phpSheet->getProtection()->getFormatCells() << 2
| (int) !$this->phpSheet->getProtection()->getFormatColumns() << 3
| (int) !$this->phpSheet->getProtection()->getFormatRows() << 4
| (int) !$this->phpSheet->getProtection()->getInsertColumns() << 5
| (int) !$this->phpSheet->getProtection()->getInsertRows() << 6
| (int) !$this->phpSheet->getProtection()->getInsertHyperlinks() << 7
| (int) !$this->phpSheet->getProtection()->getDeleteColumns() << 8
| (int) !$this->phpSheet->getProtection()->getDeleteRows() << 9
| (int) !$this->phpSheet->getProtection()->getSelectLockedCells() << 10
| (int) !$this->phpSheet->getProtection()->getSort() << 11
| (int) !$this->phpSheet->getProtection()->getAutoFilter() << 12
| (int) !$this->phpSheet->getProtection()->getPivotTables() << 13
| (int) !$this->phpSheet->getProtection()->getSelectUnlockedCells() << 14;
// record data
$recordData = pack(
'vVVCVVvv',
0x0867, // repeated record identifier
0x0000, // not used
0x0000, // not used
0x00, // not used
0x01000200, // unknown data
0xFFFFFFFF, // unknown data
$options, // options
0x0000 // not used
);
$length = strlen($recordData);
$header = pack('vv', $record, $length);
$this->append($header . $recordData);
} | php | {
"resource": ""
} |
q251353 | Worksheet.writeRangeProtection | validation | private function writeRangeProtection()
{
foreach ($this->phpSheet->getProtectedCells() as $range => $password) {
// number of ranges, e.g. 'A1:B3 C20:D25'
$cellRanges = explode(' ', $range);
$cref = count($cellRanges);
$recordData = pack(
'vvVVvCVvVv',
0x0868,
0x00,
0x0000,
0x0000,
0x02,
0x0,
0x0000,
$cref,
0x0000,
0x00
);
foreach ($cellRanges as $cellRange) {
$recordData .= $this->writeBIFF8CellRangeAddressFixed($cellRange);
}
// the rgbFeat structure
$recordData .= pack(
'VV',
0x0000,
hexdec($password)
);
$recordData .= StringHelper::UTF8toBIFF8UnicodeLong('p' . md5($recordData));
$length = strlen($recordData);
$record = 0x0868; // Record identifier
$header = pack('vv', $record, $length);
$this->append($header . $recordData);
}
} | php | {
"resource": ""
} |
q251354 | Worksheet.writeSetup | validation | private function writeSetup()
{
$record = 0x00A1; // Record identifier
$length = 0x0022; // Number of bytes to follow
$iPaperSize = $this->phpSheet->getPageSetup()->getPaperSize(); // Paper size
$iScale = $this->phpSheet->getPageSetup()->getScale() ?
$this->phpSheet->getPageSetup()->getScale() : 100; // Print scaling factor
$iPageStart = 0x01; // Starting page number
$iFitWidth = (int) $this->phpSheet->getPageSetup()->getFitToWidth(); // Fit to number of pages wide
$iFitHeight = (int) $this->phpSheet->getPageSetup()->getFitToHeight(); // Fit to number of pages high
$grbit = 0x00; // Option flags
$iRes = 0x0258; // Print resolution
$iVRes = 0x0258; // Vertical print resolution
$numHdr = $this->phpSheet->getPageMargins()->getHeader(); // Header Margin
$numFtr = $this->phpSheet->getPageMargins()->getFooter(); // Footer Margin
$iCopies = 0x01; // Number of copies
$fLeftToRight = 0x0; // Print over then down
// Page orientation
$fLandscape = ($this->phpSheet->getPageSetup()->getOrientation() == PageSetup::ORIENTATION_LANDSCAPE) ?
0x0 : 0x1;
$fNoPls = 0x0; // Setup not read from printer
$fNoColor = 0x0; // Print black and white
$fDraft = 0x0; // Print draft quality
$fNotes = 0x0; // Print notes
$fNoOrient = 0x0; // Orientation not set
$fUsePage = 0x0; // Use custom starting page
$grbit = $fLeftToRight;
$grbit |= $fLandscape << 1;
$grbit |= $fNoPls << 2;
$grbit |= $fNoColor << 3;
$grbit |= $fDraft << 4;
$grbit |= $fNotes << 5;
$grbit |= $fNoOrient << 6;
$grbit |= $fUsePage << 7;
$numHdr = pack('d', $numHdr);
$numFtr = pack('d', $numFtr);
if (self::getByteOrder()) { // if it's Big Endian
$numHdr = strrev($numHdr);
$numFtr = strrev($numFtr);
}
$header = pack('vv', $record, $length);
$data1 = pack('vvvvvvvv', $iPaperSize, $iScale, $iPageStart, $iFitWidth, $iFitHeight, $grbit, $iRes, $iVRes);
$data2 = $numHdr . $numFtr;
$data3 = pack('v', $iCopies);
$this->append($header . $data1 . $data2 . $data3);
} | php | {
"resource": ""
} |
q251355 | Worksheet.writeHeader | validation | private function writeHeader()
{
$record = 0x0014; // Record identifier
/* removing for now
// need to fix character count (multibyte!)
if (strlen($this->phpSheet->getHeaderFooter()->getOddHeader()) <= 255) {
$str = $this->phpSheet->getHeaderFooter()->getOddHeader(); // header string
} else {
$str = '';
}
*/
$recordData = StringHelper::UTF8toBIFF8UnicodeLong($this->phpSheet->getHeaderFooter()->getOddHeader());
$length = strlen($recordData);
$header = pack('vv', $record, $length);
$this->append($header . $recordData);
} | php | {
"resource": ""
} |
q251356 | Worksheet.writeFooter | validation | 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 = StringHelper::UTF8toBIFF8UnicodeLong($this->phpSheet->getHeaderFooter()->getOddFooter());
$length = strlen($recordData);
$header = pack('vv', $record, $length);
$this->append($header . $recordData);
} | php | {
"resource": ""
} |
q251357 | Worksheet.writeHcenter | validation | private function writeHcenter()
{
$record = 0x0083; // Record identifier
$length = 0x0002; // Bytes to follow
$fHCenter = $this->phpSheet->getPageSetup()->getHorizontalCentered() ? 1 : 0; // Horizontal centering
$header = pack('vv', $record, $length);
$data = pack('v', $fHCenter);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251358 | Worksheet.writeVcenter | validation | private function writeVcenter()
{
$record = 0x0084; // Record identifier
$length = 0x0002; // Bytes to follow
$fVCenter = $this->phpSheet->getPageSetup()->getVerticalCentered() ? 1 : 0; // Horizontal centering
$header = pack('vv', $record, $length);
$data = pack('v', $fVCenter);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251359 | Worksheet.writeMarginLeft | validation | private function writeMarginLeft()
{
$record = 0x0026; // Record identifier
$length = 0x0008; // Bytes to follow
$margin = $this->phpSheet->getPageMargins()->getLeft(); // Margin in inches
$header = pack('vv', $record, $length);
$data = pack('d', $margin);
if (self::getByteOrder()) { // if it's Big Endian
$data = strrev($data);
}
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251360 | Worksheet.writeMarginRight | validation | private function writeMarginRight()
{
$record = 0x0027; // Record identifier
$length = 0x0008; // Bytes to follow
$margin = $this->phpSheet->getPageMargins()->getRight(); // Margin in inches
$header = pack('vv', $record, $length);
$data = pack('d', $margin);
if (self::getByteOrder()) { // if it's Big Endian
$data = strrev($data);
}
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251361 | Worksheet.writeMarginTop | validation | private function writeMarginTop()
{
$record = 0x0028; // Record identifier
$length = 0x0008; // Bytes to follow
$margin = $this->phpSheet->getPageMargins()->getTop(); // Margin in inches
$header = pack('vv', $record, $length);
$data = pack('d', $margin);
if (self::getByteOrder()) { // if it's Big Endian
$data = strrev($data);
}
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251362 | Worksheet.writeMarginBottom | validation | private function writeMarginBottom()
{
$record = 0x0029; // Record identifier
$length = 0x0008; // Bytes to follow
$margin = $this->phpSheet->getPageMargins()->getBottom(); // Margin in inches
$header = pack('vv', $record, $length);
$data = pack('d', $margin);
if (self::getByteOrder()) { // if it's Big Endian
$data = strrev($data);
}
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251363 | Worksheet.writePrintHeaders | validation | private function writePrintHeaders()
{
$record = 0x002a; // Record identifier
$length = 0x0002; // Bytes to follow
$fPrintRwCol = $this->printHeaders; // Boolean flag
$header = pack('vv', $record, $length);
$data = pack('v', $fPrintRwCol);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251364 | Worksheet.writePrintGridlines | validation | private function writePrintGridlines()
{
$record = 0x002b; // Record identifier
$length = 0x0002; // Bytes to follow
$fPrintGrid = $this->phpSheet->getPrintGridlines() ? 1 : 0; // Boolean flag
$header = pack('vv', $record, $length);
$data = pack('v', $fPrintGrid);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251365 | Worksheet.writeGridset | validation | private function writeGridset()
{
$record = 0x0082; // Record identifier
$length = 0x0002; // Bytes to follow
$fGridSet = !$this->phpSheet->getPrintGridlines(); // Boolean flag
$header = pack('vv', $record, $length);
$data = pack('v', $fGridSet);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251366 | Worksheet.writeAutoFilterInfo | validation | private function writeAutoFilterInfo()
{
$record = 0x009D; // Record identifier
$length = 0x0002; // Bytes to follow
$rangeBounds = Coordinate::rangeBoundaries($this->phpSheet->getAutoFilter()->getRange());
$iNumFilters = 1 + $rangeBounds[1][0] - $rangeBounds[0][0];
$header = pack('vv', $record, $length);
$data = pack('v', $iNumFilters);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251367 | Worksheet.writeGuts | validation | 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->columnInfo);
for ($i = 0; $i < $colcount; ++$i) {
$col_level = max($this->columnInfo[$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);
} | php | {
"resource": ""
} |
q251368 | Worksheet.writeWsbool | validation | private function writeWsbool()
{
$record = 0x0081; // Record identifier
$length = 0x0002; // Bytes to follow
$grbit = 0x0000;
// The only option that is of interest is the flag for fit to page. So we
// set all the options in one go.
//
// Set the option flags
$grbit |= 0x0001; // Auto page breaks visible
if ($this->outlineStyle) {
$grbit |= 0x0020; // Auto outline styles
}
if ($this->phpSheet->getShowSummaryBelow()) {
$grbit |= 0x0040; // Outline summary below
}
if ($this->phpSheet->getShowSummaryRight()) {
$grbit |= 0x0080; // Outline summary right
}
if ($this->phpSheet->getPageSetup()->getFitToPage()) {
$grbit |= 0x0100; // Page setup fit to page
}
if ($this->outlineOn) {
$grbit |= 0x0400; // Outline symbols displayed
}
$header = pack('vv', $record, $length);
$data = pack('v', $grbit);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251369 | Worksheet.writeBreaks | validation | private function writeBreaks()
{
// initialize
$vbreaks = [];
$hbreaks = [];
foreach ($this->phpSheet->getBreaks() as $cell => $breakType) {
// Fetch coordinates
$coordinates = Coordinate::coordinateFromString($cell);
// Decide what to do by the type of break
switch ($breakType) {
case \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::BREAK_COLUMN:
// Add to list of vertical breaks
$vbreaks[] = Coordinate::columnIndexFromString($coordinates[0]) - 1;
break;
case \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::BREAK_ROW:
// Add to list of horizontal breaks
$hbreaks[] = $coordinates[1];
break;
case \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet::BREAK_NONE:
default:
// Nothing to do
break;
}
}
//horizontal page breaks
if (!empty($hbreaks)) {
// Sort and filter array of page breaks
sort($hbreaks, SORT_NUMERIC);
if ($hbreaks[0] == 0) { // don't use first break if it's 0
array_shift($hbreaks);
}
$record = 0x001b; // Record identifier
$cbrk = count($hbreaks); // Number of page breaks
$length = 2 + 6 * $cbrk; // Bytes to follow
$header = pack('vv', $record, $length);
$data = pack('v', $cbrk);
// Append each page break
foreach ($hbreaks as $hbreak) {
$data .= pack('vvv', $hbreak, 0x0000, 0x00ff);
}
$this->append($header . $data);
}
// vertical page breaks
if (!empty($vbreaks)) {
// 1000 vertical pagebreaks appears to be an internal Excel 5 limit.
// It is slightly higher in Excel 97/200, approx. 1026
$vbreaks = array_slice($vbreaks, 0, 1000);
// Sort and filter array of page breaks
sort($vbreaks, SORT_NUMERIC);
if ($vbreaks[0] == 0) { // don't use first break if it's 0
array_shift($vbreaks);
}
$record = 0x001a; // Record identifier
$cbrk = count($vbreaks); // Number of page breaks
$length = 2 + 6 * $cbrk; // Bytes to follow
$header = pack('vv', $record, $length);
$data = pack('v', $cbrk);
// Append each page break
foreach ($vbreaks as $vbreak) {
$data .= pack('vvv', $vbreak, 0x0000, 0xffff);
}
$this->append($header . $data);
}
} | php | {
"resource": ""
} |
q251370 | Worksheet.writeProtect | validation | 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);
} | php | {
"resource": ""
} |
q251371 | Worksheet.writeScenProtect | validation | private function writeScenProtect()
{
// Exit if sheet protection is not active
if (!$this->phpSheet->getProtection()->getSheet()) {
return;
}
// Exit if scenarios are not protected
if (!$this->phpSheet->getProtection()->getScenarios()) {
return;
}
$record = 0x00DD; // Record identifier
$length = 0x0002; // Bytes to follow
$header = pack('vv', $record, $length);
$data = pack('v', 1);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251372 | Worksheet.writeObjectProtect | validation | private function writeObjectProtect()
{
// Exit if sheet protection is not active
if (!$this->phpSheet->getProtection()->getSheet()) {
return;
}
// Exit if objects are not protected
if (!$this->phpSheet->getProtection()->getObjects()) {
return;
}
$record = 0x0063; // Record identifier
$length = 0x0002; // Bytes to follow
$header = pack('vv', $record, $length);
$data = pack('v', 1);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251373 | Worksheet.writePassword | validation | private function writePassword()
{
// Exit unless sheet protection and password have been specified
if (!$this->phpSheet->getProtection()->getSheet() || !$this->phpSheet->getProtection()->getPassword()) {
return;
}
$record = 0x0013; // Record identifier
$length = 0x0002; // Bytes to follow
$wPassword = hexdec($this->phpSheet->getProtection()->getPassword()); // Encoded password
$header = pack('vv', $record, $length);
$data = pack('v', $wPassword);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251374 | Worksheet.insertBitmap | validation | public function insertBitmap($row, $col, $bitmap, $x = 0, $y = 0, $scale_x = 1, $scale_y = 1)
{
$bitmap_array = (is_resource($bitmap) ? $this->processBitmapGd($bitmap) : $this->processBitmap($bitmap));
list($width, $height, $size, $data) = $bitmap_array;
// Scale the frame of the image.
$width *= $scale_x;
$height *= $scale_y;
// Calculate the vertices of the image and write the OBJ record
$this->positionImage($col, $row, $x, $y, $width, $height);
// Write the IMDATA record to store the bitmap data
$record = 0x007f;
$length = 8 + $size;
$cf = 0x09;
$env = 0x01;
$lcb = $size;
$header = pack('vvvvV', $record, $length, $cf, $env, $lcb);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251375 | Worksheet.positionImage | validation | public function positionImage($col_start, $row_start, $x1, $y1, $width, $height)
{
// Initialise end cell to the same as the start cell
$col_end = $col_start; // Col containing lower right corner of object
$row_end = $row_start; // Row containing bottom right corner of object
// Zero the specified offset if greater than the cell dimensions
if ($x1 >= Xls::sizeCol($this->phpSheet, Coordinate::stringFromColumnIndex($col_start + 1))) {
$x1 = 0;
}
if ($y1 >= Xls::sizeRow($this->phpSheet, $row_start + 1)) {
$y1 = 0;
}
$width = $width + $x1 - 1;
$height = $height + $y1 - 1;
// Subtract the underlying cell widths to find the end cell of the image
while ($width >= Xls::sizeCol($this->phpSheet, Coordinate::stringFromColumnIndex($col_end + 1))) {
$width -= Xls::sizeCol($this->phpSheet, Coordinate::stringFromColumnIndex($col_end + 1));
++$col_end;
}
// Subtract the underlying cell heights to find the end cell of the image
while ($height >= Xls::sizeRow($this->phpSheet, $row_end + 1)) {
$height -= Xls::sizeRow($this->phpSheet, $row_end + 1);
++$row_end;
}
// Bitmap isn't allowed to start or finish in a hidden cell, i.e. a cell
// with zero eight or width.
//
if (Xls::sizeCol($this->phpSheet, Coordinate::stringFromColumnIndex($col_start + 1)) == 0) {
return;
}
if (Xls::sizeCol($this->phpSheet, Coordinate::stringFromColumnIndex($col_end + 1)) == 0) {
return;
}
if (Xls::sizeRow($this->phpSheet, $row_start + 1) == 0) {
return;
}
if (Xls::sizeRow($this->phpSheet, $row_end + 1) == 0) {
return;
}
// Convert the pixel values to the percentage value expected by Excel
$x1 = $x1 / Xls::sizeCol($this->phpSheet, Coordinate::stringFromColumnIndex($col_start + 1)) * 1024;
$y1 = $y1 / Xls::sizeRow($this->phpSheet, $row_start + 1) * 256;
$x2 = $width / Xls::sizeCol($this->phpSheet, Coordinate::stringFromColumnIndex($col_end + 1)) * 1024; // Distance to right side of object
$y2 = $height / Xls::sizeRow($this->phpSheet, $row_end + 1) * 256; // Distance to bottom of object
$this->writeObjPicture($col_start, $x1, $row_start, $y1, $col_end, $x2, $row_end, $y2);
} | php | {
"resource": ""
} |
q251376 | Worksheet.processBitmapGd | validation | public function processBitmapGd($image)
{
$width = imagesx($image);
$height = imagesy($image);
$data = pack('Vvvvv', 0x000c, $width, $height, 0x01, 0x18);
for ($j = $height; --$j;) {
for ($i = 0; $i < $width; ++$i) {
$color = imagecolorsforindex($image, imagecolorat($image, $i, $j));
foreach (['red', 'green', 'blue'] as $key) {
$color[$key] = $color[$key] + round((255 - $color[$key]) * $color['alpha'] / 127);
}
$data .= chr($color['blue']) . chr($color['green']) . chr($color['red']);
}
if (3 * $width % 4) {
$data .= str_repeat("\x00", 4 - 3 * $width % 4);
}
}
return [$width, $height, strlen($data), $data];
} | php | {
"resource": ""
} |
q251377 | Worksheet.writeZoom | validation | 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);
} | php | {
"resource": ""
} |
q251378 | Worksheet.writeMsoDrawing | validation | private function writeMsoDrawing()
{
// write the Escher stream if necessary
if (isset($this->escher)) {
$writer = new Escher($this->escher);
$data = $writer->close();
$spOffsets = $writer->getSpOffsets();
$spTypes = $writer->getSpTypes();
// write the neccesary MSODRAWING, OBJ records
// split the Escher stream
$spOffsets[0] = 0;
$nm = count($spOffsets) - 1; // number of shapes excluding first shape
for ($i = 1; $i <= $nm; ++$i) {
// MSODRAWING record
$record = 0x00EC; // Record identifier
// chunk of Escher stream for one shape
$dataChunk = substr($data, $spOffsets[$i - 1], $spOffsets[$i] - $spOffsets[$i - 1]);
$length = strlen($dataChunk);
$header = pack('vv', $record, $length);
$this->append($header . $dataChunk);
// OBJ record
$record = 0x005D; // record identifier
$objData = '';
// ftCmo
if ($spTypes[$i] == 0x00C9) {
// Add ftCmo (common object data) subobject
$objData .=
pack(
'vvvvvVVV',
0x0015, // 0x0015 = ftCmo
0x0012, // length of ftCmo data
0x0014, // object type, 0x0014 = filter
$i, // object id number, Excel seems to use 1-based index, local for the sheet
0x2101, // option flags, 0x2001 is what OpenOffice.org uses
0, // reserved
0, // reserved
0 // reserved
);
// Add ftSbs Scroll bar subobject
$objData .= pack('vv', 0x00C, 0x0014);
$objData .= pack('H*', '0000000000000000640001000A00000010000100');
// Add ftLbsData (List box data) subobject
$objData .= pack('vv', 0x0013, 0x1FEE);
$objData .= pack('H*', '00000000010001030000020008005700');
} else {
// Add ftCmo (common object data) subobject
$objData .=
pack(
'vvvvvVVV',
0x0015, // 0x0015 = ftCmo
0x0012, // length of ftCmo data
0x0008, // object type, 0x0008 = picture
$i, // object id number, Excel seems to use 1-based index, local for the sheet
0x6011, // option flags, 0x6011 is what OpenOffice.org uses
0, // reserved
0, // reserved
0 // reserved
);
}
// ftEnd
$objData .=
pack(
'vv',
0x0000, // 0x0000 = ftEnd
0x0000 // length of ftEnd data
);
$length = strlen($objData);
$header = pack('vv', $record, $length);
$this->append($header . $objData);
}
}
} | php | {
"resource": ""
} |
q251379 | Worksheet.writePageLayoutView | validation | private function writePageLayoutView()
{
$record = 0x088B; // Record identifier
$length = 0x0010; // Bytes to follow
$rt = 0x088B; // 2
$grbitFrt = 0x0000; // 2
$reserved = 0x0000000000000000; // 8
$wScalvePLV = $this->phpSheet->getSheetView()->getZoomScale(); // 2
// The options flags that comprise $grbit
if ($this->phpSheet->getSheetView()->getView() == SheetView::SHEETVIEW_PAGE_LAYOUT) {
$fPageLayoutView = 1;
} else {
$fPageLayoutView = 0;
}
$fRulerVisible = 0;
$fWhitespaceHidden = 0;
$grbit = $fPageLayoutView; // 2
$grbit |= $fRulerVisible << 1;
$grbit |= $fWhitespaceHidden << 3;
$header = pack('vv', $record, $length);
$data = pack('vvVVvv', $rt, $grbitFrt, 0x00000000, 0x00000000, $wScalvePLV, $grbit);
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251380 | Worksheet.writeCFHeader | validation | private function writeCFHeader()
{
$record = 0x01B0; // Record identifier
$length = 0x0016; // Bytes to follow
$numColumnMin = null;
$numColumnMax = null;
$numRowMin = null;
$numRowMax = null;
$arrConditional = [];
foreach ($this->phpSheet->getConditionalStylesCollection() as $cellCoordinate => $conditionalStyles) {
foreach ($conditionalStyles as $conditional) {
if ($conditional->getConditionType() == Conditional::CONDITION_EXPRESSION
|| $conditional->getConditionType() == Conditional::CONDITION_CELLIS) {
if (!in_array($conditional->getHashCode(), $arrConditional)) {
$arrConditional[] = $conditional->getHashCode();
}
// Cells
$arrCoord = Coordinate::coordinateFromString($cellCoordinate);
if (!is_numeric($arrCoord[0])) {
$arrCoord[0] = Coordinate::columnIndexFromString($arrCoord[0]);
}
if ($numColumnMin === null || ($numColumnMin > $arrCoord[0])) {
$numColumnMin = $arrCoord[0];
}
if ($numColumnMax === null || ($numColumnMax < $arrCoord[0])) {
$numColumnMax = $arrCoord[0];
}
if ($numRowMin === null || ($numRowMin > $arrCoord[1])) {
$numRowMin = $arrCoord[1];
}
if ($numRowMax === null || ($numRowMax < $arrCoord[1])) {
$numRowMax = $arrCoord[1];
}
}
}
}
$needRedraw = 1;
$cellRange = pack('vvvv', $numRowMin - 1, $numRowMax - 1, $numColumnMin - 1, $numColumnMax - 1);
$header = pack('vv', $record, $length);
$data = pack('vv', count($arrConditional), $needRedraw);
$data .= $cellRange;
$data .= pack('v', 0x0001);
$data .= $cellRange;
$this->append($header . $data);
} | php | {
"resource": ""
} |
q251381 | Xls.readRecordData | validation | private function readRecordData($data, $pos, $len)
{
$data = substr($data, $pos, $len);
// File not encrypted, or record before encryption start point
if ($this->encryption == self::MS_BIFF_CRYPTO_NONE || $pos < $this->encryptionStartPos) {
return $data;
}
$recordData = '';
if ($this->encryption == self::MS_BIFF_CRYPTO_RC4) {
$oldBlock = floor($this->rc4Pos / self::REKEY_BLOCK);
$block = floor($pos / self::REKEY_BLOCK);
$endBlock = floor(($pos + $len) / self::REKEY_BLOCK);
// Spin an RC4 decryptor to the right spot. If we have a decryptor sitting
// at a point earlier in the current block, re-use it as we can save some time.
if ($block != $oldBlock || $pos < $this->rc4Pos || !$this->rc4Key) {
$this->rc4Key = $this->makeKey($block, $this->md5Ctxt);
$step = $pos % self::REKEY_BLOCK;
} else {
$step = $pos - $this->rc4Pos;
}
$this->rc4Key->RC4(str_repeat("\0", $step));
// Decrypt record data (re-keying at the end of every block)
while ($block != $endBlock) {
$step = self::REKEY_BLOCK - ($pos % self::REKEY_BLOCK);
$recordData .= $this->rc4Key->RC4(substr($data, 0, $step));
$data = substr($data, $step);
$pos += $step;
$len -= $step;
++$block;
$this->rc4Key = $this->makeKey($block, $this->md5Ctxt);
}
$recordData .= $this->rc4Key->RC4(substr($data, 0, $len));
// Keep track of the position of this decryptor.
// We'll try and re-use it later if we can to speed things up
$this->rc4Pos = $pos + $len;
} elseif ($this->encryption == self::MS_BIFF_CRYPTO_XOR) {
throw new Exception('XOr encryption not supported');
}
return $recordData;
} | php | {
"resource": ""
} |
q251382 | Xls.loadOLE | validation | private function loadOLE($pFilename)
{
// OLE reader
$ole = new OLERead();
// get excel data,
$ole->read($pFilename);
// Get workbook data: workbook stream + sheet streams
$this->data = $ole->getStream($ole->wrkbook);
// Get summary information data
$this->summaryInformation = $ole->getStream($ole->summaryInformation);
// Get additional document summary information data
$this->documentSummaryInformation = $ole->getStream($ole->documentSummaryInformation);
} | php | {
"resource": ""
} |
q251383 | Xls.readDefault | validation | private function readDefault()
{
$length = self::getUInt2d($this->data, $this->pos + 2);
// move stream pointer to next record
$this->pos += 4 + $length;
} | php | {
"resource": ""
} |
q251384 | Xls.readTextObject | validation | private function readTextObject()
{
$length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
// move stream pointer to next record
$this->pos += 4 + $length;
if ($this->readDataOnly) {
return;
}
// recordData consists of an array of subrecords looking like this:
// grbit: 2 bytes; Option Flags
// rot: 2 bytes; rotation
// cchText: 2 bytes; length of the text (in the first continue record)
// cbRuns: 2 bytes; length of the formatting (in the second continue record)
// followed by the continuation records containing the actual text and formatting
$grbitOpts = self::getUInt2d($recordData, 0);
$rot = self::getUInt2d($recordData, 2);
$cchText = self::getUInt2d($recordData, 10);
$cbRuns = self::getUInt2d($recordData, 12);
$text = $this->getSplicedRecordData();
$textByte = $text['spliceOffsets'][1] - $text['spliceOffsets'][0] - 1;
$textStr = substr($text['recordData'], $text['spliceOffsets'][0] + 1, $textByte);
// get 1 byte
$is16Bit = ord($text['recordData'][0]);
// it is possible to use a compressed format,
// which omits the high bytes of all characters, if they are all zero
if (($is16Bit & 0x01) === 0) {
$textStr = StringHelper::ConvertEncoding($textStr, 'UTF-8', 'ISO-8859-1');
} else {
$textStr = $this->decodeCodepage($textStr);
}
$this->textObjects[$this->textObjRef] = [
'text' => $textStr,
'format' => substr($text['recordData'], $text['spliceOffsets'][1], $cbRuns),
'alignment' => $grbitOpts,
'rotation' => $rot,
];
} | php | {
"resource": ""
} |
q251385 | Xls.readBof | validation | private function readBof()
{
$length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = substr($this->data, $this->pos + 4, $length);
// move stream pointer to next record
$this->pos += 4 + $length;
// offset: 2; size: 2; type of the following data
$substreamType = self::getUInt2d($recordData, 2);
switch ($substreamType) {
case self::XLS_WORKBOOKGLOBALS:
$version = self::getUInt2d($recordData, 0);
if (($version != self::XLS_BIFF8) && ($version != self::XLS_BIFF7)) {
throw new Exception('Cannot read this Excel file. Version is too old.');
}
$this->version = $version;
break;
case self::XLS_WORKSHEET:
// do not use this version information for anything
// it is unreliable (OpenOffice doc, 5.8), use only version information from the global stream
break;
default:
// substream, e.g. chart
// just skip the entire substream
do {
$code = self::getUInt2d($this->data, $this->pos);
$this->readDefault();
} while ($code != self::XLS_TYPE_EOF && $this->pos < $this->dataSize);
break;
}
} | php | {
"resource": ""
} |
q251386 | Xls.makeKey | validation | private function makeKey($block, $valContext)
{
$pwarray = str_repeat("\0", 64);
for ($i = 0; $i < 5; ++$i) {
$pwarray[$i] = $valContext[$i];
}
$pwarray[5] = chr($block & 0xff);
$pwarray[6] = chr(($block >> 8) & 0xff);
$pwarray[7] = chr(($block >> 16) & 0xff);
$pwarray[8] = chr(($block >> 24) & 0xff);
$pwarray[9] = "\x80";
$pwarray[56] = "\x48";
$md5 = new Xls\MD5();
$md5->add($pwarray);
$s = $md5->getContext();
return new Xls\RC4($s);
} | php | {
"resource": ""
} |
q251387 | Xls.readStyle | validation | private function readStyle()
{
$length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
// move stream pointer to next record
$this->pos += 4 + $length;
if (!$this->readDataOnly) {
// offset: 0; size: 2; index to XF record and flag for built-in style
$ixfe = self::getUInt2d($recordData, 0);
// bit: 11-0; mask 0x0FFF; index to XF record
$xfIndex = (0x0FFF & $ixfe) >> 0;
// bit: 15; mask 0x8000; 0 = user-defined style, 1 = built-in style
$isBuiltIn = (bool) ((0x8000 & $ixfe) >> 15);
if ($isBuiltIn) {
// offset: 2; size: 1; identifier for built-in style
$builtInId = ord($recordData[2]);
switch ($builtInId) {
case 0x00:
// currently, we are not using this for anything
break;
default:
break;
}
}
// user-defined; not supported by PhpSpreadsheet
}
} | php | {
"resource": ""
} |
q251388 | Xls.readPalette | validation | private function readPalette()
{
$length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
// move stream pointer to next record
$this->pos += 4 + $length;
if (!$this->readDataOnly) {
// offset: 0; size: 2; number of following colors
$nm = self::getUInt2d($recordData, 0);
// list of RGB colors
for ($i = 0; $i < $nm; ++$i) {
$rgb = substr($recordData, 2 + 4 * $i, 4);
$this->palette[] = self::readRGB($rgb);
}
}
} | php | {
"resource": ""
} |
q251389 | Xls.readMsoDrawingGroup | validation | private function readMsoDrawingGroup()
{
$length = self::getUInt2d($this->data, $this->pos + 2);
// get spliced record data
$splicedRecordData = $this->getSplicedRecordData();
$recordData = $splicedRecordData['recordData'];
$this->drawingGroupData .= $recordData;
} | php | {
"resource": ""
} |
q251390 | Xls.readPrintGridlines | validation | private function readPrintGridlines()
{
$length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
// move stream pointer to next record
$this->pos += 4 + $length;
if ($this->version == self::XLS_BIFF8 && !$this->readDataOnly) {
// offset: 0; size: 2; 0 = do not print sheet grid lines; 1 = print sheet gridlines
$printGridlines = (bool) self::getUInt2d($recordData, 0);
$this->phpSheet->setPrintGridlines($printGridlines);
}
} | php | {
"resource": ""
} |
q251391 | Xls.readHeader | validation | private function readHeader()
{
$length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
// move stream pointer to next record
$this->pos += 4 + $length;
if (!$this->readDataOnly) {
// offset: 0; size: var
// realized that $recordData can be empty even when record exists
if ($recordData) {
if ($this->version == self::XLS_BIFF8) {
$string = self::readUnicodeStringLong($recordData);
} else {
$string = $this->readByteStringShort($recordData);
}
$this->phpSheet->getHeaderFooter()->setOddHeader($string['value']);
$this->phpSheet->getHeaderFooter()->setEvenHeader($string['value']);
}
}
} | php | {
"resource": ""
} |
q251392 | Xls.readFooter | validation | private function readFooter()
{
$length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
// move stream pointer to next record
$this->pos += 4 + $length;
if (!$this->readDataOnly) {
// offset: 0; size: var
// realized that $recordData can be empty even when record exists
if ($recordData) {
if ($this->version == self::XLS_BIFF8) {
$string = self::readUnicodeStringLong($recordData);
} else {
$string = $this->readByteStringShort($recordData);
}
$this->phpSheet->getHeaderFooter()->setOddFooter($string['value']);
$this->phpSheet->getHeaderFooter()->setEvenFooter($string['value']);
}
}
} | php | {
"resource": ""
} |
q251393 | Xls.readHcenter | validation | private function readHcenter()
{
$length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
// move stream pointer to next record
$this->pos += 4 + $length;
if (!$this->readDataOnly) {
// offset: 0; size: 2; 0 = print sheet left aligned, 1 = print sheet centered horizontally
$isHorizontalCentered = (bool) self::getUInt2d($recordData, 0);
$this->phpSheet->getPageSetup()->setHorizontalCentered($isHorizontalCentered);
}
} | php | {
"resource": ""
} |
q251394 | Xls.readVcenter | validation | private function readVcenter()
{
$length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
// move stream pointer to next record
$this->pos += 4 + $length;
if (!$this->readDataOnly) {
// offset: 0; size: 2; 0 = print sheet aligned at top page border, 1 = print sheet vertically centered
$isVerticalCentered = (bool) self::getUInt2d($recordData, 0);
$this->phpSheet->getPageSetup()->setVerticalCentered($isVerticalCentered);
}
} | php | {
"resource": ""
} |
q251395 | Xls.readPageSetup | validation | private function readPageSetup()
{
$length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
// move stream pointer to next record
$this->pos += 4 + $length;
if (!$this->readDataOnly) {
// offset: 0; size: 2; paper size
$paperSize = self::getUInt2d($recordData, 0);
// offset: 2; size: 2; scaling factor
$scale = self::getUInt2d($recordData, 2);
// offset: 6; size: 2; fit worksheet width to this number of pages, 0 = use as many as needed
$fitToWidth = self::getUInt2d($recordData, 6);
// offset: 8; size: 2; fit worksheet height to this number of pages, 0 = use as many as needed
$fitToHeight = self::getUInt2d($recordData, 8);
// offset: 10; size: 2; option flags
// bit: 1; mask: 0x0002; 0=landscape, 1=portrait
$isPortrait = (0x0002 & self::getUInt2d($recordData, 10)) >> 1;
// bit: 2; mask: 0x0004; 1= paper size, scaling factor, paper orient. not init
// when this bit is set, do not use flags for those properties
$isNotInit = (0x0004 & self::getUInt2d($recordData, 10)) >> 2;
if (!$isNotInit) {
$this->phpSheet->getPageSetup()->setPaperSize($paperSize);
switch ($isPortrait) {
case 0:
$this->phpSheet->getPageSetup()->setOrientation(PageSetup::ORIENTATION_LANDSCAPE);
break;
case 1:
$this->phpSheet->getPageSetup()->setOrientation(PageSetup::ORIENTATION_PORTRAIT);
break;
}
$this->phpSheet->getPageSetup()->setScale($scale, false);
$this->phpSheet->getPageSetup()->setFitToPage((bool) $this->isFitToPages);
$this->phpSheet->getPageSetup()->setFitToWidth($fitToWidth, false);
$this->phpSheet->getPageSetup()->setFitToHeight($fitToHeight, false);
}
// offset: 16; size: 8; header margin (IEEE 754 floating-point value)
$marginHeader = self::extractNumber(substr($recordData, 16, 8));
$this->phpSheet->getPageMargins()->setHeader($marginHeader);
// offset: 24; size: 8; footer margin (IEEE 754 floating-point value)
$marginFooter = self::extractNumber(substr($recordData, 24, 8));
$this->phpSheet->getPageMargins()->setFooter($marginFooter);
}
} | php | {
"resource": ""
} |
q251396 | Xls.readMulRk | validation | private function readMulRk()
{
$length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
// move stream pointer to next record
$this->pos += 4 + $length;
// offset: 0; size: 2; index to row
$row = self::getUInt2d($recordData, 0);
// offset: 2; size: 2; index to first column
$colFirst = self::getUInt2d($recordData, 2);
// offset: var; size: 2; index to last column
$colLast = self::getUInt2d($recordData, $length - 2);
$columns = $colLast - $colFirst + 1;
// offset within record data
$offset = 4;
for ($i = 1; $i <= $columns; ++$i) {
$columnString = Coordinate::stringFromColumnIndex($colFirst + $i);
// Read cell?
if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) {
// offset: var; size: 2; index to XF record
$xfIndex = self::getUInt2d($recordData, $offset);
// offset: var; size: 4; RK value
$numValue = self::getIEEE754(self::getInt4d($recordData, $offset + 2));
$cell = $this->phpSheet->getCell($columnString . ($row + 1));
if (!$this->readDataOnly) {
// add style
$cell->setXfIndex($this->mapCellXfIndex[$xfIndex]);
}
// add cell value
$cell->setValueExplicit($numValue, DataType::TYPE_NUMERIC);
}
$offset += 6;
}
} | php | {
"resource": ""
} |
q251397 | Xls.readSharedFmla | validation | private function readSharedFmla()
{
$length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
// move stream pointer to next record
$this->pos += 4 + $length;
// offset: 0, size: 6; cell range address of the area used by the shared formula, not used for anything
$cellRange = substr($recordData, 0, 6);
$cellRange = $this->readBIFF5CellRangeAddressFixed($cellRange); // note: even BIFF8 uses BIFF5 syntax
// offset: 6, size: 1; not used
// offset: 7, size: 1; number of existing FORMULA records for this shared formula
$no = ord($recordData[7]);
// offset: 8, size: var; Binary token array of the shared formula
$formula = substr($recordData, 8);
// at this point we only store the shared formula for later use
$this->sharedFormulas[$this->baseCell] = $formula;
} | php | {
"resource": ""
} |
q251398 | Xls.readBoolErr | validation | private function readBoolErr()
{
$length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
// move stream pointer to next record
$this->pos += 4 + $length;
// offset: 0; size: 2; row index
$row = self::getUInt2d($recordData, 0);
// offset: 2; size: 2; column index
$column = self::getUInt2d($recordData, 2);
$columnString = Coordinate::stringFromColumnIndex($column + 1);
// Read cell?
if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) {
// offset: 4; size: 2; index to XF record
$xfIndex = self::getUInt2d($recordData, 4);
// offset: 6; size: 1; the boolean value or error value
$boolErr = ord($recordData[6]);
// offset: 7; size: 1; 0=boolean; 1=error
$isError = ord($recordData[7]);
$cell = $this->phpSheet->getCell($columnString . ($row + 1));
switch ($isError) {
case 0: // boolean
$value = (bool) $boolErr;
// add cell value
$cell->setValueExplicit($value, DataType::TYPE_BOOL);
break;
case 1: // error type
$value = Xls\ErrorCode::lookup($boolErr);
// add cell value
$cell->setValueExplicit($value, DataType::TYPE_ERROR);
break;
}
if (!$this->readDataOnly) {
// add cell style
$cell->setXfIndex($this->mapCellXfIndex[$xfIndex]);
}
}
} | php | {
"resource": ""
} |
q251399 | Xls.readMulBlank | validation | private function readMulBlank()
{
$length = self::getUInt2d($this->data, $this->pos + 2);
$recordData = $this->readRecordData($this->data, $this->pos + 4, $length);
// move stream pointer to next record
$this->pos += 4 + $length;
// offset: 0; size: 2; index to row
$row = self::getUInt2d($recordData, 0);
// offset: 2; size: 2; index to first column
$fc = self::getUInt2d($recordData, 2);
// offset: 4; size: 2 x nc; list of indexes to XF records
// add style information
if (!$this->readDataOnly && $this->readEmptyCells) {
for ($i = 0; $i < $length / 2 - 3; ++$i) {
$columnString = Coordinate::stringFromColumnIndex($fc + $i + 1);
// Read cell?
if (($this->getReadFilter() !== null) && $this->getReadFilter()->readCell($columnString, $row + 1, $this->phpSheet->getTitle())) {
$xfIndex = self::getUInt2d($recordData, 4 + 2 * $i);
$this->phpSheet->getCell($columnString . ($row + 1))->setXfIndex($this->mapCellXfIndex[$xfIndex]);
}
}
}
// offset: 6; size 2; index to last column (not needed)
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.