Beispiel #1
0
 /**
  * Programming note: some properties set in parsing may not necessarily be of use at this time
  * @param DOMElement $node
  */
 public function parse(DOMElement $node)
 {
     parent::parse($node);
     $this->UID = $node->hasAttribute(IdmlAttributes::Self) ? $node->getAttribute(IdmlAttributes::Self) : null;
     $this->setTransform($node);
     $this->vertices = $this->parseVertices($node);
     if (count($this->vertices) < 2) {
         $this->visible = false;
         $this->boundary = new IdmlBoundary(0, 0, 0, 0);
         return;
     }
     $this->boundary = $this->setBoundary($this->vertices);
     $this->inline = get_class($this->parentElement) == 'IdmlCharacterRange' ? true : false;
     $visible = $node->hasAttribute(IdmlAttributes::Visible) ? $node->getAttribute(IdmlAttributes::Visible) : 'true';
     $this->visible = strtolower($visible) == 'true' ? true : false;
     $ffiList = $node->getElementsByTagName('FrameFittingOption');
     if ($ffiList->length > 0) {
         $ffiNode = $ffiList->item(0);
         $topCrop = $ffiNode->hasAttribute(IdmlAttributes::TopCrop) ? $ffiNode->getAttribute(IdmlAttributes::TopCrop) : 0;
         $leftCrop = $ffiNode->hasAttribute(IdmlAttributes::LeftCrop) ? $ffiNode->getAttribute(IdmlAttributes::LeftCrop) : 0;
         $bottomCrop = $ffiNode->hasAttribute(IdmlAttributes::BottomCrop) ? $ffiNode->getAttribute(IdmlAttributes::BottomCrop) : 0;
         $rightCrop = $ffiNode->hasAttribute(IdmlAttributes::RightCrop) ? $ffiNode->getAttribute(IdmlAttributes::RightCrop) : 0;
         $this->frameFittingOption = new IdmlFrameFitting($topCrop, $leftCrop, $bottomCrop, $rightCrop);
     }
     $this->parseChildren($node);
 }
Beispiel #2
0
 public function parse(DOMElement $node)
 {
     parent::parse($node);
     $this->headerRowCount = $node->hasAttribute('HeaderRowCount') ? intval($node->getAttribute('HeaderRowCount')) : 0;
     $this->footerRowCount = $node->hasAttribute('FooterRowCount') ? intval($node->getAttribute('FooterRowCount')) : 0;
     $this->bodyRowCount = $node->hasAttribute('BodyRowCount') ? intval($node->getAttribute('BodyRowCount')) : 0;
     $this->columnCount = $node->hasAttribute('ColumnCount') ? intval($node->getAttribute('ColumnCount')) : 0;
     $this->parseChildren($node);
 }
 /**
  * Parse from DOM node.
  *
  * @param DOMElement $node
  */
 public function parse(DOMElement $node)
 {
     parent::parse($node);
     $hyperlinkMgr = IdmlHyperlinkManager::getInstance();
     // Set the id attribute value
     $destinationKey = $this->contextualStyle->idmlKeyValues['DestinationUniqueKey'];
     $this->id = 'Hyperlink_' . $destinationKey;
     // Save this destination in the hyperlink manager.
     // After parsing the page completes, its id must be stored for all the hyperlink destinations on the page.
     $hyperlinkMgr->saveDestinationForPageData($this->id);
 }
Beispiel #4
0
 /**
  * Parse from DOM node.
  *
  * @param DOMElement $node
  */
 public function parse(DOMElement $node)
 {
     parent::parse($node);
     $this->markupTag = $node->hasAttribute('MarkupTag') ? $node->getAttribute('MarkupTag') : '';
     $this->idAttribute = $node->hasAttribute(IdmlAttributes::Self) ? $node->getAttribute(IdmlAttributes::Self) : null;
     $this->xmlContent = $node->hasAttribute(IdmlAttributes::XmlContent) ? $node->getAttribute(IdmlAttributes::XmlContent) : null;
     //don't parse children of this tag if they are marked to be hidden from Chaucer (CHAUC-2866)
     if ($this->markupTag != 'XMLTag/ChaucerHidden') {
         $this->parseChildren($node);
         $this->parseAttributes($node);
     }
 }
