Support for Mirrored page setup for docx
This commit is contained in:
parent
056f81078f
commit
64957d9ec8
|
|
@ -159,6 +159,15 @@ Or to predefined values ``fullPage``, ``bestFit``, ``textFit``
|
||||||
|
|
||||||
$phpWord->getSettings()->setZoom(Zoom::BEST_FIT);
|
$phpWord->getSettings()->setZoom(Zoom::BEST_FIT);
|
||||||
|
|
||||||
|
Mirroring the Page Margins
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
Use mirror margins to set up facing pages for double-sided documents, such as books or magazines.
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
$phpWord->getSettings()->setMirrorMargins(true);
|
||||||
|
|
||||||
|
|
||||||
Spelling and grammatical checks
|
Spelling and grammatical checks
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,14 @@ class Settings
|
||||||
*/
|
*/
|
||||||
private $zoom = 100;
|
private $zoom = 100;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mirror Page Margins
|
||||||
|
*
|
||||||
|
* @see http://www.datypic.com/sc/ooxml/e-w_mirrorMargins-1.html
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $mirrorMargins;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hide spelling errors
|
* Hide spelling errors
|
||||||
*
|
*
|
||||||
|
|
@ -301,6 +309,22 @@ class Settings
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasMirrorMargins()
|
||||||
|
{
|
||||||
|
return $this->mirrorMargins;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $mirrorMargins
|
||||||
|
*/
|
||||||
|
public function setMirrorMargins($mirrorMargins)
|
||||||
|
{
|
||||||
|
$this->mirrorMargins = $mirrorMargins;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Language
|
* Returns the Language
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,7 @@ class Settings extends AbstractPart
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->setOnOffValue('w:mirrorMargins', $documentSettings->hasMirrorMargins());
|
||||||
$this->setOnOffValue('w:hideSpellingErrors', $documentSettings->hasHideSpellingErrors());
|
$this->setOnOffValue('w:hideSpellingErrors', $documentSettings->hasHideSpellingErrors());
|
||||||
$this->setOnOffValue('w:hideGrammaticalErrors', $documentSettings->hasHideGrammaticalErrors());
|
$this->setOnOffValue('w:hideGrammaticalErrors', $documentSettings->hasHideGrammaticalErrors());
|
||||||
$this->setOnOffValue('w:trackRevisions', $documentSettings->hasTrackRevisions());
|
$this->setOnOffValue('w:trackRevisions', $documentSettings->hasTrackRevisions());
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ use PhpOffice\PhpWord\Settings;
|
||||||
use PhpOffice\PhpWord\SimpleType\Zoom;
|
use PhpOffice\PhpWord\SimpleType\Zoom;
|
||||||
use PhpOffice\PhpWord\Style\Language;
|
use PhpOffice\PhpWord\Style\Language;
|
||||||
use PhpOffice\PhpWord\TestHelperDOCX;
|
use PhpOffice\PhpWord\TestHelperDOCX;
|
||||||
|
use PhpOffice\PhpWord\ComplexType\ProofState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Settings
|
* Test class for PhpOffice\PhpWord\Writer\Word2007\Part\Settings
|
||||||
|
|
@ -110,6 +111,29 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals(Language::HE_IL, $element->getAttribute('w:bidi'));
|
$this->assertEquals(Language::HE_IL, $element->getAttribute('w:bidi'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test proofState
|
||||||
|
*/
|
||||||
|
public function testProofState()
|
||||||
|
{
|
||||||
|
$proofState = new ProofState();
|
||||||
|
$proofState->setSpelling(ProofState::DIRTY);
|
||||||
|
$proofState->setGrammar(ProofState::DIRTY);
|
||||||
|
$phpWord = new PhpWord();
|
||||||
|
$phpWord->getSettings()->setProofState($proofState);
|
||||||
|
|
||||||
|
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||||
|
|
||||||
|
$file = 'word/settings.xml';
|
||||||
|
|
||||||
|
$path = '/w:settings/w:proofState';
|
||||||
|
$this->assertTrue($doc->elementExists($path, $file));
|
||||||
|
$element = $doc->getElement($path, $file);
|
||||||
|
|
||||||
|
$this->assertEquals('dirty', $element->getAttribute('w:spelling'));
|
||||||
|
$this->assertEquals('dirty', $element->getAttribute('w:grammar'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test spelling
|
* Test spelling
|
||||||
*/
|
*/
|
||||||
|
|
@ -186,6 +210,22 @@ class SettingsTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals('fullPage', $element->getAttribute('w:val'));
|
$this->assertEquals('fullPage', $element->getAttribute('w:val'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testMirrorMargins()
|
||||||
|
{
|
||||||
|
$phpWord = new PhpWord();
|
||||||
|
$phpWord->getSettings()->setMirrorMargins(true);
|
||||||
|
|
||||||
|
$doc = TestHelperDOCX::getDocument($phpWord);
|
||||||
|
|
||||||
|
$file = 'word/settings.xml';
|
||||||
|
|
||||||
|
$path = '/w:settings/w:mirrorMargins';
|
||||||
|
$this->assertTrue($doc->elementExists($path, $file));
|
||||||
|
|
||||||
|
$element = $doc->getElement($path, $file);
|
||||||
|
$this->assertNotEquals('false', $element->getAttribute('w:val'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test Revision View
|
* Test Revision View
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue