This commit is contained in:
Laurent Destailleur
2023-10-01 17:24:25 +02:00
parent 2a49ebb114
commit 2e431468a0
2 changed files with 12 additions and 3 deletions

View File

@@ -1046,7 +1046,7 @@ class doc_generic_project_odt extends ModelePDFProjects
),
);
//Insert reference
// Insert list of objects into the project
try {
$listlines = $odfHandler->setSegment('projectrefs');
@@ -1122,6 +1122,8 @@ class doc_generic_project_odt extends ModelePDFProjects
}
$odfHandler->mergeSegment($listlines);
}
} catch (OdfExceptionSegmentNotFound $e) {
// Do nothing
} catch (OdfException $e) {
$this->error = $e->getMessage();
dol_syslog($this->error, LOG_WARNING);

View File

@@ -9,6 +9,13 @@ class OdfException extends Exception
{
}
/**
* Class of ODT Exception
*/
class OdfExceptionSegmentNotFound extends Exception
{
}
/**
* Templating class for odt file
* You need PHP 5.2 at least
@@ -662,7 +669,7 @@ IMG;
* Extract the segment and store it into $this->segments[]. Return it for next call.
*
* @param string $segment Segment
* @throws OdfException
* @throws OdfExceptionSegmentNotFound
* @return Segment
*/
public function setSegment($segment)
@@ -674,7 +681,7 @@ IMG;
$reg = "#\[!--\sBEGIN\s$segment\s--\](.*)\[!--\sEND\s$segment\s--\]#sm";
$m = array();
if (preg_match($reg, html_entity_decode($this->contentXml), $m) == 0) {
throw new OdfException("'".$segment."' segment not found in the document. The tag [!-- BEGIN xxx --] or [!-- END xxx --] is not present into content file.");
throw new OdfExceptionSegmentNotFound("'".$segment."' segment not found in the document. The tag [!-- BEGIN xxx --] or [!-- END xxx --] is not present into content file.");
}
$this->segments[$segment] = new Segment($segment, $m[1], $this);
return $this->segments[$segment];