提交的内容
This commit is contained in:
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Alignment.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Alignment.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Border.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Border.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Borders.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Borders.php
vendored
Executable file → Normal file
17
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Color.php
vendored
Executable file → Normal file
17
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Color.php
vendored
Executable file → Normal file
@ -362,23 +362,8 @@ class Color extends Supervisor
|
||||
$green = self::getGreen($hexColourValue, false);
|
||||
/** @var int $blue */
|
||||
$blue = self::getBlue($hexColourValue, false);
|
||||
if ($adjustPercentage > 0) {
|
||||
$red += (255 - $red) * $adjustPercentage;
|
||||
$green += (255 - $green) * $adjustPercentage;
|
||||
$blue += (255 - $blue) * $adjustPercentage;
|
||||
} else {
|
||||
$red += $red * $adjustPercentage;
|
||||
$green += $green * $adjustPercentage;
|
||||
$blue += $blue * $adjustPercentage;
|
||||
}
|
||||
|
||||
$rgb = strtoupper(
|
||||
str_pad(dechex((int) $red), 2, '0', 0) .
|
||||
str_pad(dechex((int) $green), 2, '0', 0) .
|
||||
str_pad(dechex((int) $blue), 2, '0', 0)
|
||||
);
|
||||
|
||||
return (($rgba) ? 'FF' : '') . $rgb;
|
||||
return (($rgba) ? 'FF' : '') . RgbTint::rgbAndTintToRgb($red, $green, $blue, $adjustPercentage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
2
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Conditional.php
vendored
Executable file → Normal file
2
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Conditional.php
vendored
Executable file → Normal file
@ -248,7 +248,7 @@ class Conditional implements IComparable
|
||||
/**
|
||||
* Set Conditions.
|
||||
*
|
||||
* @param bool|float|int|string|(bool|float|int|string)[] $conditions Condition
|
||||
* @param (bool|float|int|string)[]|bool|float|int|string $conditions Condition
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
|
||||
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/CellMatcher.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/CellMatcher.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/CellStyleAssessor.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/CellStyleAssessor.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBar.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBar.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBarExtension.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalDataBarExtension.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalFormatValueObject.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalFormatValueObject.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalFormattingRuleExtension.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/ConditionalFormattingRuleExtension.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/StyleMerger.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/StyleMerger.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Blanks.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Blanks.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/CellValue.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/DateValue.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/DateValue.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Duplicates.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Duplicates.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Errors.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Errors.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Expression.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/Expression.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/TextValue.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/TextValue.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/WizardAbstract.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/WizardAbstract.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/WizardInterface.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/ConditionalFormatting/Wizard/WizardInterface.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Fill.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Fill.php
vendored
Executable file → Normal file
49
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Font.php
vendored
Executable file → Normal file
49
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Font.php
vendored
Executable file → Normal file
@ -107,6 +107,9 @@ class Font extends Supervisor
|
||||
*/
|
||||
public $colorIndex;
|
||||
|
||||
/** @var string */
|
||||
protected $scheme = '';
|
||||
|
||||
/**
|
||||
* Create a new Font.
|
||||
*
|
||||
@ -231,6 +234,12 @@ class Font extends Supervisor
|
||||
if (isset($styleArray['size'])) {
|
||||
$this->setSize($styleArray['size']);
|
||||
}
|
||||
if (isset($styleArray['chartColor'])) {
|
||||
$this->chartColor = $styleArray['chartColor'];
|
||||
}
|
||||
if (isset($styleArray['scheme'])) {
|
||||
$this->setScheme($styleArray['scheme']);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
@ -278,13 +287,11 @@ class Font extends Supervisor
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Name.
|
||||
* Set Name and turn off Scheme.
|
||||
*
|
||||
* @param string $fontname
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($fontname)
|
||||
public function setName($fontname): self
|
||||
{
|
||||
if ($fontname == '') {
|
||||
$fontname = 'Calibri';
|
||||
@ -296,7 +303,7 @@ class Font extends Supervisor
|
||||
$this->name = $fontname;
|
||||
}
|
||||
|
||||
return $this;
|
||||
return $this->setScheme('');
|
||||
}
|
||||
|
||||
public function setLatin(string $fontname): self
|
||||
@ -634,6 +641,13 @@ class Font extends Supervisor
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setChartColorFromObject(?ChartColor $chartColor): self
|
||||
{
|
||||
$this->chartColor = $chartColor;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Underline.
|
||||
*
|
||||
@ -774,6 +788,7 @@ class Font extends Supervisor
|
||||
$this->underline .
|
||||
($this->strikethrough ? 't' : 'f') .
|
||||
$this->color->getHashCode() .
|
||||
$this->scheme .
|
||||
implode(
|
||||
'*',
|
||||
[
|
||||
@ -802,6 +817,7 @@ class Font extends Supervisor
|
||||
$this->exportArray2($exportedArray, 'italic', $this->getItalic());
|
||||
$this->exportArray2($exportedArray, 'latin', $this->getLatin());
|
||||
$this->exportArray2($exportedArray, 'name', $this->getName());
|
||||
$this->exportArray2($exportedArray, 'scheme', $this->getScheme());
|
||||
$this->exportArray2($exportedArray, 'size', $this->getSize());
|
||||
$this->exportArray2($exportedArray, 'strikethrough', $this->getStrikethrough());
|
||||
$this->exportArray2($exportedArray, 'strikeType', $this->getStrikeType());
|
||||
@ -812,4 +828,27 @@ class Font extends Supervisor
|
||||
|
||||
return $exportedArray;
|
||||
}
|
||||
|
||||
public function getScheme(): string
|
||||
{
|
||||
if ($this->isSupervisor) {
|
||||
return $this->getSharedComponent()->getScheme();
|
||||
}
|
||||
|
||||
return $this->scheme;
|
||||
}
|
||||
|
||||
public function setScheme(string $scheme): self
|
||||
{
|
||||
if ($scheme === '' || $scheme === 'major' || $scheme === 'minor') {
|
||||
if ($this->isSupervisor) {
|
||||
$styleArray = $this->getStyleArray(['scheme' => $scheme]);
|
||||
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
|
||||
} else {
|
||||
$this->scheme = $scheme;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/BaseFormatter.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/BaseFormatter.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/DateFormatter.php
vendored
Executable file → Normal file
21
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php
vendored
Executable file → Normal file
21
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Formatter.php
vendored
Executable file → Normal file
@ -3,6 +3,7 @@
|
||||
namespace PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
|
||||
use PhpOffice\PhpSpreadsheet\Reader\Xls\Color\BIFF8;
|
||||
use PhpOffice\PhpSpreadsheet\RichText\RichText;
|
||||
use PhpOffice\PhpSpreadsheet\Style\Color;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
@ -67,14 +68,19 @@ class Formatter
|
||||
// 3 sections: [POSITIVE/TEXT] [NEGATIVE] [ZERO]
|
||||
// 4 sections: [POSITIVE] [NEGATIVE] [ZERO] [TEXT]
|
||||
$sectionCount = count($sections);
|
||||
$color_regex = '/\\[(' . implode('|', Color::NAMED_COLORS) . ')\\]/mui';
|
||||
// Colour could be a named colour, or a numeric index entry in the colour-palette
|
||||
$color_regex = '/\\[(' . implode('|', Color::NAMED_COLORS) . '|color\\s*(\\d+))\\]/mui';
|
||||
$cond_regex = '/\\[(>|>=|<|<=|=|<>)([+-]?\\d+([.]\\d+)?)\\]/';
|
||||
$colors = ['', '', '', '', ''];
|
||||
$conditionOperations = ['', '', '', '', ''];
|
||||
$conditionComparisonValues = [0, 0, 0, 0, 0];
|
||||
for ($idx = 0; $idx < $sectionCount; ++$idx) {
|
||||
if (preg_match($color_regex, $sections[$idx], $matches)) {
|
||||
$colors[$idx] = $matches[0];
|
||||
if (isset($matches[2])) {
|
||||
$colors[$idx] = '#' . BIFF8::lookup((int) $matches[2] + 7)['rgb'];
|
||||
} else {
|
||||
$colors[$idx] = $matches[0];
|
||||
}
|
||||
$sections[$idx] = (string) preg_replace($color_regex, '', $sections[$idx]);
|
||||
}
|
||||
if (preg_match($cond_regex, $sections[$idx], $matches)) {
|
||||
@ -170,10 +176,11 @@ class Formatter
|
||||
$format = (string) preg_replace('/_.?/ui', ' ', $format);
|
||||
|
||||
// Let's begin inspecting the format and converting the value to a formatted string
|
||||
// Check for date/time characters (not inside quotes)
|
||||
if (
|
||||
(preg_match('/(\[\$[A-Z]*-[0-9A-F]*\])*[hmsdy](?=(?:[^"]|"[^"]*")*$)/miu', $format)) &&
|
||||
(preg_match('/0(?![^\[]*\])/miu', $format) === 0)
|
||||
// Check for date/time characters (not inside quotes)
|
||||
(preg_match('/(\[\$[A-Z]*-[0-9A-F]*\])*[hmsdy](?=(?:[^"]|"[^"]*")*$)/miu', $format))
|
||||
// A date/time with a decimal time shouldn't have a digit placeholder before the decimal point
|
||||
&& (preg_match('/[0\?#]\.(?![^\[]*\])/miu', $format) === 0)
|
||||
) {
|
||||
// datetime format
|
||||
$value = DateFormatter::format($value, $format);
|
||||
@ -194,8 +201,6 @@ class Formatter
|
||||
$value = $writerInstance->$function($value, $colors);
|
||||
}
|
||||
|
||||
$value = str_replace(chr(0x00), '.', $value);
|
||||
|
||||
return $value;
|
||||
return str_replace(chr(0x00), '.', $value);
|
||||
}
|
||||
}
|
||||
|
||||
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/FractionFormatter.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/FractionFormatter.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/NumberFormatter.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/NumberFormatter.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/PercentageFormatter.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/PercentageFormatter.php
vendored
Executable file → Normal file
4
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Accounting.php
vendored
Executable file → Normal file
4
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Accounting.php
vendored
Executable file → Normal file
@ -89,13 +89,13 @@ class Accounting extends Currency
|
||||
(
|
||||
$this->currencySymbolPosition === self::LEADING_SYMBOL &&
|
||||
$this->currencySymbolSpacing === self::SYMBOL_WITH_SPACING
|
||||
) ? ' ' : '',
|
||||
) ? "\u{a0}" : '',
|
||||
$this->thousandsSeparator ? '#,##' : null,
|
||||
$this->decimals > 0 ? '.' . str_repeat('0', $this->decimals) : null,
|
||||
(
|
||||
$this->currencySymbolPosition === self::TRAILING_SYMBOL &&
|
||||
$this->currencySymbolSpacing === self::SYMBOL_WITH_SPACING
|
||||
) ? ' ' : '',
|
||||
) ? "\u{a0}" : '',
|
||||
$this->currencySymbolPosition === self::TRAILING_SYMBOL ? $this->formatCurrencyCode() : null
|
||||
);
|
||||
}
|
||||
|
||||
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Currency.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Currency.php
vendored
Executable file → Normal file
125
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Date.php
vendored
Normal file
125
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Date.php
vendored
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;
|
||||
|
||||
class Date extends DateTimeWizard
|
||||
{
|
||||
/**
|
||||
* Year (4 digits), e.g. 2023.
|
||||
*/
|
||||
public const YEAR_FULL = 'yyyy';
|
||||
|
||||
/**
|
||||
* Year (last 2 digits), e.g. 23.
|
||||
*/
|
||||
public const YEAR_SHORT = 'yy';
|
||||
|
||||
public const MONTH_FIRST_LETTER = 'mmmmm';
|
||||
/**
|
||||
* Month name, long form, e.g. January.
|
||||
*/
|
||||
public const MONTH_NAME_FULL = 'mmmm';
|
||||
/**
|
||||
* Month name, short form, e.g. Jan.
|
||||
*/
|
||||
public const MONTH_NAME_SHORT = 'mmm';
|
||||
/**
|
||||
* Month number with a leading zero if required, e.g. 01.
|
||||
*/
|
||||
public const MONTH_NUMBER_LONG = 'mm';
|
||||
|
||||
/**
|
||||
* Month number without a leading zero, e.g. 1.
|
||||
*/
|
||||
public const MONTH_NUMBER_SHORT = 'm';
|
||||
|
||||
/**
|
||||
* Day of the week, full form, e.g. Tuesday.
|
||||
*/
|
||||
public const WEEKDAY_NAME_LONG = 'dddd';
|
||||
|
||||
/**
|
||||
* Day of the week, short form, e.g. Tue.
|
||||
*/
|
||||
public const WEEKDAY_NAME_SHORT = 'ddd';
|
||||
|
||||
/**
|
||||
* Day number with a leading zero, e.g. 03.
|
||||
*/
|
||||
public const DAY_NUMBER_LONG = 'dd';
|
||||
|
||||
/**
|
||||
* Day number without a leading zero, e.g. 3.
|
||||
*/
|
||||
public const DAY_NUMBER_SHORT = 'd';
|
||||
|
||||
protected const DATE_BLOCKS = [
|
||||
self::YEAR_FULL,
|
||||
self::YEAR_SHORT,
|
||||
self::MONTH_FIRST_LETTER,
|
||||
self::MONTH_NAME_FULL,
|
||||
self::MONTH_NAME_SHORT,
|
||||
self::MONTH_NUMBER_LONG,
|
||||
self::MONTH_NUMBER_SHORT,
|
||||
self::WEEKDAY_NAME_LONG,
|
||||
self::WEEKDAY_NAME_SHORT,
|
||||
self::DAY_NUMBER_LONG,
|
||||
self::DAY_NUMBER_SHORT,
|
||||
];
|
||||
|
||||
public const SEPARATOR_DASH = '-';
|
||||
public const SEPARATOR_DOT = '.';
|
||||
public const SEPARATOR_SLASH = '/';
|
||||
public const SEPARATOR_SPACE_NONBREAKING = "\u{a0}";
|
||||
public const SEPARATOR_SPACE = ' ';
|
||||
|
||||
protected const DATE_DEFAULT = [
|
||||
self::YEAR_FULL,
|
||||
self::MONTH_NUMBER_LONG,
|
||||
self::DAY_NUMBER_LONG,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected array $separators;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected array $formatBlocks;
|
||||
|
||||
/**
|
||||
* @param null|string|string[] $separators
|
||||
* If you want to use the same separator for all format blocks, then it can be passed as a string literal;
|
||||
* if you wish to use different separators, then they should be passed as an array.
|
||||
* If you want to use only a single format block, then pass a null as the separator argument
|
||||
*/
|
||||
public function __construct($separators = self::SEPARATOR_DASH, string ...$formatBlocks)
|
||||
{
|
||||
$separators ??= self::SEPARATOR_DASH;
|
||||
$formatBlocks = (count($formatBlocks) === 0) ? self::DATE_DEFAULT : $formatBlocks;
|
||||
|
||||
$this->separators = $this->padSeparatorArray(
|
||||
is_array($separators) ? $separators : [$separators],
|
||||
count($formatBlocks) - 1
|
||||
);
|
||||
$this->formatBlocks = array_map([$this, 'mapFormatBlocks'], $formatBlocks);
|
||||
}
|
||||
|
||||
private function mapFormatBlocks(string $value): string
|
||||
{
|
||||
// Any date masking codes are returned as lower case values
|
||||
if (in_array(mb_strtolower($value), self::DATE_BLOCKS, true)) {
|
||||
return mb_strtolower($value);
|
||||
}
|
||||
|
||||
// Wrap any string literals in quotes, so that they're clearly defined as string literals
|
||||
return $this->wrapLiteral($value);
|
||||
}
|
||||
|
||||
public function format(): string
|
||||
{
|
||||
return implode('', array_map([$this, 'intersperse'], $this->formatBlocks, $this->separators));
|
||||
}
|
||||
}
|
||||
50
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTime.php
vendored
Normal file
50
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTime.php
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;
|
||||
|
||||
class DateTime extends DateTimeWizard
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected array $separators;
|
||||
|
||||
/**
|
||||
* @var array<DateTimeWizard|string>
|
||||
*/
|
||||
protected array $formatBlocks;
|
||||
|
||||
/**
|
||||
* @param null|string|string[] $separators
|
||||
* If you want to use only a single format block, then pass a null as the separator argument
|
||||
* @param DateTimeWizard|string ...$formatBlocks
|
||||
*/
|
||||
public function __construct($separators, ...$formatBlocks)
|
||||
{
|
||||
$this->separators = $this->padSeparatorArray(
|
||||
is_array($separators) ? $separators : [$separators],
|
||||
count($formatBlocks) - 1
|
||||
);
|
||||
$this->formatBlocks = array_map([$this, 'mapFormatBlocks'], $formatBlocks);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DateTimeWizard|string $value
|
||||
*/
|
||||
private function mapFormatBlocks($value): string
|
||||
{
|
||||
// Any date masking codes are returned as lower case values
|
||||
if (is_object($value)) {
|
||||
// We can't explicitly test for Stringable until PHP >= 8.0
|
||||
return $value;
|
||||
}
|
||||
|
||||
// Wrap any string literals in quotes, so that they're clearly defined as string literals
|
||||
return $this->wrapLiteral($value);
|
||||
}
|
||||
|
||||
public function format(): string
|
||||
{
|
||||
return implode('', array_map([$this, 'intersperse'], $this->formatBlocks, $this->separators));
|
||||
}
|
||||
}
|
||||
44
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTimeWizard.php
vendored
Normal file
44
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/DateTimeWizard.php
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;
|
||||
|
||||
abstract class DateTimeWizard implements Wizard
|
||||
{
|
||||
protected const NO_ESCAPING_NEEDED = "$+-/():!^&'~{}<>= ";
|
||||
|
||||
protected function padSeparatorArray(array $separators, int $count): array
|
||||
{
|
||||
$lastSeparator = array_pop($separators);
|
||||
|
||||
return $separators + array_fill(0, $count, $lastSeparator);
|
||||
}
|
||||
|
||||
protected function escapeSingleCharacter(string $value): string
|
||||
{
|
||||
if (strpos(self::NO_ESCAPING_NEEDED, $value) !== false) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
return "\\{$value}";
|
||||
}
|
||||
|
||||
protected function wrapLiteral(string $value): string
|
||||
{
|
||||
if (mb_strlen($value, 'UTF-8') === 1) {
|
||||
return $this->escapeSingleCharacter($value);
|
||||
}
|
||||
|
||||
// Wrap any other string literals in quotes, so that they're clearly defined as string literals
|
||||
return '"' . str_replace('"', '""', $value) . '"';
|
||||
}
|
||||
|
||||
protected function intersperse(string $formatBlock, ?string $separator): string
|
||||
{
|
||||
return "{$formatBlock}{$separator}";
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->format();
|
||||
}
|
||||
}
|
||||
153
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Duration.php
vendored
Normal file
153
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Duration.php
vendored
Normal file
@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;
|
||||
|
||||
class Duration extends DateTimeWizard
|
||||
{
|
||||
public const DAYS_DURATION = 'd';
|
||||
|
||||
/**
|
||||
* Hours as a duration (can exceed 24), e.g. 29.
|
||||
*/
|
||||
public const HOURS_DURATION = '[h]';
|
||||
|
||||
/**
|
||||
* Hours without a leading zero, e.g. 9.
|
||||
*/
|
||||
public const HOURS_SHORT = 'h';
|
||||
|
||||
/**
|
||||
* Hours with a leading zero, e.g. 09.
|
||||
*/
|
||||
public const HOURS_LONG = 'hh';
|
||||
|
||||
/**
|
||||
* Minutes as a duration (can exceed 60), e.g. 109.
|
||||
*/
|
||||
public const MINUTES_DURATION = '[m]';
|
||||
|
||||
/**
|
||||
* Minutes without a leading zero, e.g. 5.
|
||||
*/
|
||||
public const MINUTES_SHORT = 'm';
|
||||
|
||||
/**
|
||||
* Minutes with a leading zero, e.g. 05.
|
||||
*/
|
||||
public const MINUTES_LONG = 'mm';
|
||||
|
||||
/**
|
||||
* Seconds as a duration (can exceed 60), e.g. 129.
|
||||
*/
|
||||
public const SECONDS_DURATION = '[s]';
|
||||
|
||||
/**
|
||||
* Seconds without a leading zero, e.g. 2.
|
||||
*/
|
||||
public const SECONDS_SHORT = 's';
|
||||
|
||||
/**
|
||||
* Seconds with a leading zero, e.g. 02.
|
||||
*/
|
||||
public const SECONDS_LONG = 'ss';
|
||||
|
||||
protected const DURATION_BLOCKS = [
|
||||
self::DAYS_DURATION,
|
||||
self::HOURS_DURATION,
|
||||
self::HOURS_LONG,
|
||||
self::HOURS_SHORT,
|
||||
self::MINUTES_DURATION,
|
||||
self::MINUTES_LONG,
|
||||
self::MINUTES_SHORT,
|
||||
self::SECONDS_DURATION,
|
||||
self::SECONDS_LONG,
|
||||
self::SECONDS_SHORT,
|
||||
];
|
||||
|
||||
protected const DURATION_MASKS = [
|
||||
self::DAYS_DURATION => self::DAYS_DURATION,
|
||||
self::HOURS_DURATION => self::HOURS_SHORT,
|
||||
self::MINUTES_DURATION => self::MINUTES_LONG,
|
||||
self::SECONDS_DURATION => self::SECONDS_LONG,
|
||||
];
|
||||
|
||||
protected const DURATION_DEFAULTS = [
|
||||
self::HOURS_LONG => self::HOURS_DURATION,
|
||||
self::HOURS_SHORT => self::HOURS_DURATION,
|
||||
self::MINUTES_LONG => self::MINUTES_DURATION,
|
||||
self::MINUTES_SHORT => self::MINUTES_DURATION,
|
||||
self::SECONDS_LONG => self::SECONDS_DURATION,
|
||||
self::SECONDS_SHORT => self::SECONDS_DURATION,
|
||||
];
|
||||
|
||||
public const SEPARATOR_COLON = ':';
|
||||
public const SEPARATOR_SPACE_NONBREAKING = "\u{a0}";
|
||||
public const SEPARATOR_SPACE = ' ';
|
||||
|
||||
public const DURATION_DEFAULT = [
|
||||
self::HOURS_DURATION,
|
||||
self::MINUTES_LONG,
|
||||
self::SECONDS_LONG,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected array $separators;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected array $formatBlocks;
|
||||
|
||||
protected bool $durationIsSet = false;
|
||||
|
||||
/**
|
||||
* @param null|string|string[] $separators
|
||||
* If you want to use the same separator for all format blocks, then it can be passed as a string literal;
|
||||
* if you wish to use different separators, then they should be passed as an array.
|
||||
* If you want to use only a single format block, then pass a null as the separator argument
|
||||
*/
|
||||
public function __construct($separators = self::SEPARATOR_COLON, string ...$formatBlocks)
|
||||
{
|
||||
$separators ??= self::SEPARATOR_COLON;
|
||||
$formatBlocks = (count($formatBlocks) === 0) ? self::DURATION_DEFAULT : $formatBlocks;
|
||||
|
||||
$this->separators = $this->padSeparatorArray(
|
||||
is_array($separators) ? $separators : [$separators],
|
||||
count($formatBlocks) - 1
|
||||
);
|
||||
$this->formatBlocks = array_map([$this, 'mapFormatBlocks'], $formatBlocks);
|
||||
|
||||
if ($this->durationIsSet === false) {
|
||||
// We need at least one duration mask, so if none has been set we change the first mask element
|
||||
// to a duration.
|
||||
$this->formatBlocks[0] = self::DURATION_DEFAULTS[mb_strtolower($this->formatBlocks[0])];
|
||||
}
|
||||
}
|
||||
|
||||
private function mapFormatBlocks(string $value): string
|
||||
{
|
||||
// Any duration masking codes are returned as lower case values
|
||||
if (in_array(mb_strtolower($value), self::DURATION_BLOCKS, true)) {
|
||||
if (array_key_exists(mb_strtolower($value), self::DURATION_MASKS)) {
|
||||
if ($this->durationIsSet) {
|
||||
// We should only have a single duration mask, the first defined in the mask set,
|
||||
// so convert any additional duration masks to standard time masks.
|
||||
$value = self::DURATION_MASKS[mb_strtolower($value)];
|
||||
}
|
||||
$this->durationIsSet = true;
|
||||
}
|
||||
|
||||
return mb_strtolower($value);
|
||||
}
|
||||
|
||||
// Wrap any string literals in quotes, so that they're clearly defined as string literals
|
||||
return $this->wrapLiteral($value);
|
||||
}
|
||||
|
||||
public function format(): string
|
||||
{
|
||||
return implode('', array_map([$this, 'intersperse'], $this->formatBlocks, $this->separators));
|
||||
}
|
||||
}
|
||||
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Locale.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Locale.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Number.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Number.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/NumberBase.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/NumberBase.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Percentage.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Percentage.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Scientific.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Scientific.php
vendored
Executable file → Normal file
105
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Time.php
vendored
Normal file
105
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Time.php
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard;
|
||||
|
||||
class Time extends DateTimeWizard
|
||||
{
|
||||
/**
|
||||
* Hours without a leading zero, e.g. 9.
|
||||
*/
|
||||
public const HOURS_SHORT = 'h';
|
||||
|
||||
/**
|
||||
* Hours with a leading zero, e.g. 09.
|
||||
*/
|
||||
public const HOURS_LONG = 'hh';
|
||||
|
||||
/**
|
||||
* Minutes without a leading zero, e.g. 5.
|
||||
*/
|
||||
public const MINUTES_SHORT = 'm';
|
||||
|
||||
/**
|
||||
* Minutes with a leading zero, e.g. 05.
|
||||
*/
|
||||
public const MINUTES_LONG = 'mm';
|
||||
|
||||
/**
|
||||
* Seconds without a leading zero, e.g. 2.
|
||||
*/
|
||||
public const SECONDS_SHORT = 's';
|
||||
|
||||
/**
|
||||
* Seconds with a leading zero, e.g. 02.
|
||||
*/
|
||||
public const SECONDS_LONG = 'ss';
|
||||
|
||||
public const MORNING_AFTERNOON = 'AM/PM';
|
||||
|
||||
protected const TIME_BLOCKS = [
|
||||
self::HOURS_LONG,
|
||||
self::HOURS_SHORT,
|
||||
self::MINUTES_LONG,
|
||||
self::MINUTES_SHORT,
|
||||
self::SECONDS_LONG,
|
||||
self::SECONDS_SHORT,
|
||||
self::MORNING_AFTERNOON,
|
||||
];
|
||||
|
||||
public const SEPARATOR_COLON = ':';
|
||||
public const SEPARATOR_SPACE_NONBREAKING = "\u{a0}";
|
||||
public const SEPARATOR_SPACE = ' ';
|
||||
|
||||
protected const TIME_DEFAULT = [
|
||||
self::HOURS_LONG,
|
||||
self::MINUTES_LONG,
|
||||
self::SECONDS_LONG,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected array $separators;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected array $formatBlocks;
|
||||
|
||||
/**
|
||||
* @param null|string|string[] $separators
|
||||
* If you want to use the same separator for all format blocks, then it can be passed as a string literal;
|
||||
* if you wish to use different separators, then they should be passed as an array.
|
||||
* If you want to use only a single format block, then pass a null as the separator argument
|
||||
*/
|
||||
public function __construct($separators = self::SEPARATOR_COLON, string ...$formatBlocks)
|
||||
{
|
||||
$separators ??= self::SEPARATOR_COLON;
|
||||
$formatBlocks = (count($formatBlocks) === 0) ? self::TIME_DEFAULT : $formatBlocks;
|
||||
|
||||
$this->separators = $this->padSeparatorArray(
|
||||
is_array($separators) ? $separators : [$separators],
|
||||
count($formatBlocks) - 1
|
||||
);
|
||||
$this->formatBlocks = array_map([$this, 'mapFormatBlocks'], $formatBlocks);
|
||||
}
|
||||
|
||||
private function mapFormatBlocks(string $value): string
|
||||
{
|
||||
// Any date masking codes are returned as lower case values
|
||||
// except for AM/PM, which is set to uppercase
|
||||
if (in_array(mb_strtolower($value), self::TIME_BLOCKS, true)) {
|
||||
return mb_strtolower($value);
|
||||
} elseif (mb_strtoupper($value) === self::MORNING_AFTERNOON) {
|
||||
return mb_strtoupper($value);
|
||||
}
|
||||
|
||||
// Wrap any string literals in quotes, so that they're clearly defined as string literals
|
||||
return $this->wrapLiteral($value);
|
||||
}
|
||||
|
||||
public function format(): string
|
||||
{
|
||||
return implode('', array_map([$this, 'intersperse'], $this->formatBlocks, $this->separators));
|
||||
}
|
||||
}
|
||||
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Wizard.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/NumberFormat/Wizard/Wizard.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Protection.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Protection.php
vendored
Executable file → Normal file
175
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/RgbTint.php
vendored
Normal file
175
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/RgbTint.php
vendored
Normal file
@ -0,0 +1,175 @@
|
||||
<?php
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Style;
|
||||
|
||||
/**
|
||||
* Class to handle tint applied to color.
|
||||
* Code borrows heavily from some Python projects.
|
||||
*
|
||||
* @see https://docs.python.org/3/library/colorsys.html
|
||||
* @see https://gist.github.com/Mike-Honey/b36e651e9a7f1d2e1d60ce1c63b9b633
|
||||
*/
|
||||
class RgbTint
|
||||
{
|
||||
private const ONE_THIRD = 1.0 / 3.0;
|
||||
private const ONE_SIXTH = 1.0 / 6.0;
|
||||
private const TWO_THIRD = 2.0 / 3.0;
|
||||
private const RGBMAX = 255.0;
|
||||
/**
|
||||
* MS excel's tint function expects that HLS is base 240.
|
||||
*
|
||||
* @see https://social.msdn.microsoft.com/Forums/en-US/e9d8c136-6d62-4098-9b1b-dac786149f43/excel-color-tint-algorithm-incorrect?forum=os_binaryfile#d3c2ac95-52e0-476b-86f1-e2a697f24969
|
||||
*/
|
||||
private const HLSMAX = 240.0;
|
||||
|
||||
/**
|
||||
* Convert red/green/blue to hue/luminance/saturation.
|
||||
*
|
||||
* @param float $red 0.0 through 1.0
|
||||
* @param float $green 0.0 through 1.0
|
||||
* @param float $blue 0.0 through 1.0
|
||||
*
|
||||
* @return float[]
|
||||
*/
|
||||
private static function rgbToHls(float $red, float $green, float $blue): array
|
||||
{
|
||||
$maxc = max($red, $green, $blue);
|
||||
$minc = min($red, $green, $blue);
|
||||
$luminance = ($minc + $maxc) / 2.0;
|
||||
if ($minc === $maxc) {
|
||||
return [0.0, $luminance, 0.0];
|
||||
}
|
||||
$maxMinusMin = $maxc - $minc;
|
||||
if ($luminance <= 0.5) {
|
||||
$s = $maxMinusMin / ($maxc + $minc);
|
||||
} else {
|
||||
$s = $maxMinusMin / (2.0 - $maxc - $minc);
|
||||
}
|
||||
$rc = ($maxc - $red) / $maxMinusMin;
|
||||
$gc = ($maxc - $green) / $maxMinusMin;
|
||||
$bc = ($maxc - $blue) / $maxMinusMin;
|
||||
if ($red === $maxc) {
|
||||
$h = $bc - $gc;
|
||||
} elseif ($green === $maxc) {
|
||||
$h = 2.0 + $rc - $bc;
|
||||
} else {
|
||||
$h = 4.0 + $gc - $rc;
|
||||
}
|
||||
$h = self::positiveDecimalPart($h / 6.0);
|
||||
|
||||
return [$h, $luminance, $s];
|
||||
}
|
||||
|
||||
/** @var mixed */
|
||||
private static $scrutinizerZeroPointZero = 0.0;
|
||||
|
||||
/**
|
||||
* Convert hue/luminance/saturation to red/green/blue.
|
||||
*
|
||||
* @param float $hue 0.0 through 1.0
|
||||
* @param float $luminance 0.0 through 1.0
|
||||
* @param float $saturation 0.0 through 1.0
|
||||
*
|
||||
* @return float[]
|
||||
*/
|
||||
private static function hlsToRgb($hue, $luminance, $saturation): array
|
||||
{
|
||||
if ($saturation === self::$scrutinizerZeroPointZero) {
|
||||
return [$luminance, $luminance, $luminance];
|
||||
}
|
||||
if ($luminance <= 0.5) {
|
||||
$m2 = $luminance * (1.0 + $saturation);
|
||||
} else {
|
||||
$m2 = $luminance + $saturation - ($luminance * $saturation);
|
||||
}
|
||||
$m1 = 2.0 * $luminance - $m2;
|
||||
|
||||
return [
|
||||
self::vFunction($m1, $m2, $hue + self::ONE_THIRD),
|
||||
self::vFunction($m1, $m2, $hue),
|
||||
self::vFunction($m1, $m2, $hue - self::ONE_THIRD),
|
||||
];
|
||||
}
|
||||
|
||||
private static function vFunction(float $m1, float $m2, float $hue): float
|
||||
{
|
||||
$hue = self::positiveDecimalPart($hue);
|
||||
if ($hue < self::ONE_SIXTH) {
|
||||
return $m1 + ($m2 - $m1) * $hue * 6.0;
|
||||
}
|
||||
if ($hue < 0.5) {
|
||||
return $m2;
|
||||
}
|
||||
if ($hue < self::TWO_THIRD) {
|
||||
return $m1 + ($m2 - $m1) * (self::TWO_THIRD - $hue) * 6.0;
|
||||
}
|
||||
|
||||
return $m1;
|
||||
}
|
||||
|
||||
private static function positiveDecimalPart(float $hue): float
|
||||
{
|
||||
$hue = fmod($hue, 1.0);
|
||||
|
||||
return ($hue >= 0.0) ? $hue : (1.0 + $hue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert red/green/blue to HLSMAX-based hue/luminance/saturation.
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
private static function rgbToMsHls(int $red, int $green, int $blue): array
|
||||
{
|
||||
$red01 = $red / self::RGBMAX;
|
||||
$green01 = $green / self::RGBMAX;
|
||||
$blue01 = $blue / self::RGBMAX;
|
||||
[$hue, $luminance, $saturation] = self::rgbToHls($red01, $green01, $blue01);
|
||||
|
||||
return [
|
||||
(int) round($hue * self::HLSMAX),
|
||||
(int) round($luminance * self::HLSMAX),
|
||||
(int) round($saturation * self::HLSMAX),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts HLSMAX based HLS values to rgb values in the range (0,1).
|
||||
*
|
||||
* @return float[]
|
||||
*/
|
||||
private static function msHlsToRgb(int $hue, int $lightness, int $saturation): array
|
||||
{
|
||||
return self::hlsToRgb($hue / self::HLSMAX, $lightness / self::HLSMAX, $saturation / self::HLSMAX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tints HLSMAX based luminance.
|
||||
*
|
||||
* @see http://ciintelligence.blogspot.co.uk/2012/02/converting-excel-theme-color-and-tint.html
|
||||
*/
|
||||
private static function tintLuminance(float $tint, float $luminance): int
|
||||
{
|
||||
if ($tint < 0) {
|
||||
return (int) round($luminance * (1.0 + $tint));
|
||||
}
|
||||
|
||||
return (int) round($luminance * (1.0 - $tint) + (self::HLSMAX - self::HLSMAX * (1.0 - $tint)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return result of tinting supplied rgb as 6 hex digits.
|
||||
*/
|
||||
public static function rgbAndTintToRgb(int $red, int $green, int $blue, float $tint): string
|
||||
{
|
||||
[$hue, $luminance, $saturation] = self::rgbToMsHls($red, $green, $blue);
|
||||
[$red, $green, $blue] = self::msHlsToRgb($hue, self::tintLuminance($tint, $luminance), $saturation);
|
||||
|
||||
return sprintf(
|
||||
'%02X%02X%02X',
|
||||
(int) round($red * self::RGBMAX),
|
||||
(int) round($green * self::RGBMAX),
|
||||
(int) round($blue * self::RGBMAX)
|
||||
);
|
||||
}
|
||||
}
|
||||
14
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Style.php
vendored
Executable file → Normal file
14
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Style.php
vendored
Executable file → Normal file
@ -2,7 +2,10 @@
|
||||
|
||||
namespace PhpOffice\PhpSpreadsheet\Style;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
|
||||
use PhpOffice\PhpSpreadsheet\Exception;
|
||||
use PhpOffice\PhpSpreadsheet\Shared\StringHelper;
|
||||
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||
|
||||
class Style extends Supervisor
|
||||
@ -122,7 +125,7 @@ class Style extends Supervisor
|
||||
public function getSharedComponent(): self
|
||||
{
|
||||
$activeSheet = $this->getActiveSheet();
|
||||
$selectedCell = $this->getActiveCell(); // e.g. 'A1'
|
||||
$selectedCell = Functions::trimSheetFromCellReference($this->getActiveCell()); // e.g. 'A1'
|
||||
|
||||
if ($activeSheet->cellExists($selectedCell)) {
|
||||
$xfIndex = $activeSheet->getCell($selectedCell)->getXfIndex();
|
||||
@ -203,8 +206,15 @@ class Style extends Supervisor
|
||||
if ($this->isSupervisor) {
|
||||
$pRange = $this->getSelectedCells();
|
||||
|
||||
// Uppercase coordinate
|
||||
// Uppercase coordinate and strip any Worksheet reference from the selected range
|
||||
$pRange = strtoupper($pRange);
|
||||
if (strpos($pRange, '!') !== false) {
|
||||
$pRangeWorksheet = StringHelper::strToUpper(trim(substr($pRange, 0, (int) strrpos($pRange, '!')), "'"));
|
||||
if ($pRangeWorksheet !== '' && StringHelper::strToUpper($this->getActiveSheet()->getTitle()) !== $pRangeWorksheet) {
|
||||
throw new Exception('Invalid Worksheet for specified Range');
|
||||
}
|
||||
$pRange = strtoupper(Functions::trimSheetFromCellReference($pRange));
|
||||
}
|
||||
|
||||
// Is it a cell range or a single cell?
|
||||
if (strpos($pRange, ':') === false) {
|
||||
|
||||
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Supervisor.php
vendored
Executable file → Normal file
0
vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Style/Supervisor.php
vendored
Executable file → Normal file
Reference in New Issue
Block a user