diff --git a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php index 0ff119f587cea..83edf0192f826 100644 --- a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php +++ b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php @@ -380,12 +380,19 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index 006d797f5b637..4117b0d23ff99 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -378,11 +378,18 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 3495cc5726553..ccfbe10eb1ca3 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -399,11 +399,18 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 6c68888cebc0e..bfdf38b677804 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -389,13 +389,19 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Call the ODTSubstitution hook $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 5cbba7e69f043..f6f950cdf1603 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -372,6 +372,13 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede dol_syslog($e->getMessage(), LOG_INFO); } + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + // Make substitutions into odt of user info $tmparray = $this->get_substitutionarray_user($user, $outputlangs); foreach ($tmparray as $key => $value) { @@ -379,7 +386,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede if (preg_match('/logo$/', $key)) { // Image //var_dump($value);exit; if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } @@ -397,7 +404,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede if (preg_match('/logo$/', $key)) { // Image //var_dump($value);exit; if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } @@ -419,7 +426,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } @@ -437,7 +444,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } @@ -464,7 +471,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 7b081f4d4bd20..6fcf43dd223d6 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -453,12 +453,20 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + + //var_dump($tmparray); exit; foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image //var_dump($value);exit; if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php index 6834dcfd7e768..8565ec752fa16 100644 --- a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php +++ b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php @@ -351,12 +351,20 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $mode = 'substitutionarray' => &$tmparray ); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php index 93ce87f2be5ac..40b1a53904646 100644 --- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php +++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php @@ -378,12 +378,19 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index e6f0d524747e2..63fb48978d228 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -390,11 +390,18 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index ff383d66c8106..fa732d749d128 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -651,11 +651,18 @@ public function write_file($object, $outputlangs, $srctemplatepath = '') $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index e45ce84f946d0..00bc01f449f12 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -590,11 +590,18 @@ public function write_file($object, $outputlangs, $srctemplatepath = '') $tmparray = array_merge($substitutionarray, $array_object_from_properties, $array_user, $array_soc, $array_thirdparty, $array_objet, $array_other); complete_substitutions_array($tmparray, $outputlangs, $object); + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 4e3f9adb01bba..6cd04bf9963b0 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -436,11 +436,18 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index 68b20c4597723..4b11553590bda 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -385,11 +385,19 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Call the ODTSubstitution hook $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 23626a6bb8f10..12bdc8eb8bc50 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -384,12 +384,19 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + // Replace variables into document foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index fbb1bc6428027..e382674d0942d 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -388,11 +388,18 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php index 6ec79297018c0..e201a80f60d1d 100644 --- a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php @@ -390,11 +390,18 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php index 2c26e3fb876d3..9be7d008e50e1 100644 --- a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php +++ b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php @@ -385,11 +385,18 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index b207a616be8a3..8e3e94014d2a8 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -414,11 +414,18 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php index 9dd7398e304ec..4240a55f1af3e 100644 --- a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php +++ b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php @@ -346,11 +346,19 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Call the ODTSubstitution hook $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index 07c4090460565..5cc119fe0c2c8 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -377,11 +377,19 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Call the ODTSubstitution hook $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 55015b96550ff..7309f688d2e2e 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -412,11 +412,19 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede // Call the ODTSubstitution hook $parameters = array('file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/includes/odtphp/Segment.php b/htdocs/includes/odtphp/Segment.php index 95b1c75d35c6c..e4ca91457d34a 100644 --- a/htdocs/includes/odtphp/Segment.php +++ b/htdocs/includes/odtphp/Segment.php @@ -257,10 +257,11 @@ public function setVars($key, $value, $encode = true, $charset = 'ISO-8859') * * @param string $key name of the variable within the template * @param string $value path to the picture + * @param float $ratio Ratio for image * @throws OdfException * @return Segment */ - public function setImage($key, $value) + public function setImage($key, $value, float $ratio=1) { $filename = strtok(strrchr($value, '/'), '/.'); $file = substr(strrchr($value, '/'), 1); @@ -270,8 +271,8 @@ public function setImage($key, $value) } // Set the width and height of the page list ($width, $height) = $size; - $width *= Odf::PIXEL_TO_CM; - $height *= Odf::PIXEL_TO_CM; + $width *= Odf::PIXEL_TO_CM * $ratio; + $height *= Odf::PIXEL_TO_CM * $ratio; // Fix local-aware issues (eg: 12,10 -> 12.10) $width = sprintf("%F", $width); $height = sprintf("%F", $height); diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index 5b3593f29a3f7..fd85e735c8af8 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -527,10 +527,11 @@ public function preOdfToOdf($value) * * @param string $key name of the variable within the template * @param string $value path to the picture + * @param float $ratio Ratio for image * @throws OdfException * @return odf */ - public function setImage($key, $value) + public function setImage($key, $value, float $ratio=1) { $filename = strtok(strrchr($value, '/'), '/.'); $file = substr(strrchr($value, '/'), 1); @@ -539,8 +540,8 @@ public function setImage($key, $value) throw new OdfException("Invalid image"); } list ($width, $height) = $size; - $width *= self::PIXEL_TO_CM; - $height *= self::PIXEL_TO_CM; + $width *= self::PIXEL_TO_CM * $ratio; + $height *= self::PIXEL_TO_CM * $ratio; $xml = << IMG; diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index 59ae7b1ec7130..e5cecd437e9ed 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -415,12 +415,19 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index 637ba4f0cba20..57c238c2cc3a8 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -408,12 +408,19 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede $parameters = array('odfHandler' => &$odfHandler, 'file' => $file, 'object' => $object, 'outputlangs' => $outputlangs, 'substitutionarray' => &$tmparray); $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + // retrieve the constant to apply a ratio for image size or set the ratio to 1 + if (getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')) { + $ratio = floatval(getDolGlobalString('MAIN_DOC_ODT_IMAGE_RATIO')); + } else { + $ratio = 1; + } + foreach ($tmparray as $key => $value) { try { if (preg_match('/logo$/', $key)) { // Image if (file_exists($value)) { - $odfHandler->setImage($key, $value); + $odfHandler->setImage($key, $value, $ratio); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); }