/** * Test set and get of a property. */ public function test_set_and_get() { $xml_code = '<style:style style:name="test" style:family="text"> <style:text-properties fo:color="#ffffff"/> </style:style>'; $style = ODTStyle::importODTStyle($xml_code); $this->assertNotNull($style); $style->setProperty('color', '#000000'); $this->assertEquals($style->getProperty('color'), '#000000'); }
/** * Test set and get of a property. */ public function test_set_and_get() { $xml_code = '<style:style style:name="Table1.A" style:family="table-column"> <style:table-column-properties style:column-width="5.609cm"/> </style:style>'; $style = ODTStyle::importODTStyle($xml_code); $this->assertNotNull($style); $style->setProperty('column-width', '12.345cm'); $this->assertEquals($style->getProperty('column-width'), '12.345cm'); }
/** * Test set and get of a property. */ public function test_set_and_get() { $xml_code = '<style:style style:name="Table1.A1" style:family="table-cell"> <style:table-cell-properties fo:padding="0.097cm" fo:border-left="0.05pt solid #000000" fo:border-right="none" fo:border-top="0.05pt solid #000000" fo:border-bottom="0.05pt solid #000000"/> </style:style>'; $style = ODTStyle::importODTStyle($xml_code); $this->assertNotNull($style); $style->setProperty('padding', '5cm'); $this->assertEquals($style->getProperty('padding'), '5cm'); }
/** * Test set and get of a property. */ public function test_set_and_get() { $xml_code = '<style:style style:name="TableTest" style:family="table"> <style:table-properties table:border-model="collapsing"/> </style:style>'; $style = ODTStyle::importODTStyle($xml_code); $this->assertNotNull($style); $style->setProperty('border-model', 'separating'); $this->assertEquals($style->getProperty('border-model'), 'separating'); }
/** * Test set and get of a property. */ public function test_set_and_get() { $xml_code = '<style:style style:name="Table1.2" style:family="table-row"> <style:table-row-properties style:min-row-height="2.228cm"/> </style:style>'; $style = ODTStyle::importODTStyle($xml_code); $this->assertNotNull($style); $style->setProperty('min-row-height', '2.228cm'); $this->assertEquals($style->getProperty('min-row-height'), '2.228cm'); }
/** * Test ODT XML style definition import and conversion to string. */ public function test_import_and_to_string_2() { $xml_code = '<style:style style:family="NothingIKnow"> <style:graphic-properties draw:shadow-offset-x="0.3cm" draw:shadow-offset-y="0.3cm" draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" style:flow-with-text="false"/> <style:paragraph-properties style:text-autospace="ideograph-alpha" style:line-break="strict" style:writing-mode="lr-tb" style:font-independent-line-spacing="false"> <style:tab-stops/> </style:paragraph-properties> <style:text-properties style:use-window-font-color="true" fo:font-size="12pt" style:font-size-asian="12pt" style:font-size-complex="12pt"/> </style:style>'; $style = ODTStyle::importODTStyle($xml_code); $this->assertNotNull($style); $style_string = $style->toString(); $this->assertEquals($xml_code . "\n", $style_string); }
protected function importFromODT($styles_xml_content, $root_element) { if (empty($styles_xml_content) || empty($root_element)) { return false; } // Only import known style elements switch ($root_element) { case 'office:styles': case 'office:automatic-styles': $style_elements = XMLUtil::getElementContent($root_element, $styles_xml_content, $end); break; default: return false; } $pos = 0; $max = strlen($style_elements); while ($pos < $max) { $xml_code = XMLUtil::getNextElement($element, substr($style_elements, $pos), $end); if ($xml_code == NULL) { break; } $pos += $end + 1; // Create new ODTStyle $object = ODTStyle::importODTStyle($xml_code); if ($object != NULL) { // Success, add it switch ($root_element) { case 'office:styles': $this->addStyle($object); break; case 'office:automatic-styles': $this->addAutomaticStyle($object); break; } } } return true; }
/** * Test default ODT XML style definition import and conversion to string. */ public function test_import_and_to_string_default() { $xml_code = '<style:default-style style:name="Heading" style:family="paragraph" style:parent-style-name="Standard" style:next-style-name="Text_20_body" style:class="text"> <style:paragraph-properties fo:margin-top="0.423cm" fo:margin-bottom="0.212cm" fo:keep-with-next="always"/> <style:text-properties style:font-name="Bitstream Vera Sans1" fo:font-size="14pt" style:font-name-asian="Bitstream Vera Sans2" style:font-size-asian="14pt" style:font-name-complex="Bitstream Vera Sans2" style:font-size-complex="14pt"/> </style:default-style>'; // The order of attributes will change! This is OK. $expected = '<style:default-style style:name="Heading" style:parent-style-name="Standard" style:class="text" style:next-style-name="Text_20_body" style:family="paragraph" >' . "\n"; $expected .= '<style:paragraph-properties fo:margin-top="0.423cm" fo:margin-bottom="0.212cm" fo:keep-with-next="always" />' . "\n"; $expected .= '<style:text-properties fo:font-size="14pt" style:font-size-asian="14pt" style:font-size-complex="14pt" style:font-name="Bitstream Vera Sans1" style:font-name-asian="Bitstream Vera Sans2" style:font-name-complex="Bitstream Vera Sans2" />' . "\n"; $expected .= '</style:default-style>' . "\n"; $style = ODTStyle::importODTStyle($xml_code); $this->assertNotNull($style); $style_string = $style->toString(); $this->assertEquals(true, $style->isDefault()); $this->assertEquals($expected, $style_string); }
/** * Test set and get of a property. */ public function test_set_and_get() { $xml_code = '<text:outline-style> <text:outline-level-style text:level="1" style:num-format=""> <style:list-level-properties text:min-label-distance="10cm"/> </text:outline-level-style> <text:outline-level-style text:level="2" style:num-format=""> <style:list-level-properties text:min-label-distance="9cm"/> </text:outline-level-style> <text:outline-level-style text:level="3" style:num-format=""> <style:list-level-properties text:min-label-distance="8cm"/> </text:outline-level-style> <text:outline-level-style text:level="4" style:num-format=""> <style:list-level-properties text:min-label-distance="7cm"/> </text:outline-level-style> <text:outline-level-style text:level="5" style:num-format=""> <style:list-level-properties text:min-label-distance="6cm"/> </text:outline-level-style> <text:outline-level-style text:level="6" style:num-format=""> <style:list-level-properties text:min-label-distance="5cm"/> </text:outline-level-style> <text:outline-level-style text:level="7" style:num-format=""> <style:list-level-properties text:min-label-distance="4cm"/> </text:outline-level-style> <text:outline-level-style text:level="8" style:num-format=""> <style:list-level-properties text:min-label-distance="3cm"/> </text:outline-level-style> <text:outline-level-style text:level="9" style:num-format=""> <style:list-level-properties text:min-label-distance="2cm"/> </text:outline-level-style> <text:outline-level-style text:level="10" style:num-format=""> <style:list-level-properties text:min-label-distance="1cm"/> </text:outline-level-style> </text:outline-style>'; $style = ODTStyle::importODTStyle($xml_code); $this->assertNotNull($style); $style->setPropertyForLevel(5, 'text-min-label-distance', '999cm'); $dist = $style->getPropertyFromLevel(1, 'text-min-label-distance'); $this->assertEquals('10cm', $dist); $dist = $style->getPropertyFromLevel(2, 'text-min-label-distance'); $this->assertEquals('9cm', $dist); $dist = $style->getPropertyFromLevel(3, 'text-min-label-distance'); $this->assertEquals('8cm', $dist); $dist = $style->getPropertyFromLevel(4, 'text-min-label-distance'); $this->assertEquals('7cm', $dist); $dist = $style->getPropertyFromLevel(5, 'text-min-label-distance'); $this->assertEquals('999cm', $dist); $dist = $style->getPropertyFromLevel(6, 'text-min-label-distance'); $this->assertEquals('5cm', $dist); $dist = $style->getPropertyFromLevel(7, 'text-min-label-distance'); $this->assertEquals('4cm', $dist); $dist = $style->getPropertyFromLevel(8, 'text-min-label-distance'); $this->assertEquals('3cm', $dist); $dist = $style->getPropertyFromLevel(9, 'text-min-label-distance'); $this->assertEquals('2cm', $dist); $dist = $style->getPropertyFromLevel(10, 'text-min-label-distance'); $this->assertEquals('1cm', $dist); }
/** * Test set and get of a property. */ public function test_set_and_get() { $xml_code = '<text:list-style style:name="Numbering_20_1" style:display-name="Numbering 1"> <text:list-level-style-number text:level="1" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="0.499cm" fo:text-indent="-0.499cm" fo:margin-left="0.499cm"/> </style:list-level-properties> </text:list-level-style-number> <text:list-level-style-number text:level="2" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1cm" fo:text-indent="-0.499cm" fo:margin-left="1cm"/> </style:list-level-properties> </text:list-level-style-number> <text:list-level-style-number text:level="3" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.499cm" fo:text-indent="-0.499cm" fo:margin-left="1.499cm"/> </style:list-level-properties> </text:list-level-style-number> <text:list-level-style-number text:level="4" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2cm" fo:text-indent="-0.499cm" fo:margin-left="2cm"/> </style:list-level-properties> </text:list-level-style-number> <text:list-level-style-number text:level="5" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.499cm" fo:text-indent="-0.499cm" fo:margin-left="2.499cm"/> </style:list-level-properties> </text:list-level-style-number> <text:list-level-style-number text:level="6" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3cm" fo:text-indent="-0.499cm" fo:margin-left="3cm"/> </style:list-level-properties> </text:list-level-style-number> <text:list-level-style-number text:level="7" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.5cm" fo:text-indent="-0.499cm" fo:margin-left="3.5cm"/> </style:list-level-properties> </text:list-level-style-number> <text:list-level-style-number text:level="8" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.001cm" fo:text-indent="-0.499cm" fo:margin-left="4.001cm"/> </style:list-level-properties> </text:list-level-style-number> <text:list-level-style-number text:level="9" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.5cm" fo:text-indent="-0.499cm" fo:margin-left="4.5cm"/> </style:list-level-properties> </text:list-level-style-number> <text:list-level-style-number text:level="10" text:style-name="Numbering_20_Symbols" style:num-suffix="." style:num-format="1"> <style:list-level-properties text:list-level-position-and-space-mode="label-alignment"> <style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.001cm" fo:text-indent="-0.499cm" fo:margin-left="5.001cm"/> </style:list-level-properties> </text:list-level-style-number> </text:list-style>'; $style = ODTStyle::importODTStyle($xml_code); $this->assertNotNull($style); $style->setPropertyForLevel(5, 'list-tab-stop-position', '999cm'); $dist = $style->getPropertyFromLevel(1, 'list-tab-stop-position'); $this->assertEquals('0.499cm', $dist); $dist = $style->getPropertyFromLevel(2, 'list-tab-stop-position'); $this->assertEquals('1cm', $dist); $dist = $style->getPropertyFromLevel(3, 'list-tab-stop-position'); $this->assertEquals('1.499cm', $dist); $dist = $style->getPropertyFromLevel(4, 'list-tab-stop-position'); $this->assertEquals('2cm', $dist); $dist = $style->getPropertyFromLevel(5, 'list-tab-stop-position'); $this->assertEquals('999cm', $dist); $dist = $style->getPropertyFromLevel(6, 'list-tab-stop-position'); $this->assertEquals('3cm', $dist); $dist = $style->getPropertyFromLevel(7, 'list-tab-stop-position'); $this->assertEquals('3.5cm', $dist); $dist = $style->getPropertyFromLevel(8, 'list-tab-stop-position'); $this->assertEquals('4.001cm', $dist); $dist = $style->getPropertyFromLevel(9, 'list-tab-stop-position'); $this->assertEquals('4.5cm', $dist); $dist = $style->getPropertyFromLevel(10, 'list-tab-stop-position'); $this->assertEquals('5.001cm', $dist); }