protected function convertColor(Node $node, Document $document)
 {
     $color = $node->getAttribute('color');
     if ($color) {
         $node->setAttribute('color', $document->getColorFromPalette($color));
     }
     if ($node->hasAttribute('chart-colors')) {
         $colors = $node->getAttribute('chart-colors');
         foreach ($colors as $key => $color) {
             $colors[$key] = $document->getColorFromPalette($color);
         }
         $node->setAttribute('chart-colors', $colors);
     }
 }
示例#2
0
 private function setColumnMarginIfNecessary(Node $node, $marginType)
 {
     $margin = $node->getAttribute($marginType);
     $columnNumber = $node->getNumberOfColumn();
     if (!isset($this->marginsOfColumns[$marginType][$columnNumber]) || $margin > $this->marginsOfColumns[$marginType][$columnNumber]) {
         $this->marginsOfColumns[$marginType][$columnNumber] = $margin;
     }
 }
示例#3
0
 public function format(Node $node, Document $document)
 {
     $position = $node->getAttribute('list-position');
     $node->assignEnumerationStrategyFromFactory();
     if ($position === BasicList::LIST_POSITION_INSIDE) {
         $widthOfEnumerationChar = $node->getEnumerationStrategy()->getWidthOfTheBiggestPosibleEnumerationElement($document, $node);
         foreach ($node->getChildren() as $child) {
             $marginLeft = $widthOfEnumerationChar + $child->getMarginLeft();
             $child->setAttribute('margin-left', $marginLeft);
         }
     }
 }
示例#4
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);
     }
 }
 private function isLineBreak(Node $node, Node $previousSibling)
 {
     return $node->getAttribute('line-break') && $previousSibling->getAttribute('line-break');
 }
示例#6
0
 private function drawCircleBorder(GraphicsContext $gc, Node $node, Document $document)
 {
     $size = $document->convertUnit($this->size);
     $gc->setLineWidth($size);
     $point = $node->getMiddlePoint();
     $translation = $node->getPositionTranslation();
     if (!$translation->isZero()) {
         $point = $point->translate($translation->getX(), $translation->getY());
     }
     $this->drawCircle($gc, $node->getAttribute('radius'), $point->getX(), $point->getY(), GraphicsContext::SHAPE_DRAW_STROKE);
 }
 private function shouldParentBeAutomaticallyBroken(Node $node)
 {
     return $node->getAttribute('break');
 }
示例#8
0
 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;
 }
示例#9
0
 private function drawCircleBackground(GraphicsContext $gc, Node $node, Document $document)
 {
     $point = $node->getMiddlePoint();
     $translation = $node->getPositionTranslation();
     if (!$translation->isZero()) {
         $point = $point->translate($translation->getX(), $translation->getY());
     }
     $this->drawCircle($gc, $node->getAttribute('radius'), $point->getX(), $point->getY(), GraphicsContext::SHAPE_DRAW_FILL);
 }