From 89a557fc3642d799a8665f78595a0cbdb6eca208 Mon Sep 17 00:00:00 2001 From: gyalogmixi <33487866+gyalogmixi@users.noreply.github.com> Date: Sun, 10 Dec 2023 20:14:02 +0100 Subject: [PATCH] Feat(Format): rotation --- kernel/format.c | 25 +++++++++++++++++++++++++ tests/format_rotation.phpt | 31 +++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tests/format_rotation.phpt diff --git a/kernel/format.c b/kernel/format.c index 8c1787a..b257633 100644 --- a/kernel/format.c +++ b/kernel/format.c @@ -125,6 +125,10 @@ ZEND_BEGIN_ARG_INFO_EX(format_font_arginfo, 0, 0, 1) ZEND_ARG_INFO(0, font) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(format_rotation_arginfo, 0, 0, 1) + ZEND_ARG_INFO(0, angle) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(format_to_resource_arginfo, 0, 0, 0) ZEND_END_ARG_INFO() /* }}} */ @@ -479,6 +483,26 @@ PHP_METHOD(vtiful_format, borderColorOfTheFourSides) } /* }}} */ +/** {{{ \Vtiful\Kernel\Format::rotation(int $angle) + */ +PHP_METHOD(vtiful_format, rotation) +{ + zend_long angle = 0; + + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_LONG(angle) + ZEND_PARSE_PARAMETERS_END(); + + ZVAL_COPY(return_value, getThis()); + + format_object *obj = Z_FORMAT_P(getThis()); + + if (obj->ptr.format) { + format_set_rotation(obj->ptr.format, angle); + } +} +/* }}} */ + /** {{{ \Vtiful\Kernel\Format::toResource() */ PHP_METHOD(vtiful_format, toResource) @@ -508,6 +532,7 @@ zend_function_entry format_methods[] = { PHP_ME(vtiful_format, strikeout, format_strikeout_arginfo, ZEND_ACC_PUBLIC) PHP_ME(vtiful_format, underline, format_underline_arginfo, ZEND_ACC_PUBLIC) PHP_ME(vtiful_format, unlocked, format_unlocked_arginfo, ZEND_ACC_PUBLIC) + PHP_ME(vtiful_format, rotation, format_rotation_arginfo, ZEND_ACC_PUBLIC) PHP_ME(vtiful_format, toResource, format_to_resource_arginfo, ZEND_ACC_PUBLIC) PHP_ME(vtiful_format, background, format_background_arginfo, ZEND_ACC_PUBLIC) PHP_FE_END diff --git a/tests/format_rotation.phpt b/tests/format_rotation.phpt new file mode 100644 index 0000000..f7f8343 --- /dev/null +++ b/tests/format_rotation.phpt @@ -0,0 +1,31 @@ +--TEST-- +Check for vtiful presence +--SKIPIF-- + +--FILE-- + './tests' +]; + +$fileObject = new \Vtiful\Kernel\Excel($config); + +$fileObject = $fileObject->fileName('format_rotation.xlsx'); +$fileHandle = $fileObject->getHandle(); + +$format = new \Vtiful\Kernel\Format($fileHandle); +$rotationStyle = $format->rotation(30)->toResource(); + +$fileObject->insertText(0, 0, 'viest', null, $rotationStyle); +$fileObject->insertText(0, 1, 'wjx'); + +$filePath = $fileObject->output(); + +var_dump($filePath); +?> +--CLEAN-- + +--EXPECT-- +string(28) "./tests/format_rotation.xlsx"