Skip to content

Commit 89a557f

Browse files
committed
Feat(Format): rotation
1 parent 54c3e07 commit 89a557f

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

kernel/format.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ ZEND_BEGIN_ARG_INFO_EX(format_font_arginfo, 0, 0, 1)
125125
ZEND_ARG_INFO(0, font)
126126
ZEND_END_ARG_INFO()
127127

128+
ZEND_BEGIN_ARG_INFO_EX(format_rotation_arginfo, 0, 0, 1)
129+
ZEND_ARG_INFO(0, angle)
130+
ZEND_END_ARG_INFO()
131+
128132
ZEND_BEGIN_ARG_INFO_EX(format_to_resource_arginfo, 0, 0, 0)
129133
ZEND_END_ARG_INFO()
130134
/* }}} */
@@ -479,6 +483,26 @@ PHP_METHOD(vtiful_format, borderColorOfTheFourSides)
479483
}
480484
/* }}} */
481485

486+
/** {{{ \Vtiful\Kernel\Format::rotation(int $angle)
487+
*/
488+
PHP_METHOD(vtiful_format, rotation)
489+
{
490+
zend_long angle = 0;
491+
492+
ZEND_PARSE_PARAMETERS_START(1, 1)
493+
Z_PARAM_LONG(angle)
494+
ZEND_PARSE_PARAMETERS_END();
495+
496+
ZVAL_COPY(return_value, getThis());
497+
498+
format_object *obj = Z_FORMAT_P(getThis());
499+
500+
if (obj->ptr.format) {
501+
format_set_rotation(obj->ptr.format, angle);
502+
}
503+
}
504+
/* }}} */
505+
482506
/** {{{ \Vtiful\Kernel\Format::toResource()
483507
*/
484508
PHP_METHOD(vtiful_format, toResource)
@@ -508,6 +532,7 @@ zend_function_entry format_methods[] = {
508532
PHP_ME(vtiful_format, strikeout, format_strikeout_arginfo, ZEND_ACC_PUBLIC)
509533
PHP_ME(vtiful_format, underline, format_underline_arginfo, ZEND_ACC_PUBLIC)
510534
PHP_ME(vtiful_format, unlocked, format_unlocked_arginfo, ZEND_ACC_PUBLIC)
535+
PHP_ME(vtiful_format, rotation, format_rotation_arginfo, ZEND_ACC_PUBLIC)
511536
PHP_ME(vtiful_format, toResource, format_to_resource_arginfo, ZEND_ACC_PUBLIC)
512537
PHP_ME(vtiful_format, background, format_background_arginfo, ZEND_ACC_PUBLIC)
513538
PHP_FE_END

tests/format_rotation.phpt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
--TEST--
2+
Check for vtiful presence
3+
--SKIPIF--
4+
<?php if (!extension_loaded("xlswriter")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
$config = [
8+
'path' => './tests'
9+
];
10+
11+
$fileObject = new \Vtiful\Kernel\Excel($config);
12+
13+
$fileObject = $fileObject->fileName('format_rotation.xlsx');
14+
$fileHandle = $fileObject->getHandle();
15+
16+
$format = new \Vtiful\Kernel\Format($fileHandle);
17+
$rotationStyle = $format->rotation(30)->toResource();
18+
19+
$fileObject->insertText(0, 0, 'viest', null, $rotationStyle);
20+
$fileObject->insertText(0, 1, 'wjx');
21+
22+
$filePath = $fileObject->output();
23+
24+
var_dump($filePath);
25+
?>
26+
--CLEAN--
27+
<?php
28+
@unlink(__DIR__ . '/format_rotation.xlsx');
29+
?>
30+
--EXPECT--
31+
string(28) "./tests/format_rotation.xlsx"

0 commit comments

Comments
 (0)