/**
  * 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="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.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 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="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 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);
 }
Ejemplo n.º 7
0
 /**
  * @param null $source
  */
 public function addAutomaticStyle(ODTStyle $new)
 {
     $name = $new->getProperty('style-name');
     if ($this->auto_styles_by_name[$name] == NULL) {
         $this->auto_styles[] = $new;
         if (!empty($name)) {
             $this->auto_styles_by_name[$name] = $new;
         }
         return true;
     }
     // Do not overwrite an already existing style.
     return false;
 }
 /**
  * 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);
 }
Ejemplo n.º 10
0
 /**
  * Set style properties by importing values from a properties array.
  * Properties might be disabled by setting them in $disabled.
  * The style must have been previously created. Only those properties
  * will be accepted that are mentioned in the fields array.
  *
  * @param  $style      ODTStyle object for storing the properties
  * @param  $fields     Properties accepted by the object/class
  * @param  $properties Properties to be imported
  * @param  $disabled   Properties to be ignored
  */
 protected function importPropertiesInternal(array $fields, $properties, $disabled, &$dest = NULL)
 {
     parent::importPropertiesInternal($fields, $properties, $disabled, $dest);
 }
 /**
  * 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);
 }
Ejemplo n.º 12
0
 /**
  * @param null $source
  */
 public function addStyleInternal(&$dest, &$dest_by_name, ODTStyle $new, $overwrite = false)
 {
     if ($new->isDefault()) {
         // The key for a default style is the family.
         $family = $new->getFamily();
         // Search for default style with same family.
         for ($index = 0; $index < count($dest); $index++) {
             if ($dest[$index]->isDefault() && $dest[$index]->getFamily() == $family) {
                 // Only overwrite it if allowed.
                 if ($overwrite) {
                     $dest[$index] = $new;
                 }
                 return false;
             }
         }
         // Default style for that family does not exist yet, add it.
         $dest[] = $new;
     } else {
         // The key for a normal style is the name.
         $name = $new->getProperty('style-name');
         if ($dest_by_name[$name] == NULL) {
             $dest[] = $new;
             if (!empty($name)) {
                 $dest_by_name[$name] = $new;
             }
             return true;
         } elseif ($overwrite) {
             for ($index = 0; $index < count($dest); $index++) {
                 if ($dest[$index] == $dest_by_name[$name]) {
                     $dest[$index] = $new;
                     break;
                 }
             }
             $dest_by_name[$name] = $new;
             return true;
         }
     }
     // Do not overwrite an already existing style.
     return false;
 }
Ejemplo n.º 13
0
 /**
  * Set style properties by importing values from a properties array.
  * Properties might be disabled by setting them in $disabled.
  * The style must have been previously created. Only those properties
  * will be accepted that are mentioned in the fields array.
  *
  * @param  $style      ODTStyle object for storing the properties
  * @param  $fields     Properties accepted by the object/class
  * @param  $properties Properties to be imported
  * @param  $disabled   Properties to be ignored
  */
 protected function importPropertiesInternal($fields, $properties, $disabled, &$dest = NULL)
 {
     parent::importPropertiesInternal($fields, $properties, $disabled);
     // Make sure that our family is always set and never changed
     $this->setPropertyInternal('style-family', self::$style_fields['style-family'][0], $this->getFamily(), self::$style_fields['style-family'][1]);
 }