Skip to content

Added Support for Indentation & Tabs on RTF Writer. #1405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Jul 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e5ee811
Added Support for Indentation & Tabs on RTF Writer.
smaug1985 Nov 28, 2016
d6ee4ee
Fixed syntaxs issues
Jul 9, 2018
7e58a49
Fixed syntaxs issues again
Jul 9, 2018
87bbae1
Fixed whitespaces issues
Jul 10, 2018
abe2532
fix formatting
troosan Jul 10, 2018
8c5bf7d
add decimal tab writer + tests
troosan Jul 10, 2018
42e5364
Merge branch 'develop' into develop
troosan Jul 10, 2018
b34ddaf
fix import order
troosan Jul 10, 2018
94cf1ae
Require `ext-zip` for development (#1419)
jjok Jul 13, 2018
c23143a
Update CHANGELOG.md
troosan Jul 13, 2018
ebe3fe0
refactor
troosan Jul 13, 2018
1bcd38b
Merge branch 'develop' of https://github.com/smaug1985/PHPWord into d…
troosan Jul 13, 2018
536a1b8
disable entity loader
troosan Jul 13, 2018
96b21ba
update changelog
troosan Jul 13, 2018
4c4c6f4
remove options not compatible with latest phpunit version
troosan Jul 13, 2018
cdc1852
Merge pull request #1427 from troosan/libxml_disable_entity_loader
troosan Jul 13, 2018
57afd89
Added Support for Indentation & Tabs on RTF Writer.
smaug1985 Nov 28, 2016
ab35628
Fixed syntaxs issues
Jul 9, 2018
5ff879c
Fixed syntaxs issues again
Jul 9, 2018
e5f68a9
Fixed whitespaces issues
Jul 10, 2018
a72b905
fix formatting
troosan Jul 10, 2018
53cc3ed
add decimal tab writer + tests
troosan Jul 10, 2018
704be56
fix import order
troosan Jul 10, 2018
346d74c
Update CHANGELOG.md
troosan Jul 13, 2018
39aacd6
refactor
troosan Jul 13, 2018
ba4aff5
fix warning
troosan Jul 13, 2018
75c74b3
Merge branch 'develop' of https://github.com/smaug1985/PHPWord into
troosan Jul 13, 2018
390d543
fix merge
troosan Jul 13, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed syntaxs issues
  • Loading branch information
root authored and troosan committed Jul 13, 2018
commit ab3562864f28dfdb877210358e24fe330c016416
12 changes: 4 additions & 8 deletions src/PhpWord/Writer/RTF/Style/Indentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

namespace PhpOffice\PhpWord\Writer\RTF\Style;


/**
* RTF indentation style writer
*
Expand All @@ -33,17 +32,14 @@ class Indentation extends AbstractStyle
*/
public function write()
{

$style = $this->getStyle();
if (!$style instanceof \PhpOffice\PhpWord\Style\Indentation) {
return;
return;
}
$content = '';
$content .= '\fi'.$style->getFirstLine();
$content = '';
$content .= '\fi'.$style->getFirstLine();
$content .= '\li'.$style->getLeft();
$content .= '\ri'.$style->getRight();
return $content . ' ';
}


}
}
28 changes: 13 additions & 15 deletions src/PhpWord/Writer/RTF/Style/Paragraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,32 +65,30 @@ public function write()
$content .= $alignments[$style->getAlignment()];
}
$indent = $style->getIndentation();
if(isset($indent) && $indent instanceof \PhpOffice\PhpWord\Style\Indentation){
$writer = new Indentation($indent);
$content .= $writer->write();
if (isset($indent) && $indent instanceof \PhpOffice\PhpWord\Style\Indentation) {
$writer = new Indentation($indent);
$content .= $writer->write();
}
$content .= $this->getValueIf($spaceBefore !== null, '\sb' . $spaceBefore);
$content .= $this->getValueIf($spaceAfter !== null, '\sa' . $spaceAfter);

$styles = $style->getStyleValues();
$content .= $this->writeTabs( $styles['tabs']);
$content .= $this->writeTabs($styles['tabs']);

return $content;
}

private function writeTabs( $tabs)
private function writeTabs($tabs)
{
$content = '';
if (!empty($tabs)) {

foreach ($tabs as $tab) {

$styleWriter = new Tab( $tab);
$content .= $styleWriter->write();
}
$content = '';
if (!empty($tabs)) {

}
return $content;
foreach ($tabs as $tab) {
$styleWriter = new Tab($tab);
$content .= $styleWriter->write();
}
}
return $content;
}

/**
Expand Down
17 changes: 8 additions & 9 deletions src/PhpWord/Writer/RTF/Style/Tab.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,17 @@ public function write()
}
$content = '';
$type = $style->getType();
if($type == \PhpOffice\PhpWord\Style\Tab::TAB_STOP_RIGHT){
$content .= '\tqr';
}else if($type == \PhpOffice\PhpWord\Style\Tab::TAB_STOP_CENTER){
$content .= '\tqc';
if ($type == \PhpOffice\PhpWord\Style\Tab::TAB_STOP_RIGHT) {
$content .= '\tqr';
} else if ($type == \PhpOffice\PhpWord\Style\Tab::TAB_STOP_CENTER) {
$content .= '\tqc';
}
$pos = $style->getPosition();
if(isset($pos)){
$content .= '\tx'.$pos;
}else{
$content .= '\tx';
if (isset($pos)) {
$content .= '\tx'.$pos;
} else {
$content .= '\tx';
}

return $content;
}
}