Skip to content

Commit

Permalink
Added support for multi columns frame to provide it to the wrap plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
lpaulsen93 committed May 7, 2015
1 parent a7bd42b commit a544f07
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ChangeLog.txt
@@ -1,3 +1,9 @@
2015-05-07 LarsDW223

* Added support for multi column frames (to provide it to the wrap plugin).
New functions are: createMultiColumnFrameStyle (stylefactory), _odtOpenMultiColumnFrame,
_odtCloseMultiColumnFrame.

2015-05-05 LarsDW223

* Bugfix: The function 'adjustValueForODT' did not convert the color name 'black' to '#000000'. This is fixed now.
Expand Down
55 changes: 55 additions & 0 deletions helper/stylefactory.php
Expand Up @@ -637,5 +637,60 @@ public static function createTableColumnStyle(&$style, $properties, $disabled_pr

return $style_name;
}

/**
* This function creates a frame style for multiple columns, using the style as set in the assoziative array $properties.
* The parameters in the array should be named as the CSS property names e.g. 'color' or 'background-color'.
* Properties which shall not be used in the style can be disabled by setting the value in disabled_props
* to 1 e.g. $disabled_props ['color'] = 1 would block the usage of the color property.
*
* The currently supported properties are:
* column-count, column-rule, column-gap
*
* The function returns the name of the new style or NULL if all relevant properties are empty.
*
* @author LarsDW223
*/
public static function createMultiColumnFrameStyle(&$style, $properties, $disabled_props = NULL) {
$attrs = 0;

if ( empty ($disabled_props ['column-count']) === true ) {
$columns = $properties ['column-count'];
$attrs++;
}

if ( empty ($disabled_props ['column-rule']) === true ) {
$rule_parts = explode (' ', $properties ['column-rule']);
$attrs++;
}

if ( empty ($disabled_props ['column-gap']) === true ) {
$gap = $properties ['column-gap'];
$attrs++;
}

// If all relevant properties are empty or disabled, then there
// are no attributes for our style. Return NULL to indicate 'no style required'.
if ( $attrs == 0 ) {
return NULL;
}

// Create style name.
$style_name = self::getNewStylename ('Frame');

$width = '1000*';

$style = '<style:style style:name="'.$style_name.'" style:family="graphic" style:parent-style-name="Frame">
<style:graphic-properties fo:border="none" style:vertical-pos="top" style:vertical-rel="paragraph-content" style:horizontal-pos="center" style:horizontal-rel="paragraph">
<style:columns fo:column-count="'.$columns.'" fo:column-gap="'.$gap.'">
<style:column-sep style:style="'.$rule_parts [1].'" style:color="'.$rule_parts [2].'" style:width="'.$rule_parts [0].'"/>
<style:column style:rel-width="'.$width.'" fo:start-indent="0cm" fo:end-indent="0cm"/>
<style:column style:rel-width="'.$width.'" fo:start-indent="0cm" fo:end-indent="0cm"/>
<style:column style:rel-width="'.$width.'" fo:start-indent="0cm" fo:end-indent="0cm"/>
</style:columns>
</style:graphic-properties></style:style>';

return $style_name;
}
}
?>
37 changes: 37 additions & 0 deletions renderer.php
Expand Up @@ -2572,6 +2572,43 @@ public function _processCSSClass(&$properties, helper_plugin_odt_cssimport $impo
}
}
}

/**
* This function opens a multi column frame according to the parameters in $properties.
* See function createMultiColumnFrameStyle of helper class stylefactory.php for more
* information about the supported properties/CSS styles.
*
* @author LarsDW223
*/
function _odtOpenMultiColumnFrame ($properties) {
// Create style name.
$style_name = $this->factory->createMultiColumnFrameStyle ($style, $properties);
$this->autostyles[$style_name] = $style;

$width_abs = $this->_getAbsWidthMindMargins (100);

// Group the frame so that they are stacked one on each other.
$this->p_close();
$this->doc .= '<text:p>';

// Draw a frame with a text box in it. the text box will be left opened
// to grow with the content (requires fo:min-height in $style_name).
$this->doc .= '<draw:frame draw:style-name="'.$style_name.'" draw:name="Frame1"
text:anchor-type="paragraph" svg:width="'.$width_abs.'cm" draw:z-index="0">';
$this->doc .= '<draw:text-box fo:min-height="5cm">';
}

/**
* This function closes a multi column frame (previously opened with _odtOpenMultiColumnFrame).
*
* @author LarsDW223
*/
function _odtCloseMultiColumnFrame () {
$this->doc .= '</draw:text-box></draw:frame>';
$this->doc .= '</text:p>';

$this->div_z_index -= 5;
}
}

//Setup VIM: ex: et ts=4 enc=utf-8 :

0 comments on commit a544f07

Please sign in to comment.