|
@@ -25,7 +25,6 @@ class OdfExceptionSegmentNotFound extends Exception
|
|
|
* @copyright 2010-2015 - Laurent Destailleur - eldy@users.sourceforge.net
|
|
|
* @copyright 2010 - Vikas Mahajan - http://vikasmahajan.wordpress.com
|
|
|
* @copyright 2012 - Stephen Larroque - lrq3000@gmail.com
|
|
|
- * @copyright 2023 - Thomas Negre - contact@open-dsi.fr
|
|
|
* @license https://www.gnu.org/copyleft/gpl.html GPL License
|
|
|
* @version 1.5.0
|
|
|
*/
|
|
@@ -54,7 +53,7 @@ class Odf
|
|
|
public $userdefined=array();
|
|
|
|
|
|
const PIXEL_TO_CM = 0.026458333;
|
|
|
- const FIND_TAGS_REGEX = '/<([A-Za-z0-9]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/';
|
|
|
+ const FIND_TAGS_REGEX = '/<([A-Za-z0-9]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/s';
|
|
|
const FIND_ENCODED_TAGS_REGEX = '/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/';
|
|
|
|
|
|
|
|
@@ -227,14 +226,14 @@ class Odf
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Replaces html tags in with odt tags and returns an odt string. Encodes and converts inner text.
|
|
|
+ * Replaces html tags in with odt tags and returns an odt string. Encodes and converts inner text.
|
|
|
* @param array $tags An array with html tags generated by the getDataFromHtml() function
|
|
|
* @param array $customStyles An array of style defenitions that should be included inside the odt file
|
|
|
* @param array $fontDeclarations An array of font declarations that should be included inside the odt file
|
|
|
* @param bool $encode If true, special XML characters are encoded
|
|
|
* @param string $charset Charset. See encode_chars()
|
|
|
- * @return string
|
|
|
- */
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
private function _replaceHtmlWithOdtTag($tags, &$customStyles, &$fontDeclarations, $encode = false, $charset = '')
|
|
|
{
|
|
|
if ($customStyles == null) $customStyles = array();
|
|
@@ -325,7 +324,7 @@ class Odf
|
|
|
* @param string $text The text to encode or not
|
|
|
* @param bool $encode If true, special XML characters are encoded
|
|
|
* @param string $charset Charset
|
|
|
- * @return string The converted text
|
|
|
+ * @return string The converted text
|
|
|
* @see self::convertVarToOdf()
|
|
|
*/
|
|
|
private function encode_chars($text, $encode = false, $charset = '')
|
|
@@ -335,15 +334,15 @@ class Odf
|
|
|
return $newtext;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Checks if the given text is a html string
|
|
|
- * @param string $text The text to check
|
|
|
- * @return bool
|
|
|
- */
|
|
|
- private function _isHtmlTag($text)
|
|
|
+ /**
|
|
|
+ * Checks if the given text is a html string
|
|
|
+ * @param string $text The text to check
|
|
|
+ * @return bool
|
|
|
+ */
|
|
|
+ private function _isHtmlTag($text)
|
|
|
{
|
|
|
- return preg_match(self::FIND_TAGS_REGEX, $text);
|
|
|
- }
|
|
|
+ return preg_match(self::FIND_TAGS_REGEX, $text);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* Checks if the given text includes a html string
|
|
@@ -537,10 +536,10 @@ IMG;
|
|
|
$balise = str_replace('row.', '', $matches2[1]);
|
|
|
// Move segment tags around the row
|
|
|
$replace = array(
|
|
|
- '[!-- BEGIN ' . $matches2[1] . ' --]' => '',
|
|
|
- '[!-- END ' . $matches2[1] . ' --]' => '',
|
|
|
- '<table:table-row' => '[!-- BEGIN ' . $balise . ' --]<table:table-row',
|
|
|
- '</table:table-row>' => '</table:table-row>[!-- END ' . $balise . ' --]'
|
|
|
+ '[!-- BEGIN ' . $matches2[1] . ' --]' => '',
|
|
|
+ '[!-- END ' . $matches2[1] . ' --]' => '',
|
|
|
+ '<table:table-row' => '[!-- BEGIN ' . $balise . ' --]<table:table-row',
|
|
|
+ '</table:table-row>' => '</table:table-row>[!-- END ' . $balise . ' --]'
|
|
|
);
|
|
|
$replacedXML = str_replace(array_keys($replace), array_values($replace), $matches[0][$i]);
|
|
|
$this->contentXml = str_replace($matches[0][$i], $replacedXML, $this->contentXml);
|
|
@@ -583,10 +582,10 @@ IMG;
|
|
|
$reg = '@(\[!--\sELSE\s' . $key . '\s--\](.*))?\[!--\sENDIF\s' . $key . '\s--\]@smU'; // U modifier = all quantifiers are non-greedy
|
|
|
$this->contentXml = preg_replace($reg, '', $this->contentXml);
|
|
|
/*if ($sav != $this->contentXml)
|
|
|
- {
|
|
|
- dol_syslog("We found a IF and it was processed");
|
|
|
- //var_dump($sav);exit;
|
|
|
- }*/
|
|
|
+ {
|
|
|
+ dol_syslog("We found a IF and it was processed");
|
|
|
+ //var_dump($sav);exit;
|
|
|
+ }*/
|
|
|
} else {
|
|
|
// Else the value is false, then two cases: no ELSE and we're done, or there is at least one place where there is an ELSE clause, then we replace it
|
|
|
|
|
@@ -601,10 +600,10 @@ IMG;
|
|
|
// Cleanup the other conditional blocks (all the others where there were no ELSE clause, we can just remove them altogether)
|
|
|
$this->contentXml = preg_replace($reg, '', $this->contentXml);
|
|
|
/*if ($sav != $this->contentXml)
|
|
|
- {
|
|
|
- dol_syslog("We found a IF and it was processed");
|
|
|
- //var_dump($sav);exit;
|
|
|
- }*/
|
|
|
+ {
|
|
|
+ dol_syslog("We found a IF and it was processed");
|
|
|
+ //var_dump($sav);exit;
|
|
|
+ }*/
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1025,4 +1024,4 @@ IMG;
|
|
|
$this->contentXml = preg_replace($searchreg, "", $this->contentXml);
|
|
|
return $matches[1];
|
|
|
}
|
|
|
-}
|
|
|
+}
|