forked from PHPOffice/PHPWord
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PHPOffice#196: Ability to add links and page breaks in RTF
- Loading branch information
Showing
8 changed files
with
101 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
/** | ||
* This file is part of PHPWord - A pure PHP library for reading and writing | ||
* word processing documents. | ||
* | ||
* PHPWord is free software distributed under the terms of the GNU Lesser | ||
* General Public License version 3 as published by the Free Software Foundation. | ||
* | ||
* For the full copyright and license information, please read the LICENSE | ||
* file that was distributed with this source code. For the full list of | ||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. | ||
* | ||
* @link https://github.com/PHPOffice/PHPWord | ||
* @copyright 2010-2014 PHPWord contributors | ||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 | ||
*/ | ||
|
||
namespace PhpOffice\PhpWord\Writer\RTF\Element; | ||
|
||
use PhpOffice\PhpWord\Shared\String; | ||
|
||
/** | ||
* Link element RTF writer | ||
* | ||
* @since 0.11.0 | ||
*/ | ||
class Link extends AbstractElement | ||
{ | ||
/** | ||
* Write element | ||
* | ||
* @return string | ||
*/ | ||
public function write() | ||
{ | ||
$element = $this->element; | ||
if (!$element instanceof \PhpOffice\PhpWord\Element\Link) { | ||
return; | ||
} | ||
|
||
$content = ''; | ||
if (!$this->withoutP) { | ||
$content .= '{'; | ||
} | ||
$content .= '{\field {\*\fldinst {HYPERLINK "' . $element->getTarget() . '"}}{\\fldrslt {'; | ||
$content .= String::toUnicode($element->getText()); | ||
$content .= '}}}'; | ||
if (!$this->withoutP) { | ||
$content .= '}'; | ||
} | ||
|
||
return $content; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/** | ||
* This file is part of PHPWord - A pure PHP library for reading and writing | ||
* word processing documents. | ||
* | ||
* PHPWord is free software distributed under the terms of the GNU Lesser | ||
* General Public License version 3 as published by the Free Software Foundation. | ||
* | ||
* For the full copyright and license information, please read the LICENSE | ||
* file that was distributed with this source code. For the full list of | ||
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors. | ||
* | ||
* @link https://github.com/PHPOffice/PHPWord | ||
* @copyright 2010-2014 PHPWord contributors | ||
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 | ||
*/ | ||
|
||
namespace PhpOffice\PhpWord\Writer\RTF\Element; | ||
|
||
/** | ||
* PageBreak element RTF writer | ||
* | ||
* @since 0.11.0 | ||
*/ | ||
class PageBreak extends AbstractElement | ||
{ | ||
/** | ||
* Write element | ||
* | ||
* @return string | ||
*/ | ||
public function write() | ||
{ | ||
return '\page' . PHP_EOL; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters