add support for STYLEREF field
This commit is contained in:
parent
dd27f668e0
commit
c52c96d657
|
|
@ -6,15 +6,20 @@ include_once 'Sample_Header.php';
|
|||
// New Word document
|
||||
echo date('H:i:s'), ' Create new PhpWord object', EOL;
|
||||
$phpWord = new \PhpOffice\PhpWord\PhpWord();
|
||||
PhpOffice\PhpWord\Style::addTitleStyle(1, array('size' => 14));
|
||||
|
||||
// New section
|
||||
$section = $phpWord->addSection();
|
||||
$section->addTitle('This page demos fields');
|
||||
|
||||
// Add Field elements
|
||||
// See Element/Field.php for all options
|
||||
$section->addText('Date field:');
|
||||
$section->addField('DATE', array('dateformat' => 'dddd d MMMM yyyy H:mm:ss'), array('PreserveFormat'));
|
||||
|
||||
$section->addText('Style Ref field:');
|
||||
$section->addField('STYLEREF', array('StyleIdentifier' => 'Heading 1'));
|
||||
|
||||
$section->addText('Page field:');
|
||||
$section->addField('PAGE', array('format' => 'Arabic'));
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,10 @@ class Field extends AbstractElement
|
|||
'properties' => array(),
|
||||
'options' => array('PreserveFormat'),
|
||||
),
|
||||
'STYLEREF' => array(
|
||||
'properties' => array('StyleIdentifier' => ''),
|
||||
'options' => array('PreserveFormat'),
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -177,6 +177,9 @@ class Field extends Text
|
|||
case 'macroname':
|
||||
$propertiesAndOptions .= $propval . ' ';
|
||||
break;
|
||||
default:
|
||||
$propertiesAndOptions .= '"' . $propval . '" ';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -288,6 +288,7 @@ class ElementTest extends \PHPUnit\Framework\TestCase
|
|||
$section->addField('DATE', array(), array('LunarCalendar'));
|
||||
$section->addField('DATE', array(), array('SakaEraCalendar'));
|
||||
$section->addField('NUMPAGES', array('format' => 'roman', 'numformat' => '0,00'), array('SakaEraCalendar'));
|
||||
$section->addField('STYLEREF', array('StyleIdentifier' => 'Heading 1'));
|
||||
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||
|
||||
$element = '/w:document/w:body/w:p/w:r/w:instrText';
|
||||
|
|
|
|||
Loading…
Reference in New Issue