package org.openoffice.odf.doc.element.text;

import org.openoffice.odf.doc.OdfFileDom;

public class OdfParagraphExtra extends OdfParagraph
{
	OdfFileDom owner;
	/**
	 * Construct an OdfParagraphExtra from owner document.
	 * @param _aOwnerDoc the owner document DOM
	 */
	public OdfParagraphExtra(OdfFileDom _aOwnerDoc)
	{
		super(_aOwnerDoc);
		this.owner = _aOwnerDoc;
	}
	
	/**
	 * Construct an OdfParagraphExtra with the given styleName.
	 * @param _aOwnerDoc the owner document DOM
	 * @param styleName the style:style-name value
	 */
	public OdfParagraphExtra(OdfFileDom _aOwnerDoc, String styleName)
	{
		super(_aOwnerDoc);
		this.owner = _aOwnerDoc;
		if (styleName != null && (!(styleName.equals(""))))
        {
            this.setStyleName(styleName);
        }
	}
	
	/**
	 * Construct an OdfParagraphExtra with the given styleName and content.
     * If the style name is null or the null string, no style is added.
	 * @param _aOwnerDoc the owner document DOM
	 * @param content the paragraph content
	 * @param styleName the style:style-name value
	 */
	public OdfParagraphExtra(OdfFileDom _aOwnerDoc,
			String content, String styleName)
	{
		super(_aOwnerDoc);
		this.owner = _aOwnerDoc;
		this.addContentStyle(content, styleName);
	}
	
	/**
	 * Add the given content to the paragraph.
     * If the style name is null or the null string, no style is added.
	 * Embedded \n are converted to <code>&lt;text:line-break&gt;</code>
	 * elements. I'm sure there's a more efficient way to do this.
	 * Does not handle conversion of multiple blanks to
	 * <code>&lt;text:s&gt;</code> elements.
	 * @param content the paragraph content
	 */
	public void addContent(String content)
	{
		new OdfWhitespaceProcessor().append(this, content);
	}

	/**
	 * Set a paragraph to have the given styleName and add the given content.
     * If the style name is null or the null string, no style is added.
	 * @param styleName the style:style-name value
	 * @param content the paragraph content
	 */
	public void addContentStyle( String content, String styleName )
	{
		if (styleName != null && (!(styleName.equals(""))))
        {
            setStyleName(styleName);
        }
		addContent(content);
	}
		
}
