mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
This commit is contained in:
@@ -27,7 +27,7 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
var $_oldFontStyle;
|
||||
var $_oldColor;
|
||||
var $_buffer;
|
||||
|
||||
|
||||
function initDefaultAttributes($node) {
|
||||
//read attributes
|
||||
$this->initLocalAttribute($node, "border-top-style");
|
||||
@@ -57,7 +57,7 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
$this->initLocalSizeAttribute($node, "space-before.optimum");
|
||||
$this->initLocalSizeAttribute($node, "space-after.optimum");
|
||||
$this->initLocalAttribute($node, "break-before");
|
||||
$this->initLocalAttribute($node, "break-after");
|
||||
$this->initLocalAttribute($node, "break-after");
|
||||
$this->initSizeAttribute($node, "line-height");
|
||||
$this->initLocalSizeAttribute($node, "padding-top");
|
||||
//$this->initLocalSizeAttribute($node, "padding-bottom");
|
||||
@@ -71,61 +71,64 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
//echo str_replace('EURO',chr(128),utf8_decode($str));
|
||||
return str_replace('EURO',chr(128),utf8_decode($str));
|
||||
}
|
||||
|
||||
function parse(DOMNode $node) {
|
||||
|
||||
function parse(DOMNode $node)
|
||||
{
|
||||
//set default attributes
|
||||
$this->initDefaultAttributes($node);
|
||||
$this->initAttributes($node);
|
||||
$this->initialize();
|
||||
$acceptPageBreak = $this->getContext("acceptPageBreak");
|
||||
|
||||
|
||||
$pos = $this->getPosition();
|
||||
list($x, $y, $width, $height) = $pos[0];
|
||||
list($xOrig, $yOrig, $width, $height) = $pos[1];
|
||||
|
||||
//automatic page break if component exceeds page limits
|
||||
$pdf = $this->getPdf();
|
||||
if ($yOrig > $pdf->PageBreakTrigger &&
|
||||
$pdf->AcceptPageBreak() &&
|
||||
$acceptPageBreak) {
|
||||
$pdf->AddPage();
|
||||
$this->handleEvent("sync-position");
|
||||
$this->parse($node);
|
||||
return;
|
||||
if ($yOrig > $pdf->PageBreakTrigger && $pdf->AcceptPageBreak() && $acceptPageBreak)
|
||||
{
|
||||
$pdf->AddPage();
|
||||
$this->handleEvent("sync-position");
|
||||
$this->parse($node);
|
||||
return;
|
||||
}
|
||||
|
||||
//update to inner position
|
||||
$this->setContext("x", $x);
|
||||
$this->setContext("y", $y);
|
||||
|
||||
|
||||
//draw us
|
||||
$this->setColor();
|
||||
$this->setFont();
|
||||
$this->setFont();
|
||||
|
||||
$this->startCapture();
|
||||
foreach($node->childNodes as $child) {
|
||||
if ($child->nodeType == self::NODE_TYPE_TEXT) {
|
||||
$this->preParseContent($child->textContent);
|
||||
//oesi - add function utf8_decode for special chars (umlaut)
|
||||
$this->processContent($this->convert($child->nodeValue));
|
||||
$this->postParseContent($child->textContent);
|
||||
}
|
||||
else {
|
||||
$this->processChildNode($child, $this->getChildNodes());
|
||||
}
|
||||
}
|
||||
|
||||
foreach($node->childNodes as $child)
|
||||
{
|
||||
if ($child->nodeType == self::NODE_TYPE_TEXT)
|
||||
{
|
||||
$this->preParseContent($child->textContent);
|
||||
//oesi - add function utf8_decode for special chars (umlaut)
|
||||
$this->processContent($this->convert($child->nodeValue));
|
||||
$this->postParseContent($child->textContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->processChildNode($child, $this->getChildNodes());
|
||||
}
|
||||
}
|
||||
|
||||
//oesi - hack for ExternalGraphic Tag to show without content
|
||||
if($this instanceof FO_ExternalGraphic)
|
||||
$this->processContent('');
|
||||
//endhack
|
||||
|
||||
$contentBuffer = $this->endCapture();
|
||||
|
||||
$contentBuffer = $this->endCapture();
|
||||
|
||||
//update to outer position
|
||||
$this->setContext("x", $xOrig);
|
||||
$this->setContext("y", $yOrig);
|
||||
|
||||
|
||||
//recalc positions
|
||||
$pos2 = $this->getPosition();
|
||||
//merge with X and y values of the original psoition
|
||||
@@ -136,17 +139,17 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
|
||||
//automatic page break if component exceeds page limits
|
||||
$pdf = $this->getPdf();
|
||||
if ($pos2[1][3] < $pdf->PageBreakTrigger &&
|
||||
$pos2[1][3]+$this->getContext("y") > $pdf->PageBreakTrigger &&
|
||||
if ($pos2[1][3] < $pdf->PageBreakTrigger &&
|
||||
$pos2[1][3]+$this->getContext("y") > $pdf->PageBreakTrigger &&
|
||||
$pdf->AcceptPageBreak() && $acceptPageBreak) {
|
||||
$pdf->AddPage();
|
||||
$this->handleEvent("sync-position");
|
||||
$this->parse($node);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$this->drawBordersAndBackground($pos2);
|
||||
|
||||
|
||||
//update to outer positions
|
||||
$this->setLocalContext("width", $pos2[1][2]);
|
||||
$this->setLocalContext("height", $pos2[1][3]);
|
||||
@@ -166,10 +169,10 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
|
||||
function preParseContent($content) {
|
||||
}
|
||||
|
||||
|
||||
function postParseContent($textcontent) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Draw borders and backgrounds according to the positions
|
||||
* May be overwritten to specify behaviour
|
||||
@@ -177,7 +180,7 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
function drawBordersAndBackground($pos) {
|
||||
list($x, $y, $width, $height) = $pos[1];
|
||||
$this->drawBackground($x, $y, $width, $height);
|
||||
$this->drawBorders($x, $y, $width, $height);
|
||||
$this->drawBorders($x, $y, $width, $height);
|
||||
}
|
||||
|
||||
function getChildNodes() {
|
||||
@@ -188,12 +191,12 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
function initialize() {
|
||||
$break_before = $this->getContext("break-before");
|
||||
$this->handleBreak($break_before);
|
||||
}
|
||||
}
|
||||
|
||||
function closeDown() {
|
||||
$pdf = $this->getPdf();
|
||||
if ($this->_oldFont) {
|
||||
$pdf->SetFont($this->_oldFont, $this->_oldFontStyle,
|
||||
$pdf->SetFont($this->_oldFont, $this->_oldFontStyle,
|
||||
$this->_oldFontSize);
|
||||
}
|
||||
else if ($this->_oldFontSize) {
|
||||
@@ -207,7 +210,7 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
$space_after = $this->getContext("space-after.optimum");
|
||||
// echo "Space-after:".$space_after.":".get_class($this).":".$this->getContext("height")."<br>";
|
||||
if ($space_after) {
|
||||
$this->setLocalContext("height", $this->getContext("height") +
|
||||
$this->setLocalContext("height", $this->getContext("height") +
|
||||
$space_after);
|
||||
}
|
||||
$break_after = $this->getContext("break-after");
|
||||
@@ -223,9 +226,9 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
}
|
||||
|
||||
function endCapture() {
|
||||
if (!$this->_buffer) {
|
||||
if (!$this->_buffer) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
$partBuffer = $this->getPdf()->endCapture($this->_buffer);
|
||||
$this->_buffer = NULL;
|
||||
return $partBuffer;
|
||||
@@ -240,23 +243,23 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
}
|
||||
|
||||
function getPosition() {
|
||||
$space_before = $this->getContext("space-before.optimum");
|
||||
$space_before = $this->getContext("space-before.optimum");
|
||||
$height = $this->getContext("line-height");
|
||||
$pdf = $this->getPdf();
|
||||
|
||||
$pdf = $this->getPdf();
|
||||
|
||||
$bw_top = $this->getContext("border-top-width");
|
||||
$bw_left = $this->getContext("border-left-width");
|
||||
$bw_right = $this->getContext("border-right-width");
|
||||
$bw_bottom = $this->getContext("border-bottom-width");
|
||||
$padding_left = $this->getContext("padding-left");
|
||||
$padding_top = $this->getContext("padding-top");
|
||||
$bw_bottom = $this->getContext("border-bottom-width");
|
||||
$padding_left = $this->getContext("padding-left");
|
||||
$padding_top = $this->getContext("padding-top");
|
||||
|
||||
$bw = $this->getContext("border-width");
|
||||
$xx = $this->getContext("x");
|
||||
$yy = $this->getContext("y");
|
||||
|
||||
$height2 = $this->getContext("height");
|
||||
if (!$height || $height < $height2) {
|
||||
$height2 = $this->getContext("height");
|
||||
if (!$height || $height < $height2) {
|
||||
$height = $height2;
|
||||
}
|
||||
$width = $this->getContext("width");
|
||||
@@ -264,7 +267,7 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
if (!$bw_bottom) {$bw_bottom = $bw;}
|
||||
if (!$bw_right) {$bw_right = $bw;}
|
||||
if (!$bw_left) {$bw_left = $bw;}
|
||||
|
||||
|
||||
sscanf($bw_top, "%f%s", $wt, $unit);
|
||||
sscanf($bw_left, "%f%s", $wl, $unit);
|
||||
sscanf($bw_right, "%f%s", $wr, $unit);
|
||||
@@ -273,7 +276,7 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
$yy += $wt;
|
||||
$height += $wt+$wb;
|
||||
$width += $wl+$wr;
|
||||
|
||||
|
||||
if ($space_before) {
|
||||
//echo "Spacebefore:$space_before<br>";
|
||||
$yy += $space_before;
|
||||
@@ -286,27 +289,27 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
$yy += $padding_top;
|
||||
}
|
||||
|
||||
return
|
||||
return
|
||||
array(
|
||||
//inner coordinates
|
||||
array($xx, $yy, $width-$wl-$wr, $height-$wt-$wb),
|
||||
array($xx, $yy, $width-$wl-$wr, $height-$wt-$wb),
|
||||
//outer coordinates
|
||||
array($xx-$wl, $yy-$wr, $width, $height));
|
||||
array($xx-$wl, $yy-$wr, $width, $height));
|
||||
}
|
||||
|
||||
|
||||
function setColor() {
|
||||
$pdf = $this->getPdf();
|
||||
$this->_oldColor = $pdf->GetTextColor();
|
||||
$color = $this->getContext("color");
|
||||
$color = $this->getContext("color");
|
||||
if ($color) {
|
||||
$this->setTextColor($color, $pdf);
|
||||
}
|
||||
}
|
||||
|
||||
function setFont() {
|
||||
$pdf = $this->getPdf();
|
||||
$pdf = $this->getPdf();
|
||||
$this->_oldFont = $pdf->GetFontFamily();
|
||||
$this->_oldFontStyle = $pdf->GetFontStyle();
|
||||
$this->_oldFontStyle = $pdf->GetFontStyle();
|
||||
$this->_oldFontSize = $pdf->GetFontSizePt();
|
||||
$weight = $this->getContext("font-weight");
|
||||
$style = $this->getContext("font-style");
|
||||
@@ -317,7 +320,7 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
}
|
||||
else {
|
||||
$f = $this->_oldFont;
|
||||
}
|
||||
}
|
||||
if ($weight || $style) {
|
||||
if ($weight) {
|
||||
$st = "B";
|
||||
@@ -325,7 +328,7 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
if ($style) {
|
||||
//TODO: check which styles are supported
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$st = $this->_oldFontStyle;
|
||||
}
|
||||
@@ -334,13 +337,13 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
}
|
||||
else {
|
||||
$sz = $this->_oldFontSize;
|
||||
}
|
||||
if ($pdf->FontExists($f, $st)) {
|
||||
}
|
||||
if ($pdf->FontExists($f, $st)) {
|
||||
$pdf->SetFont($f, $st, $sz);
|
||||
}
|
||||
else if ($pdf->FontExists($this->_oldFont, $st)) {
|
||||
else if ($pdf->FontExists($this->_oldFont, $st)) {
|
||||
$pdf->SetFont($this->_oldFont, $st, $sz);
|
||||
}
|
||||
}
|
||||
else {
|
||||
//adjust only size
|
||||
$pdf->SetFontSize($sz);
|
||||
@@ -356,14 +359,14 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
$bc_top = $this->getContext("border-top-color");
|
||||
$bc_left = $this->getContext("border-left-color");
|
||||
$bc_right = $this->getContext("border-right-color");
|
||||
$bc_bottom = $this->getContext("border-bottom-color");
|
||||
$bc = $this->getContext("border-color");
|
||||
$bc_bottom = $this->getContext("border-bottom-color");
|
||||
$bc = $this->getContext("border-color");
|
||||
$bw_top = $this->getContext("border-top-width");
|
||||
$bw_left = $this->getContext("border-left-width");
|
||||
$bw_right = $this->getContext("border-right-width");
|
||||
$bw_bottom = $this->getContext("border-bottom-width");
|
||||
$bw_bottom = $this->getContext("border-bottom-width");
|
||||
$bw = $this->getContext("border-width");
|
||||
|
||||
|
||||
$pdf = $this->getPdf();
|
||||
if (!$bs_top) {$bs_top = $bs;}
|
||||
if (!$bs_bottom) {$bs_bottom = $bs;}
|
||||
@@ -382,7 +385,7 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
sscanf($bw_left, "%f%s", $wl, $unit);
|
||||
sscanf($bw_right, "%f%s", $wr, $unit);
|
||||
sscanf($bw_bottom, "%f%s", $wb, $unit);
|
||||
$wt /= 2;
|
||||
$wt /= 2;
|
||||
$wl /= 2;
|
||||
$wr /= 2;
|
||||
$wb /= 2;
|
||||
@@ -391,13 +394,13 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
$height -= $wt+$wb;
|
||||
$x += $wl;
|
||||
$y += $wt;
|
||||
$this->drawLine($x, $y, $x+$width, $y, $bs_top, $bc_top,
|
||||
$this->drawLine($x, $y, $x+$width, $y, $bs_top, $bc_top,
|
||||
$bw_top, $pdf);
|
||||
$this->drawLine($x, $y, $x, $y+$height, $bs_left,
|
||||
$this->drawLine($x, $y, $x, $y+$height, $bs_left,
|
||||
$bc_left, $bw_left,$pdf);
|
||||
$this->drawLine($x, $y+$height, $x+$width, $y+$height,
|
||||
$this->drawLine($x, $y+$height, $x+$width, $y+$height,
|
||||
$bs_bottom, $bc_bottom, $bw_bottom, $pdf);
|
||||
$this->drawLine($x+$width, $y, $x+$width, $y+$height,
|
||||
$this->drawLine($x+$width, $y, $x+$width, $y+$height,
|
||||
$bs_right, $bc_right,$bw_right, $pdf);
|
||||
}
|
||||
|
||||
@@ -412,12 +415,12 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
$pdf->Rect($x, $y, $width, $height, "F");
|
||||
list($r, $g, $b) = $this->parseColor($oldColor);
|
||||
$pdf->SetFillColor($r, $g, $b);
|
||||
}
|
||||
}
|
||||
else if ($bg_img) {
|
||||
$this->NotYetSupported("background-image");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function drawLine($x, $y, $x2, $y2, $style, $color, $width, &$pdf) {
|
||||
$oldColor = $pdf->GetDrawColor();
|
||||
$oldLineWidth = $pdf->GetLineWidth();
|
||||
@@ -459,20 +462,20 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
function setDrawColor($color, &$pdf) {
|
||||
if ($color == '') {
|
||||
return;
|
||||
}
|
||||
list($r, $g, $b) = $this->parseColor($color);
|
||||
}
|
||||
list($r, $g, $b) = $this->parseColor($color);
|
||||
$pdf->SetDrawColor($r, $g, $b);
|
||||
}
|
||||
|
||||
function setTextColor($color, &$pdf) {
|
||||
if ($color == '') {
|
||||
return;
|
||||
}
|
||||
list($r, $g, $b) = $this->parseColor($color);
|
||||
}
|
||||
list($r, $g, $b) = $this->parseColor($color);
|
||||
$pdf->SetTextColor($r, $g, $b);
|
||||
}
|
||||
}
|
||||
|
||||
function handleBreak($break) {
|
||||
function handleBreak($break) {
|
||||
if (!$break) {
|
||||
return;
|
||||
}
|
||||
@@ -480,11 +483,11 @@ class FO_LayoutObject extends FO_FlowContainer {
|
||||
switch($break) {
|
||||
case "page":
|
||||
$pdf->AddPage();
|
||||
$this->handleEvent("sync-position");
|
||||
$this->handleEvent("sync-position");
|
||||
return;
|
||||
default:
|
||||
$this->NotYetSupported("Break:$break");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,7 +504,7 @@ class FO_PageSequence extends FO_Object {
|
||||
static $CHILDNODES = array(
|
||||
'FO_Flow'
|
||||
);
|
||||
|
||||
|
||||
function parse(DOMNode $node) {
|
||||
$masterRef = $node->attributes->getNamedItem("master-reference");
|
||||
if ($masterRef) {
|
||||
@@ -512,7 +515,7 @@ class FO_PageSequence extends FO_Object {
|
||||
$pdf->AddPage();
|
||||
$this->handleEvent("sync-position");
|
||||
$this->processChildNodes($node, self::$CHILDNODES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FO_FlowContainer extends FO_Object {
|
||||
@@ -521,20 +524,20 @@ class FO_FlowContainer extends FO_Object {
|
||||
$acceptPageBreak = $this->getContext("acceptPageBreak");
|
||||
$this->setLocalContext("width", $obj->getContext("width"));
|
||||
$height = $this->getContext("height")+$obj->getContext("height");
|
||||
$this->setLocalContext("height", $height);
|
||||
$this->setLocalContext("height", $height);
|
||||
$y = $this->getContext("y")+$obj->getContext("height");
|
||||
$pdf = $this->getPdf();
|
||||
if ($height < $pdf->PageBreakTrigger &&
|
||||
$y > $pdf->PageBreakTrigger &&
|
||||
$pdf->AcceptPageBreak() &&
|
||||
if ($height < $pdf->PageBreakTrigger &&
|
||||
$y > $pdf->PageBreakTrigger &&
|
||||
$pdf->AcceptPageBreak() &&
|
||||
$acceptPageBreak) {
|
||||
|
||||
$pdf->AddPage();
|
||||
$this->handleEvent("sync-position");
|
||||
//echo "Page break on .".get_class($obj)."<br>";
|
||||
}
|
||||
else {
|
||||
$this->setContext("y", $y);
|
||||
else {
|
||||
$this->setContext("y", $y);
|
||||
//echo "Move :".get_class($obj).":".$y.":".$obj->getContext("height")."<br>;";
|
||||
}
|
||||
}
|
||||
@@ -552,7 +555,7 @@ class FO_Flow extends FO_FlowContainer {
|
||||
function parse(DOMNode $node) {
|
||||
//TODO: use attributes
|
||||
$this->processChildNodes($node, self::$CHILDNODES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class FO_BlockContainer extends FO_LayoutObject {
|
||||
@@ -570,7 +573,7 @@ class FO_BlockContainer extends FO_LayoutObject {
|
||||
$this->initLocalSizeAttribute($node, "height");
|
||||
$this->initLocalSizeAttribute($node, "width");
|
||||
}
|
||||
|
||||
|
||||
function getChildNodes() {
|
||||
return self::$CHILDNODES;
|
||||
}
|
||||
@@ -592,7 +595,7 @@ class FO_BlockContainer extends FO_LayoutObject {
|
||||
}
|
||||
|
||||
class FO_ListBlock extends FO_LayoutObject {
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
$dont_sync_php=array('11','91','92','94','145','182','203','204','222','227','228','254','255','256','257','258','297','298','299','301','302','308','327','328','329','333','334','335','336','332','476','999');
|
||||
//'300','303','330','331'
|
||||
$dont_sync_php=array('11','91','92','94','145','182','203','204','222','227','228','254','255','256','257','258','297','298','299','300','301','302','308','327','328','329','330','331','333','334','335','336','332','476','999');
|
||||
//'303'
|
||||
|
||||
function dont_sync_sql($dont_sync_php)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user