当前位置: 首页>>代码示例>>PHP>>正文


PHP Shared\XMLWriter类代码示例

本文整理汇总了PHP中PhpOffice\PhpWord\Shared\XMLWriter的典型用法代码示例。如果您正苦于以下问题:PHP XMLWriter类的具体用法?PHP XMLWriter怎么用?PHP XMLWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了XMLWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: writeFontFaces

 /**
  * Write font faces declaration
  */
 protected function writeFontFaces(XMLWriter $xmlWriter)
 {
     $xmlWriter->startElement('office:font-face-decls');
     $fontTable = array();
     $styles = Style::getStyles();
     $numFonts = 0;
     if (count($styles) > 0) {
         foreach ($styles as $style) {
             // Font
             if ($style instanceof Font) {
                 $numFonts++;
                 $name = $style->getName();
                 if (!in_array($name, $fontTable)) {
                     $fontTable[] = $name;
                     // style:font-face
                     $xmlWriter->startElement('style:font-face');
                     $xmlWriter->writeAttribute('style:name', $name);
                     $xmlWriter->writeAttribute('svg:font-family', $name);
                     $xmlWriter->endElement();
                 }
             }
         }
     }
     if (!in_array(Settings::getDefaultFontName(), $fontTable)) {
         $xmlWriter->startElement('style:font-face');
         $xmlWriter->writeAttribute('style:name', Settings::getDefaultFontName());
         $xmlWriter->writeAttribute('svg:font-family', Settings::getDefaultFontName());
         $xmlWriter->endElement();
     }
     $xmlWriter->endElement();
 }
开发者ID:hcvcastro,项目名称:pxp,代码行数:34,代码来源:AbstractPart.php

示例2: writeContentType

 /**
  * Write content types element
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter XML Writer
  * @param array $parts
  * @param boolean $isDefault
  */
 private function writeContentType(XMLWriter $xmlWriter, $parts, $isDefault)
 {
     foreach ($parts as $partName => $contentType) {
         $partType = $isDefault ? 'Default' : 'Override';
         $partAttribute = $isDefault ? 'Extension' : 'PartName';
         $xmlWriter->startElement($partType);
         $xmlWriter->writeAttribute($partAttribute, $partName);
         $xmlWriter->writeAttribute('ContentType', $contentType);
         $xmlWriter->endElement();
     }
 }
开发者ID:hcvcastro,项目名称:pxp,代码行数:18,代码来源:ContentTypes.php

示例3: testEmptyStyles

 /**
  * Test empty styles
  */
 public function testEmptyStyles()
 {
     $styles = array('Font', 'Paragraph', 'Image', 'Section', 'Table');
     foreach ($styles as $style) {
         $objectClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Style\\' . $style;
         $xmlWriter = new XMLWriter();
         $object = new $objectClass($xmlWriter);
         $object->write();
         $this->assertEquals('', $xmlWriter->getData());
     }
 }
开发者ID:hcvcastro,项目名称:pxp,代码行数:14,代码来源:StyleTest.php

示例4: testMethodExceptions

 /**
  * Test method exceptions
  */
 public function testMethodExceptions()
 {
     $styles = array('Frame' => 'writeAlignment', 'Line' => 'writeStroke', 'TextBox' => 'writeBorder');
     foreach ($styles as $style => $method) {
         $objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Style\\' . $style;
         $xmlWriter = new XMLWriter();
         $object = new $objectClass($xmlWriter);
         $object->{$method}();
         $this->assertEquals('', $xmlWriter->getData());
     }
 }
开发者ID:doit05,项目名称:relProject,代码行数:14,代码来源:StyleTest.php

示例5: testUnmatchedElements

 /**
  * Test unmatched element
  */
 public function testUnmatchedElements()
 {
     $elements = array('CheckBox', 'Container', 'Footnote', 'Image', 'Link', 'ListItem', 'ListItemRun', 'Object', 'PreserveText', 'Table', 'Text', 'TextBox', 'TextBreak', 'Title', 'TOC', 'Field', 'Line', 'Shape', 'Chart', 'FormField', 'SDT');
     foreach ($elements as $element) {
         $objectClass = 'PhpOffice\\PhpWord\\Writer\\Word2007\\Element\\' . $element;
         $xmlWriter = new XMLWriter();
         $newElement = new \PhpOffice\PhpWord\Element\PageBreak();
         $object = new $objectClass($xmlWriter, $newElement);
         $object->write();
         $this->assertEquals('', $xmlWriter->getData());
     }
 }
