public function format(Nodes\Node $node, Document $document)
 {
     $boundary = $node->getBoundary();
     list($x, $y) = $node->getFirstPoint()->toArray();
     $boundary->reset();
     $boundary->setNext($x, $y);
 }
 public function format(Node $node, Document $document)
 {
     $boundary = $node->getBoundary();
     list($x, $y) = $boundary->getFirstPoint()->toArray();
     list($parentX, $parentY) = $node->getParent()->getStartDrawingPoint();
     $lineSizes = $node->getLineSizes();
     $lineHeight = $node->getLineHeightRecursively();
     $startX = $x;
     $currentX = $x;
     $currentY = $y;
     foreach ($lineSizes as $rowNumber => $width) {
         $newX = $x + $width;
         $newY = $currentY - $lineHeight;
         if ($currentX !== $newX) {
             $boundary->setNext($newX, $currentY);
         }
         $boundary->setNext($newX, $newY);
         $currentX = $newX;
         $currentY = $newY;
         $x = $parentX + $node->getMarginLeft();
     }
     $boundary->setNext($x, $currentY);
     $currentY = $currentY + (count($lineSizes) - 1) * $lineHeight;
     $boundary->setNext($x, $currentY);
     $boundary->setNext($startX, $currentY);
     $boundary->close();
 }
 public function format(Node $node, Document $document)
 {
     $node->makeAttributesSnapshot(array('height', 'width'));
     $boundary = $node->getBoundary();
     if ($boundary->isClosed()) {
         return;
     }
     $parent = $node->getParent();
     list($parentX, $parentY) = $parent->getStartDrawingPoint();
     $startX = $node->getMarginLeft() + $parentX;
     $startY = $parentY - $node->getMarginTop();
     $this->setNodesPosition($node, $startX, $startY);
     $boundary->setNext($startX, $startY);
 }
 public function format(Node $node, Document $document)
 {
     $boundary = $node->getBoundary();
     $verticalMargins = $node->getMarginsBottomOfCells() + $node->getMarginsTopOfCells();
     $newHeight = $node->getMaxHeightOfCells() + $verticalMargins;
     $heightDiff = $newHeight - $node->getHeight();
     $boundary->pointTranslate(2, 0, $heightDiff)->pointTranslate(3, 0, $heightDiff);
     $node->setHeight($newHeight);
     foreach ((array) $node->getChildren() as $cell) {
         $heightDiff = $node->getMaxHeightOfCells() - $cell->getHeight();
         $cell->setHeight($node->getMaxHeightOfCells());
         $cell->getBoundary()->pointTranslate(2, 0, $heightDiff)->pointTranslate(3, 0, $heightDiff);
         $cell->translate(0, $node->getMarginsTopOfCells());
     }
 }
 public function format(Nodes\Node $node, Document $document)
 {
     $boundary = $node->getBoundary();
     if (!$boundary->isClosed()) {
         list($x, $y) = $boundary->getFirstPoint()->toArray();
         $attributesSnapshot = $node->getAttributesSnapshot();
         $diffWidth = $node->getWidth() - $attributesSnapshot['width'];
         $width = $node->getWidth();
         $x += $width;
         $yEnd = $y - $node->getHeight();
         $boundary->setNext($x, $y)->setNext($x, $yEnd)->setNext($x - $width, $yEnd)->close();
         if ($node->hadAutoMargins()) {
             $node->translate(-$diffWidth / 2, 0);
         }
     }
 }
 public function format(Node $node, Document $document)
 {
     $parent = $node->getParent();
     $boundary = $node->getBoundary();
     $boundary->setNext($parent->getFirstPoint());
 }
Beispiel #7
0
 public function format(Node $node, Document $document)
 {
     $children = $node->getChildren();
     $attributesSnapshot = $node->getAttributesSnapshot();
     $parentBottomYCoord = null;
     $positionCorrection = false;
     foreach ($children as $child) {
         $translateX = $translateY = 0;
         list($x, $y) = $child->getStartDrawingPoint();
         if ($this->hasFloat($child)) {
             $sibling = $this->getPreviousSiblingWithFloat($child, $child->getFloat());
             list($orgX, $orgY) = $child->getStartDrawingPoint();
             if (!$sibling) {
                 $previousSibling = $child->getPreviousSibling();
                 if ($previousSibling) {
                     $y = $previousSibling->getDiagonalPoint()->getY() - $previousSibling->getMarginBottom() - $child->getMarginTop() - $child->getPaddingTop();
                 }
             }
             $this->setNodesWithFloatPosition($child, $x, $y, $sibling);
             $translateX = $x - $orgX;
             $translateY = -($y - $orgY);
         } elseif ($positionCorrection) {
             $siblings = $child->getSiblings();
             $minYCoord = null;
             $previousSiblingWithMinBottomYCoord = null;
             foreach ($siblings as $sib) {
                 if ($sib === $child) {
                     break;
                 }
                 $previousSibling = $sib;
                 $bottomYCoord = $previousSibling->getDiagonalPoint()->getY() - $previousSibling->getMarginBottom();
                 if ($minYCoord === null || $bottomYCoord < $minYCoord) {
                     $minYCoord = $bottomYCoord;
                     $previousSiblingWithMinBottomYCoord = $previousSibling;
                 }
             }
             if ($minYCoord !== null) {
                 $translateY = -($minYCoord - $y - $child->getMarginTop() - $child->getPaddingTop());
                 if ($child->isInline() && $previousSiblingWithMinBottomYCoord->isInline()) {
                     $translateY -= $child instanceof Text ? $child->getLineHeightRecursively() : $child->getHeight();
                 }
             }
         }
         if ($translateX || $translateY) {
             $child->translate($translateX, $translateY);
         }
         $childBottomYCoord = $child->getDiagonalPoint()->getY() - $child->getMarginBottom();
         if ($parentBottomYCoord === null || $childBottomYCoord < $parentBottomYCoord) {
             $parentBottomYCoord = $childBottomYCoord;
         }
         if ($translateY) {
             $positionCorrection = true;
         }
     }
     if ($positionCorrection && $parentBottomYCoord && !$node->getAttribute('static-size')) {
         $parentTranslate = $node->getDiagonalPoint()->getY() - $parentBottomYCoord + $node->getPaddingBottom();
         $newHeight = $node->getHeight() + $parentTranslate;
         $oldHeight = isset($attributesSnapshot['height']) ? $attributesSnapshot['height'] : 0;
         if ($newHeight < $oldHeight) {
             $parentTranslate += $oldHeight - $newHeight;
             $newHeight = $oldHeight;
         }
         $node->setHeight($newHeight);
         $node->getBoundary()->pointTranslate(2, 0, $parentTranslate);
         $node->getBoundary()->pointTranslate(3, 0, $parentTranslate);
     }
 }
Beispiel #8
0
 private function getBoundary(Node $node)
 {
     $boundary = $this->useRealDimension ? $node->getRealBoundary() : $node->getBoundary();
     return $this->getTranslationAwareBoundary($node, $boundary);
 }