Skip to content

ListItem inhert from AbstractContainer better ? #230

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

Closed
basjan opened this issue May 10, 2014 · 5 comments
Closed

ListItem inhert from AbstractContainer better ? #230

basjan opened this issue May 10, 2014 · 5 comments
Assignees
Milestone

Comments

@basjan
Copy link
Contributor

basjan commented May 10, 2014

I came across the ListItem element and I was wondering if it would not be better if the ListItem was inherited from the AbstractContainer class instead of the AbstractElement class ?

At the moment a structure like:

  • Default font Strong again default
  • Next list item

Seems not possible at the moment.
Considering the other elements, it would be, in my opinion, more logical if one could code the following:

$listItemObject = $section->addListItem(); 
$listItemObject->addText('Default font');
$listItemObject->addText('Strong', array('bold'=>true));
$listItemObject->addText('again default');

$listItemObject = $section->addListItem();
$listItemObject->addText('Next list item');
@ivanlanin
Copy link
Contributor

Good catch, @basjan. I even think that ListItem could be inherited from TextRun.

We just started the composite refactoring on 0.10. I'm still working on refactoring for HTML and RTF writers now. You can see for yourself that the code structure is rapidly changing in the last couple of days. Feel free to experiment and request a pull.

@basjan
Copy link
Contributor Author

basjan commented May 10, 2014

OK. I will first work a bit more on my \PhpOffice\PhpWord\Shared\Html::addHtml function and then take a look at the ListItem class

@ivanlanin
Copy link
Contributor

You might want to look at another implementation here :)

@basjan
Copy link
Contributor Author

basjan commented May 10, 2014

I did look at that package, before I decided that the PHPOffice is better. My main problem with the PHPDocX package is that "The PRO+ and CORPORATE version need JRE 1.5 or higher in order to run the advanced conversion plugin" (see http://www.phpdocx.com/help/faq)
Although I did not buy this package, it appears to me that for outputting other file formats than DocX the PHPDocX package uses a part of LibreOffice.

What I consider the main advantage of PHPOffice is that you build an object oriented model of a document and only at the end one decides whether it should be outputted as DocX, ODF, PDF etc.

Looking at the embedHTML function of PHPDocX, it appears to me that the HTML is converted directly into WordML and not to an object oriented model. (see also http://www.phpdocx.com/documentation/html-to-word-PHP) My first attempt of implementing HTML into PHPWord, as committed in #209 was similar.

At the moment I am working on a function, which takes the HTML and dissects it into elements and adds these elements to the document object.

@ivanlanin
Copy link
Contributor

Ok. Looking forward to see it implemented. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants