| 23 |
liveuser |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
//require_once 'functions.php';
|
|
|
4 |
//require_once 'class.odt.php';
|
|
|
5 |
|
|
|
6 |
include_once 'phpodt.php';
|
|
|
7 |
|
|
|
8 |
/**
|
|
|
9 |
* Base class for paragraph & text styles.
|
|
|
10 |
*
|
|
|
11 |
* @author Issam RACHDI
|
|
|
12 |
*/
|
|
|
13 |
class ContentAutoStyle {
|
|
|
14 |
|
|
|
15 |
/**
|
|
|
16 |
* The DOMDocument representing the styles xml file
|
|
|
17 |
* @access private
|
|
|
18 |
* @var DOMDocument
|
|
|
19 |
*/
|
|
|
20 |
protected $contentDocument;
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
* The name of the style
|
|
|
24 |
* @access private
|
|
|
25 |
* @var string
|
|
|
26 |
*/
|
|
|
27 |
protected $name;
|
|
|
28 |
|
|
|
29 |
/**
|
|
|
30 |
* The DOMElement representing this style
|
|
|
31 |
* @access private
|
|
|
32 |
* @var DOMElement
|
|
|
33 |
*/
|
|
|
34 |
protected $styleElement;
|
|
|
35 |
|
|
|
36 |
/**
|
|
|
37 |
* The constructor initializes the properties, then creates a <style:style> element , or an other element
|
|
|
38 |
* if $elementNodeName is specified, representing this specific style, and add it to <office:automatic-styles> element
|
|
|
39 |
*
|
|
|
40 |
* @param DOMDocument $contentDoc The content Document returned by the method {@link ODT.html#initContent initContent()}
|
|
|
41 |
* @param string $name The style name
|
|
|
42 |
*/
|
|
|
43 |
function __construct($name, $elementNodeName = NULL) {
|
|
|
44 |
$this->contentDocument = ODT::getInstance()->getDocumentContent();
|
|
|
45 |
$this->name = $name;
|
|
|
46 |
if ($elementNodeName == NULL) {
|
|
|
47 |
$this->styleElement = $this->contentDocument->createElement('style:style');
|
|
|
48 |
} else {
|
|
|
49 |
$this->styleElement = $this->contentDocument->createElement($elementNodeName);
|
|
|
50 |
}
|
|
|
51 |
$this->styleElement->setAttribute('style:name', $name);
|
|
|
52 |
$this->contentDocument->getElementsByTagName('office:automatic-styles')->item(0)->appendChild($this->styleElement);
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
/**
|
|
|
56 |
* return the name of this style
|
|
|
57 |
* @return string
|
|
|
58 |
*/
|
|
|
59 |
function getStyleName() {
|
|
|
60 |
return $this->name;
|
|
|
61 |
}
|
|
|
62 |
|
|
|
63 |
public function setStyleName($name) {
|
|
|
64 |
$this->name = $name;
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
?>
|