Beispiel #5
0
 /**
  * Parse from DOM node.
  * @param DOMElement $node
  */
 public function parse(DOMElement $node)
 {
     parent::parse($node);
     //        $this->styleInfo['inlineStyle']->translateSingleColumnWidth(); //set Css width for column
     /*
             if($this->hasIdmlProperty('SingleColumnWidth'))
             {
                 $val = $this->getIdmlProperty('SingleColumnWidth');
                 if(is_numeric($val))
                 {
                     $val = round($val);
                     $this->addCssProperty('width', $val . 'pt');
                 }
             }
     */
     /*
             //add needed column info to parent table because IdmlHtmlProducer needs this at the IdmlTable element level
             if($this->styleInfo["inlineStyle"]->hasCssProperty('width'))
             {
                 $table = $this->parentIdmlObject();
                 if(IdmlParserHelper::getIdmlObjectType($table) == "Table")
                 {
                     $table->cols[] = $this;
                     $colwidth = $this->styleInfo["inlineStyle"]->getCssPropertyString('width');
                     if($colwidth) {
                         $table->colGroupStyles[] = $colwidth;
                     }
                 }
             }
             else
             {
                 CakeLog::debug("[IdmlTableColumn::parse] column width not found? ".__FILE__." Line ".__LINE__);
             }
     */
     if ($node->hasAttribute('SingleColumnWidth')) {
         $singleColumnWidth = round($node->getAttribute('SingleColumnWidth'));
         $table = $this->parentIdmlObject();
         if (IdmlParserHelper::getIdmlObjectType($table) == "Table") {
             $table->cols[] = $this;
             $colwidth = 'width:' . $singleColumnWidth . 'pt;';
             $table->colGroupStyles[] = $colwidth;
         }
     } else {
         CakeLog::debug("[IdmlTableColumn::parse] column width not found? " . __FILE__ . " Line " . __LINE__);
     }
     //IdmlTableColumn has no children to parse
 }
Beispiel #6
0
 /**
  * Parse from DOM node.
  * 
  * @param DOMElement $node
  */
 public function parse(DOMElement $node)
 {
     parent::parse($node);
     $link = IdmlAssembler::getInstance()->getCurrentPackage()->getHyperlinkBySource($node->getAttribute("Self"));
     $this->idAttribute = $node->hasAttribute(IdmlAttributes::Self) ? $node->getAttribute(IdmlAttributes::Self) : null;
     $this->name = $node->hasAttribute(IdmlAttributes::Name) ? $node->getAttribute(IdmlAttributes::Name) : null;
     if (count($link) > 0) {
         if (is_array($link['Destination'])) {
             $this->linkType = $link['Destination']['DestinationType'];
             if (array_key_exists('DestinationURL', $link['Destination'])) {
                 $this->href = $link['Destination']['DestinationURL'];
             }
         } else {
             $this->href = $link['Destination'];
         }
         if (!strlen($this->idmlTag)) {
             $this->idmlTag = 'a';
         }
     }
     $this->parseChildren($node);
 }
Beispiel #7
0
 public function parse(DOMElement $node)
 {
     parent::parse($node);
     //parse and set row attributes that are based upon parent table
     $rownum = $node->hasAttribute('Name') ? intval($node->getAttribute('Name')) : 0;
     $table = $this->parentIdmlObject();
     if (IdmlParserHelper::getIdmlObjectType($table) == "Table") {
         //set this row in the table rows array by index
         $table->rows[$rownum] = $this;
         //from Indesign the order of rows is header, body, footer
         //we must set what type of row this is and whether it is first and/or last in its group
         if ($table->headerRowCount && $rownum < $table->headerRowCount) {
             $this->rowType = 'thead';
             $rowGroupStart = 0;
             $rowGroupEnd = $table->headerRowCount - 1;
         } elseif ($table->bodyRowCount && $rownum < $table->headerRowCount + $table->bodyRowCount) {
             $this->rowType = 'tbody';
             $rowGroupStart = $table->headerRowCount;
             $rowGroupEnd = $table->headerRowCount + $table->bodyRowCount - 1;
         } elseif ($table->footerRowCount && $rownum < $table->headerRowCount + $table->bodyRowCount + $table->footerRowCount) {
             $this->rowType = 'tfoot';
             $rowGroupStart = $table->headerRowCount + $table->bodyRowCount;
             $rowGroupEnd = $table->headerRowCount + $table->bodyRowCount + $table->footerRowCount - 1;
         } else {
             //this is a problem as we can't place the row?
             CakeLog::debug("[IdmlTableRow::parse] unable to identify tablerow type and place in group " . __FILE__ . " Line " . __LINE__);
         }
         if ($rownum == $rowGroupStart) {
             $this->isFirstRow = true;
         }
         if ($rownum == $rowGroupEnd) {
             $this->isLastRow = true;
         }
     } else {
         //something is wrong so log this?
         CakeLog::debug("[IdmlTableRow::parse] parent is not an IdmlTable?" . __FILE__ . " Line " . __LINE__);
     }
     //TableRow has no children to parse
 }