开发者ID:productioncompilers,项目名称:PHPWord,代码行数:15,代码来源:ElementTest.php

示例6: testUnmatchedElements

 /**
  * Test unmatched elements
  */
 public function testUnmatchedElements()
 {
     $elements = array('Image', 'Link', 'Table', 'Text', 'Title');
     foreach ($elements as $element) {
         $objectClass = 'PhpOffice\\PhpWord\\Writer\\ODText\\Element\\' . $element;
         $xmlWriter = new XMLWriter();
         $newElement = new \PhpOffice\PhpWord\Element\PageBreak();
         $object = new $objectClass($xmlWriter, $newElement);
         $object->write();
         $this->assertEquals('', $xmlWriter->getData());
     }
 }
开发者ID:HaiLeader,项目名称:quizz,代码行数:15,代码来源:ElementTest.php

示例7: writeContentType

 /**
  * Write content types element
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter XML Writer
  * @param array $parts
  * @param boolean $isDefault
  * @throws \PhpOffice\PhpWord\Exception\Exception
  */
 private function writeContentType(XMLWriter $xmlWriter, $parts, $isDefault)
 {
     foreach ($parts as $partName => $contentType) {
         if ($partName != '' && $contentType != '') {
             $partType = $isDefault ? 'Default' : 'Override';
             $partAttribute = $isDefault ? 'Extension' : 'PartName';
             $xmlWriter->startElement($partType);
             $xmlWriter->writeAttribute($partAttribute, $partName);
             $xmlWriter->writeAttribute('ContentType', $contentType);
             $xmlWriter->endElement();
         } else {
             throw new Exception("Invalid parameters passed.");
         }
     }
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:23,代码来源:ContentTypes.php

示例8: writeWatermark

 /**
  * Write watermark element
  */
 private function writeWatermark(XMLWriter $xmlWriter, ImageElement $element)
 {
     $rId = $element->getRelationId();
     $style = $element->getStyle();
     $style->setPositioning('absolute');
     $styleWriter = new ImageStyleWriter($xmlWriter, $style);
     $xmlWriter->startElement('w:p');
     $xmlWriter->startElement('w:r');
     $xmlWriter->startElement('w:pict');
     $xmlWriter->startElement('v:shape');
     $xmlWriter->writeAttribute('type', '#_x0000_t75');
     $styleWriter->write();
     $xmlWriter->startElement('v:imagedata');
     $xmlWriter->writeAttribute('r:id', 'rId' . $rId);
     $xmlWriter->writeAttribute('o:title', '');
     $xmlWriter->endElement();
     // v:imagedata
     $xmlWriter->endElement();
     // v:shape
     $xmlWriter->endElement();
     // w:pict
     $xmlWriter->endElement();
     // w:r
     $xmlWriter->endElement();
     // w:p
 }
开发者ID:hcvcastro,项目名称:pxp,代码行数:29,代码来源:Image.php

示例9: writeSetting

 /**
  * Write indivual setting, recursive to any child settings
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
  * @param string $settingKey
  * @param array|string $settingValue
  */
 protected function writeSetting($xmlWriter, $settingKey, $settingValue)
 {
     if ($settingValue == '') {
         $xmlWriter->writeElement($settingKey);
     } else {
         $xmlWriter->startElement($settingKey);
         foreach ($settingValue as $childKey => $childValue) {
             if ($childKey == '@attributes') {
                 foreach ($childValue as $key => $val) {
                     $xmlWriter->writeAttribute($key, $val);
                 }
             } else {
                 $this->writeSetting($xmlWriter, $childKey, $childValue);
             }
         }
         $xmlWriter->endElement();
     }
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:25,代码来源:Settings.php

示例10: writeSide

 /**
  * Write side.
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
  * @param string $side
  * @param int $width
  * @param string $color
  * @return void
  */
 private function writeSide(XMLWriter $xmlWriter, $side, $width, $color = null)
 {
     $xmlWriter->startElement('w:' . $side);
     if (!empty($this->colors)) {
         if ($color === null && !empty($this->attributes)) {
             if (isset($this->attributes['defaultColor'])) {
                 $color = $this->attributes['defaultColor'];
             }
         }
         $xmlWriter->writeAttribute('w:val', 'single');
         $xmlWriter->writeAttribute('w:sz', $width);
         $xmlWriter->writeAttribute('w:color', $color);
         if (!empty($this->attributes)) {
             if (isset($this->attributes['space'])) {
                 $xmlWriter->writeAttribute('w:space', $this->attributes['space']);
             }
         }
     } else {
         $xmlWriter->writeAttribute('w:w', $width);
         $xmlWriter->writeAttribute('w:type', 'dxa');
     }
     $xmlWriter->endElement();
 }
开发者ID:doit05,项目名称:relProject,代码行数:32,代码来源:MarginBorder.php

示例11: writeWrap

 /**
  * Write alignment.
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
  * @param \PhpOffice\PhpWord\Style\Frame $style
  * @param string $wrap
  * @return void
  */
 private function writeWrap(XMLWriter $xmlWriter, FrameStyle $style, $wrap)
 {
     if ($wrap !== null) {
         $xmlWriter->startElement('w10:wrap');
         $xmlWriter->writeAttribute('type', $wrap);
         $relativePositions = array(FrameStyle::POS_RELTO_MARGIN => 'margin', FrameStyle::POS_RELTO_PAGE => 'page', FrameStyle::POS_RELTO_TMARGIN => 'margin', FrameStyle::POS_RELTO_BMARGIN => 'page', FrameStyle::POS_RELTO_LMARGIN => 'margin', FrameStyle::POS_RELTO_RMARGIN => 'page');
         $pos = $style->getPos();
         $hPos = $style->getHPosRelTo();
         $vPos = $style->getVPosRelTo();
         if ($pos == FrameStyle::POS_ABSOLUTE) {
             $xmlWriter->writeAttribute('anchorx', "page");
             $xmlWriter->writeAttribute('anchory', "page");
         } elseif ($pos == FrameStyle::POS_RELATIVE) {
             if (isset($relativePositions[$hPos])) {
                 $xmlWriter->writeAttribute('anchorx', $relativePositions[$hPos]);
             }
             if (isset($relativePositions[$vPos])) {
                 $xmlWriter->writeAttribute('anchory', $relativePositions[$vPos]);
             }
         }
         $xmlWriter->endElement();
         // w10:wrap
     }
 }
开发者ID:Senasum,项目名称:PHPWord,代码行数:32,代码来源:Frame.php

示例12: writeShape

 /**
  * Write shape
  *
  * @link http://www.datypic.com/sc/ooxml/t-a_CT_ShapeProperties.html
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
  * @param bool $line
  * @return void
  */
 private function writeShape(XMLWriter $xmlWriter, $line = false)
 {
     $xmlWriter->startElement('c:spPr');
     $xmlWriter->startElement('a:ln');
     if ($line === true) {
         $xmlWriter->writeElement('a:solidFill');
     } else {
         $xmlWriter->writeElement('a:noFill');
     }
     $xmlWriter->endElement();
     // a:ln
     $xmlWriter->endElement();
     // c:spPr
 }
开发者ID:doit05,项目名称:relProject,代码行数:22,代码来源:Chart.php

示例13: writeShading

 /**
  * Write shading.
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
  * @param \PhpOffice\PhpWord\Style\Table $style
  * @return void
  */
 private function writeShading(XMLWriter $xmlWriter, TableStyle $style)
 {
     if (null !== $style->getShading()) {
         $xmlWriter->startElement('w:tcPr');
         $styleWriter = new Shading($xmlWriter, $style->getShading());
         $styleWriter->write();
         $xmlWriter->endElement();
     }
 }
开发者ID:brunodebarros,项目名称:phpword,代码行数:16,代码来源:Table.php

示例14: writeDefaultStyles

 /**
  * Write default font and other default styles
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
  * @param array $styles
  */
 private function writeDefaultStyles(XMLWriter $xmlWriter, PhpWord $phpWord, $styles)
 {
     $fontName = $phpWord->getDefaultFontName();
     $fontSize = $phpWord->getDefaultFontSize();
     // Default font
     $xmlWriter->startElement('w:docDefaults');
     $xmlWriter->startElement('w:rPrDefault');
     $xmlWriter->startElement('w:rPr');
     $xmlWriter->startElement('w:rFonts');
     $xmlWriter->writeAttribute('w:ascii', $fontName);
     $xmlWriter->writeAttribute('w:hAnsi', $fontName);
     $xmlWriter->writeAttribute('w:eastAsia', $fontName);
     $xmlWriter->writeAttribute('w:cs', $fontName);
     $xmlWriter->endElement();
     // w:rFonts
     $xmlWriter->startElement('w:sz');
     $xmlWriter->writeAttribute('w:val', $fontSize * 2);
     $xmlWriter->endElement();
     // w:sz
     $xmlWriter->startElement('w:szCs');
     $xmlWriter->writeAttribute('w:val', $fontSize * 2);
     $xmlWriter->endElement();
     // w:szCs
     $xmlWriter->endElement();
     // w:rPr
     $xmlWriter->endElement();
     // w:rPrDefault
     $xmlWriter->endElement();
     // w:docDefaults
     // Normal style
     $xmlWriter->startElement('w:style');
     $xmlWriter->writeAttribute('w:type', 'paragraph');
     $xmlWriter->writeAttribute('w:default', '1');
     $xmlWriter->writeAttribute('w:styleId', 'Normal');
     $xmlWriter->startElement('w:name');
     $xmlWriter->writeAttribute('w:val', 'Normal');
     $xmlWriter->endElement();
     // w:name
     if (array_key_exists('Normal', $styles)) {
         $styleWriter = new ParagraphStyleWriter($xmlWriter, $styles['Normal']);
         $styleWriter->write();
     }
     $xmlWriter->endElement();
     // w:style
     // FootnoteReference style
     if (!array_key_exists('FootnoteReference', $styles)) {
         $xmlWriter->startElement('w:style');
         $xmlWriter->writeAttribute('w:type', 'character');
         $xmlWriter->writeAttribute('w:styleId', 'FootnoteReference');
         $xmlWriter->startElement('w:name');
         $xmlWriter->writeAttribute('w:val', 'Footnote Reference');
         $xmlWriter->endElement();
         // w:name
         $xmlWriter->writeElement('w:semiHidden');
         $xmlWriter->writeElement('w:unhideWhenUsed');
         $xmlWriter->startElement('w:rPr');
         $xmlWriter->startElement('w:vertAlign');
         $xmlWriter->writeAttribute('w:val', 'superscript');
         $xmlWriter->endElement();
         // w:vertAlign
         $xmlWriter->endElement();
         // w:rPr
         $xmlWriter->endElement();
         // w:style
     }
 }
开发者ID:kaantunc,项目名称:MYK-BOR,代码行数:72,代码来源:Styles.php

示例15: writeSectionSettings

 /**
  * Write end section.
  *
  * @param \PhpOffice\PhpWord\Shared\XMLWriter $xmlWriter
  * @param \PhpOffice\PhpWord\Element\Section $section
  * @return void
  */
 private function writeSectionSettings(XMLWriter $xmlWriter, Section $section)
 {
     $xmlWriter->startElement('w:sectPr');
     // Header reference
     foreach ($section->getHeaders() as $header) {
         $rId = $header->getRelationId();
         $xmlWriter->startElement('w:headerReference');
         $xmlWriter->writeAttribute('w:type', $header->getType());
         $xmlWriter->writeAttribute('r:id', 'rId' . $rId);
         $xmlWriter->endElement();
     }
     // Footer reference
     foreach ($section->getFooters() as $footer) {
         $rId = $footer->getRelationId();
         $xmlWriter->startElement('w:footerReference');
         $xmlWriter->writeAttribute('w:type', $footer->getType());
         $xmlWriter->writeAttribute('r:id', 'rId' . $rId);
         $xmlWriter->endElement();
     }
     // Different first page
     if ($section->hasDifferentFirstPage()) {
         $xmlWriter->startElement('w:titlePg');
         $xmlWriter->endElement();
     }
     // Section settings
     $styleWriter = new SectionStyleWriter($xmlWriter, $section->getStyle());
     $styleWriter->write();
     $xmlWriter->endElement();
     // w:sectPr
 }
开发者ID:doit05,项目名称:relProject,代码行数:37,代码来源:Document.php


注:本文中的PhpOffice\PhpWord\Shared\XMLWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。