public function format(Node $node, Document $document) { $parent = $node->getParent(); if ($node->getWidth() === null && !$node->isInline() && $node->getFloat() === Node::FLOAT_NONE) { $parentWidth = $parent->getWidthWithoutPaddings(); $marginLeft = $node->getMarginLeft(); $marginRight = $node->getMarginRight(); $node->setWidth($parentWidth - ($marginLeft + $marginRight)); $node->setRelativeWidth('100%'); } elseif ($node->isInline()) { $node->setWidth(0); } if ($node->getHeight() === null) { $node->setHeight(0); } $paddingLeft = $node->getPaddingLeft(); $paddingRight = $node->getPaddingRight(); $paddingTop = $node->getPaddingTop(); $paddingBottom = $node->getPaddingBottom(); $prefferedWidth = $node->getRealWidth() + $paddingLeft + $paddingRight; $parent = $node->getParent(); $parentWidth = $parent ? $parent->getWidthWithoutPaddings() : null; if ($parent && $parentWidth < $prefferedWidth) { $prefferedWidth = $parentWidth; } $node->setWidth($prefferedWidth); $node->setHeight($node->getRealHeight() + $paddingTop + $paddingBottom); }
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(); }
private function getMaxXCoord(Node $node) { for ($parent = $node->getParent(); $parent && !$parent->getWidth(); $parent = $parent->getParent()) { } if (!$node->getWidth() && $parent && $parent->getWidth()) { $node = $parent; } return $node->getFirstPoint()->getX() + $node->getWidth() - $node->getPaddingRight(); }
private function isNodeInSameRowAsPreviousSibling(Node $node, Node $previousSibling) { $oneOfNodesIsInline = $previousSibling->isInline() && $node->isInline(); if (!$oneOfNodesIsInline) { return false; } $parent = $node->getParent(); $parentBoundary = $parent->getBoundary(); list($prevX) = $previousSibling->getEndDrawingPoint(); $endX = $prevX + $previousSibling->getMarginRight() + $node->getMarginLeft() + $node->getWidth(); $parentEndX = $parentBoundary->getFirstPoint()->getX() + $parent->getWidth(); $rowIsOverflowed = !$node instanceof Nodes\Text && $parentEndX < $endX && $previousSibling->getFloat() !== Nodes\Node::FLOAT_RIGHT; return !$rowIsOverflowed; }
private function getParentBookmarkIdentifier(Node $node) { if ($this->options['parentId']) { return $this->options['parentId']; } for ($parent = $node->getParent(); $parent !== null; $parent = $parent->getParent()) { foreach ($parent->getBehaviours() as $behaviour) { if ($behaviour instanceof Bookmark) { return $behaviour->getUniqueId(); } } } return null; }
private function setDimensionsFromParent(EngineImage $sourceImage, Node $node) { $parent = $node->getParent(); $width = $sourceImage->getOriginalWidth(); $height = $sourceImage->getOriginalHeight(); if ($width > $parent->getWidth() || $height > $parent->getHeight()) { if ($parent->getWidth() > $parent->getHeight()) { $height = $parent->getHeight(); $width = null; } else { $width = $parent->getWidth(); $height = null; } } return array($width, $height); }
protected function convertAutoMargins(Node $node) { $parent = $node->getParent(); if ($parent !== null && $this->hasAutoMargins($node)) { $parentWidth = $parent->getWidthWithoutPaddings(); $nodeWidth = $node->getWidth(); if ($nodeWidth > $parentWidth) { $parentWidth = $nodeWidth; $parent->setWidth($nodeWidth); } $node->hadAutoMargins(true); $width = $node->getWidth() === null ? $parentWidth : $node->getWidth(); //adds horizontal paddings, becouse dimension formatter hasn't executed yet $width += $node->getPaddingLeft() + $node->getPaddingRight(); $margin = ($parentWidth - $width) / 2; $node->setMarginLeft($margin); $node->setMarginRight($margin); } }
public function format(Node $node, Document $document) { $parent = $node->getParent(); $boundary = $node->getBoundary(); $boundary->setNext($parent->getFirstPoint()); }
private function correctXCoordWithParent(Node $node) { $parent = $node->getParent(); if ($node->getFloat() === Node::FLOAT_LEFT) { $preferredXCoord = $parent->getFirstPoint()->getX() + $parent->getPaddingLeft() + $node->getMarginLeft() + $node->getPaddingLeft(); } else { $preferredXCoord = $parent->getDiagonalPoint()->getX() - $node->getWidth() + $node->getPaddingLeft() - $node->getMarginRight(); } return $preferredXCoord; }
private function isOutOfPage(Node $node) { $page = $node->getParent(); if ($node->getAttribute('break')) { return true; } return $page->getDiagonalPoint()->getY() > $node->getFirstPoint()->getY() && $node->getFloat() == Node::FLOAT_NONE; }