Beispiel #8
0
 public function parse(DOMElement $node)
 {
     parent::parse($node);
     //we must set the <col style='width:...' /> for this column in the table
     $this->rowspan = $node->hasAttribute('RowSpan') ? intval($node->getAttribute('RowSpan')) : -1;
     $this->colspan = $node->hasAttribute('ColumnSpan') ? intval($node->getAttribute('ColumnSpan')) : -1;
     // Right now the parent is a table element, but we need the parent to be the corresponding row for this cell.
     // Find the right row in the table array and assign it as this cell's parent ImdlElement.
     $colrow = $node->hasAttribute('Name') ? $node->getAttribute('Name') : '0:0';
     $colrowArray = explode(":", $colrow);
     // <col>:<row>
     $this->colnumber = intval($colrowArray[0]);
     $this->rownumber = intval($colrowArray[1]);
     $row = $this->parentElement->rows[$this->rownumber];
     if (IdmlParserHelper::getIdmlObjectType($row) == "TableRow") {
         /*@var $row IdmlTableRow*/
         $row->childrenElements[] = $this;
         $this->parentElement = $row;
         //assign this cell as child of the table row
     } else {
         CakeLog::debug("[IdmlTableCell::parse] cannot find parent row in table for cell? " . __FILE__ . " Line " . __LINE__);
     }
     $this->parseChildren($node);
 }
Beispiel #9
0
 /**
  * Parse the portion of a spread.xml file that contains a <TextFrame>
  *
  * @param DOMElement $node is a single <TextFrame> node within the IDML document
  */
 public function parse(DOMElement $node)
 {
     parent::parse($node);
     $attributes = $node->attributes;
     $this->UID = $attributes->getNamedItem('Self')->value;
     // like 'uf9'
     $this->parentStoryUID = $attributes->getNamedItem('ParentStory')->value;
     // like 'ue5'
     $this->contentType = $attributes->getNamedItem('ContentType')->value;
     // like 'TextType'
     $this->visible = $attributes->getNamedItem('Visible')->value == 'false' ? false : true;
     // like 'true'
     $this->setTransform($node);
     $this->boundary = IdmlParserHelper::parseBoundary($node);
     $this->prevTextFrame = $attributes->getNamedItem(IdmlAttributes::PreviousTextFrame)->value == 'n' ? null : $attributes->getNamedItem(IdmlAttributes::PreviousTextFrame)->value;
     $this->nextTextFrame = $attributes->getNamedItem(IdmlAttributes::NextTextFrame)->value == 'n' ? null : $attributes->getNamedItem(IdmlAttributes::NextTextFrame)->value;
     $this->textColumnCount = isset($this->contextualStyle->idmlKeyValues['TextFramePreference->TextColumnCount']) ? (int) $this->contextualStyle->idmlKeyValues['TextFramePreference->TextColumnCount'] : null;
     $this->columnWidth = isset($this->contextualStyle->idmlKeyValues['TextFramePreference->TextColumnFixedWidth']) ? $this->contextualStyle->idmlKeyValues['TextFramePreference->TextColumnFixedWidth'] : null;
     // If we *do_not_have* a previous text frame then it is either a single text frame or the first of a series of
     // linked ones. In case of linked ones we output only the first one.
     if (!$this->prevTextFrame) {
         $this->loadParentStory();
     } else {
         if (IdmlAssembler::getInstance()->isFixedLayout()) {
             CakeLog::debug("[IdmlTextFrame::parse] Encountered an InDesign threaded frame in a fixed layout book (story {$this->parentStoryUID}). Run Chaucer FixedLayoutPreflight.jsx script within InDesign and re-export the IDML.");
         }
     }
 }
 /**
  * @param DOMElement $node
  */
 public function parse(DOMElement $node)
 {
     parent::parse($node);
     $this->content = $node->hasAttribute('ResultText') ? $node->getAttribute('ResultText') : '';
 }
 /**
  * Parse from DOM node.
  * @param DOMElement $node
  */
 public function parse(DOMElement $node)
 {
     parent::parse($node);
     $this->paragraphBreakType = isset($this->contextualStyle->idmlKeyValues['ParagraphBreakType']) ? $this->contextualStyle->idmlKeyValues['ParagraphBreakType'] : '';
     $this->parseChildren($node);
 }
 /**
  * Parse from DOM node.
  * 
  * @param DOMElement $node
  */
 public function parse(DOMElement $node)
 {
     parent::parse($node);
     $justification = $node->hasAttribute(IdmlAttributes::Justification) ? $node->getAttribute(IdmlAttributes::Justification) : 'left';
     if (isset($this->story->page)) {
         $pagePosition = $this->story->page->pagePosition;
     } else {
         $pagePosition = 'left';
     }
     $this->textAlign = IdmlParserHelper::convertJustification($justification, $pagePosition);
     // Change the TabList property cluster into an array for easier handling
     IdmlDeclarationParser::arrayifyDupes($this->contextualStyle->idmlContextualElement, $this->contextualStyle);
     // Check for nested styles; if any exist, set up the helper class object
     $this->parseNestedStyle();
     $this->parseChildren($node);
 }
