View Single Post
Old 02-23-2009, 10:38 AM   #6 (permalink)
Gibou
The Contributor
 
Gibou's Avatar
 
Join Date: Nov 2007
Location: France, near Paris
Posts: 53
Thanks: 6
Gibou is on a distinguished road
Default

Quote:
Originally Posted by Ultimatum View Post
How do I add the objects Page etc.. to the class WordDocument. Now I have a method addParagraph and then I pass the object paragraph to that method or should I extend Page class with WordDocument class?
Don't extend, no. The class Page is not a container of WordDocument.
You add pages like this:
In your "WordDocument" class, you have a addPage() method:

PHP Code:
<?php
private Array pages;

public function 
addPage(Page &page)
{
  
this->pages[] = page;
}
?>
You create the instance outsite and you add it, passing it by reference. The method had it into the class collection (pages).


Quote:
Originally Posted by Ultimatum View Post
And it is possible to put images and text in header/footer as well
Header and Footer are 'Paragraph' instances. Paragraph can contains images, no problem.

Quote:
Originally Posted by Ultimatum View Post
and it is also possible to add pagenumbers to those so it's a little more then only paragraphs.
No problem, when you add a paragraph, it's a method "addParagraph" in the 'Page class' when you add, you take the Page instance id and put it into a 'Paragraph' 'pageId' attribute.
But i don't advise you to do that. Indeed, when you add some text before a paragraph, you push the following ones to bottom and a paragraph could go to the following page. It could be hard to check.
I advise more to insert an attribute 'position' to the 'Paragraph' class which is incremented at each inserted paragraph.


Quote:
Originally Posted by Ultimatum View Post
In the class Text I know have all the properties like fontsize, fontfamily, fontcolor, bold, italic, underline. And with the Text class I can give every line other properties. That's why I have a Text class.

I love more comments from anybody to help me solve this problem :)
You don't need a class for that. Why don't you keep dob codes inside the text ? You just have to transform dob codes into html tags (or others depending on the api you use to create your Word documents) with regular expressions.

Have a nice day
__________________
Wedus project's Website
Send a message via MSN to Gibou
Gibou is offline  
Reply With Quote