Beispiel #13
0
 /**
  * Parse function.
  * @param DOMElement $node
  */
 public function parse(DOMElement $node)
 {
     parent::parse($node);
     $this->UID = $node->hasAttribute(IdmlAttributes::Self) ? $node->getAttribute(IdmlAttributes::Self) : null;
     $this->setTransform($node);
     $visible = $node->hasAttribute(IdmlAttributes::Visible) ? $node->getAttribute(IdmlAttributes::Visible) : 'true';
     $this->visible = strtolower($visible) == 'true' ? true : false;
     $this->parseChildren($node);
     // Groups can be nested within groups, so this needs to be determined now, after any inner groups have
     // had _their_ bounds determined.
     $this->determineBounds();
 }
Beispiel #14
0
 /**
  * Parse function.
  * @param DOMElement $node
  */
 public function parse(DOMElement $node)
 {
     parent::parse($node);
     $this->changeType = $node->hasAttribute(IdmlAttributes::ChangeType) ? $node->getAttribute(IdmlAttributes::ChangeType) : 'undefined';
     $this->parseChildren($node);
 }
Beispiel #15
0
 /**
  * Parse from DOM node.
  *
  * @param DOMElement $node
  */
 public function parse(DOMElement $node)
 {
     parent::parse($node);
     $this->UID = $node->hasAttribute(IdmlAttributes::Self) ? $node->getAttribute(IdmlAttributes::Self) : null;
     $this->setTransform($node);
     $visible = $node->hasAttribute(IdmlAttributes::Visible) ? $node->getAttribute(IdmlAttributes::Visible) : 'true';
     $this->visible = strtolower($visible) == 'true' ? true : false;
     $this->boundary = IdmlParserHelper::parseBoundary($node);
     $ffiList = $node->getElementsByTagName('FrameFittingOption');
     if ($ffiList->length > 0) {
         $ffiNode = $ffiList->item(0);
         $topCrop = $ffiNode->hasAttribute(IdmlAttributes::TopCrop) ? $ffiNode->getAttribute(IdmlAttributes::TopCrop) : 0;
         $leftCrop = $ffiNode->hasAttribute(IdmlAttributes::LeftCrop) ? $ffiNode->getAttribute(IdmlAttributes::LeftCrop) : 0;
         $bottomCrop = $ffiNode->hasAttribute(IdmlAttributes::BottomCrop) ? $ffiNode->getAttribute(IdmlAttributes::BottomCrop) : 0;
         $rightCrop = $ffiNode->hasAttribute(IdmlAttributes::RightCrop) ? $ffiNode->getAttribute(IdmlAttributes::RightCrop) : 0;
         $this->frameFittingOption = new IdmlFrameFitting($topCrop, $leftCrop, $bottomCrop, $rightCrop);
     }
     $this->parseChildren($node);
 }
Beispiel #16
0
 /**
  * Parse from DOM node.
  *
  * @param DOMElement $node
  */
 public function parse(DOMElement $node)
 {
     parent::parse($node);
     $this->setAttributes($node);
 }