/** * Constructor. */ public function __construct() { parent::__construct(); // Load config $this->config = plugin_load('helper', 'odt_config'); $this->config->load($warning); }
/** * Constructor. */ public function __construct() { parent::__construct(); $this->settings = new ODTSettings(); // Create styles. $this->styleset = new ODTDefaultStyles(); $this->styleset->import(); }
/** * Constructor. */ public function __construct() { parent::__construct(); $this->settings = new ODTSettings(); $this->factory = plugin_load('helper', 'odt_stylefactory'); // Create default styles (from styles.xml). $this->styleset = new ODTDefaultStyles(); $this->styleset->import(); }
/** * Constructor. */ public function __construct() { parent::__construct(); // Load config $this->config = plugin_load('helper', 'odt_config'); $this->config->load($warning); // Create styles. $this->styleset = new ODTDefaultStyles(); $this->styleset->import(); }
/** * @param string $src * @param $width * @param $height * @param $align * @param $title * @param $style * @param $returnonly */ function _odtAddImage($src, $width = NULL, $height = NULL, $align = NULL, $title = NULL, $style = NULL, $returnonly = false) { $doc = ''; if (file_exists($src)) { list($ext, $mime) = mimetype($src); $name = 'Pictures/' . md5($src) . '.' . $ext; $this->docHandler->addFile($name, $mime, io_readfile($src, false)); } else { $name = $src; } // make sure width and height are available if (!$width || !$height) { list($width, $height) = $this->_odtGetImageSize($src, $width, $height); } else { // Adjust values for ODT $width = $this->adjustXLengthValueForODT($width); $height = $this->adjustYLengthValueForODT($height); } if ($align) { $anchor = 'paragraph'; } else { $anchor = 'as-char'; } if (!$style or !array_key_exists($style, $this->autostyles)) { $style = $this->styleset->getStyleName('media ' . $align); } if ($title) { $doc .= '<draw:frame draw:style-name="' . $style . '" draw:name="' . $this->_xmlEntities($title) . ' Legend" text:anchor-type="' . $anchor . '" draw:z-index="0" svg:width="' . $width . '">'; $doc .= '<draw:text-box>'; $doc .= '<text:p text:style-name="' . $this->styleset->getStyleName('legend center') . '">'; } $doc .= '<draw:frame draw:style-name="' . $style . '" draw:name="' . $this->_xmlEntities($title) . '" text:anchor-type="' . $anchor . '" draw:z-index="0" svg:width="' . $width . '" svg:height="' . $height . '" >'; $doc .= '<draw:image xlink:href="' . $this->_xmlEntities($name) . '" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>'; $doc .= '</draw:frame>'; if ($title) { $doc .= $this->_xmlEntities($title) . '</text:p></draw:text-box></draw:frame>'; } if ($returnonly) { return $doc; } else { $this->doc .= $doc; } }
/** * Constructor. */ public function __construct() { parent::__construct(); $this->settings = new ODTSettings(); }
/** * This function opens a textbox in a frame. * * The currently supported CSS properties are: * background-color, color, padding, margin, display, border-radius, min-height. * The background-image is simulated using a picture frame. * FIXME: Find a way to successfuly use the background-image in the graphic style (see comments). * * The div should be closed by calling '_odtDivCloseAsFrame'. * * @author LarsDW223 * * @param array $properties */ function _odtOpenTextBoxUseProperties($properties) { if ($this->state->getInFrame()) { // Do not open a nested frame as this will make the content ofthe nested frame disappear. //return; } $this->div_z_index += 5; $this->style_count++; $odt_bg = $properties['background-color']; $odt_fo = $properties['color']; $padding_left = $properties['padding-left']; $padding_right = $properties['padding-right']; $padding_top = $properties['padding-top']; $padding_bottom = $properties['padding-bottom']; $margin_left = $properties['margin-left']; $margin_right = $properties['margin-right']; $margin_top = $properties['margin-top']; $margin_bottom = $properties['margin-bottom']; $display = $properties['display']; $fo_border = $properties['border']; $border_color = $properties['border-color']; $border_width = $properties['border-width']; $radius = $properties['border-radius']; $picture = $properties['background-image']; $pic_positions = preg_split('/\\s/', $properties['background-position']); $min_height = $properties['min-height']; $width = $properties['width']; $horiz_pos = $properties['float']; $pic_link = ''; $pic_width = ''; $pic_height = ''; if (!empty($picture)) { // If a picture/background-image is set in the CSS, than we insert it manually here. // This is a workaround because ODT does not support the background-image attribute in a span. $pic_link = $this->_odtAddImageAsFileOnly($picture); list($pic_width, $pic_height) = $this->_odtGetImageSizeString($picture); } if (empty($horiz_pos)) { $horiz_pos = 'center'; } if (empty($width)) { $width = '100%'; } if (empty($border_color)) { $border_color = $odt_bg; } if (!empty($pic_positions[0])) { $pic_positions[0] = $this->adjustXLengthValueForODT($pic_positions[0]); } if (empty($min_height)) { $min_height = '1pt'; } // Different handling for relative and absolute size... if ($width[strlen($width) - 1] == '%') { // Convert percentage values to absolute size, respecting page margins $width = trim($width, '%'); $width_abs = $this->_getAbsWidthMindMargins($width) . 'cm'; } else { // Absolute values may include not supported units. // Adjust. $width_abs = $this->adjustXLengthValueForODT($width); } // Add our styles. $style_name = 'odt_auto_style_div_' . $this->style_count; $style = '<style:style style:name="' . $style_name . '_text_frame" style:family="graphic"> <style:graphic-properties draw:textarea-horizontal-align="left" style:horizontal-pos="' . $horiz_pos . '" fo:background-color="' . $odt_bg . '" style:background-transparency="100%" '; if (!empty($odt_bg)) { $style .= 'draw:fill="solid" draw:fill-color="' . $odt_bg . '" '; } else { $style .= 'draw:fill="none" '; } if (!empty($border_color)) { $style .= 'svg:stroke-color="' . $border_color . '" '; } if (!empty($border_width)) { $style .= 'svg:stroke-width="' . $border_width . '" '; } if (!empty($padding_left)) { $style .= 'fo:padding-left="' . $padding_left . '" '; } if (!empty($padding_right)) { $style .= 'fo:padding-right="' . $padding_right . '" '; } if (!empty($padding_top)) { $style .= 'fo:padding-top="' . $padding_top . '" '; } if (!empty($padding_bottom)) { $style .= 'fo:padding-bottom="' . $padding_bottom . '" '; } if (!empty($margin_left)) { $style .= 'fo:margin-left="' . $margin_left . '" '; } if (!empty($margin_right)) { $style .= 'fo:margin-right="' . $margin_right . '" '; } if (!empty($margin_top)) { $style .= 'fo:margin-top="' . $margin_top . '" '; } if (!empty($margin_bottom)) { $style .= 'fo:margin-bottom="' . $margin_bottom . '" '; } if (!empty($fo_border)) { $style .= 'fo:border="' . $fo_border . '" '; } $style .= 'fo:min-height="' . $min_height . '" style:wrap="none"'; $style .= '>'; // FIXME: Delete the part below 'if ( $picture != NULL ) {...}' // and use this background-image definition. For some reason the background-image is not displayed. // Help is welcome. /*$style .= '<style:background-image '; $style .= 'xlink:href="'.$pic_link.'" xlink:type="simple" xlink:actuate="onLoad" style:position="center center" style:repeat="no-repeat" draw:opacity="100%"/>';*/ $style .= '</style:graphic-properties>'; $style .= '</style:style>'; $style .= '<style:style style:name="' . $style_name . '_image_frame" style:family="graphic"> <style:graphic-properties svg:stroke-color="' . $odt_bg . '" draw:fill="none" draw:fill-color="' . $odt_bg . '" draw:textarea-horizontal-align="left" draw:textarea-vertical-align="center" style:wrap="none"/> </style:style> <style:style style:name="' . $style_name . '_text_box" style:family="paragraph"> <style:text-properties fo:color="' . $odt_fo . '"/> <style:paragraph-properties fo:margin-left="' . $padding_left . '" fo:margin-right="10pt" fo:text-indent="0cm"/> </style:style>'; // Add style to our document // (as unknown style because style-family graphic is not supported) $style_obj = ODTUnknownStyle::importODTStyle($style); $this->docHandler->addAutomaticStyle($style_obj); // Group the frame so that they are stacked one on each other. $this->p_close(); $this->p_open(); $this->linebreak(); if ($display == NULL) { $this->doc .= '<draw:g>'; } else { $this->doc .= '<draw:g draw:display="' . $display . '">'; } $anchor_type = 'paragraph'; // FIXME: Later try to get nested frames working - probably with anchor = as-char if ($this->state->getInFrame()) { $anchor_type = 'as-char'; } // Draw a frame with the image in it, if required. // FIXME: delete this part if 'background-image' in graphic style is working. if ($picture != NULL) { $this->doc .= '<draw:frame draw:style-name="' . $style_name . '_image_frame" draw:name="Bild1" text:anchor-type="paragraph" svg:x="' . $pic_positions[0] . '" svg:y="' . $pic_positions[0] . '" svg:width="' . $pic_width . '" svg:height="' . $pic_height . '" draw:z-index="' . ($this->div_z_index + 1) . '"> <draw:image xlink:href="' . $pic_link . '" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/> </draw:frame>'; } // 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 . '_text_frame" draw:name="Bild1" text:anchor-type="' . $anchor_type . '" svg:x="0cm" svg:y="0cm" svg:width="' . $width_abs . '" svg:height="' . $min_height . '" '; $this->doc .= 'draw:z-index="' . ($this->div_z_index + 0) . '">'; $this->doc .= '<draw:text-box '; // If required use round corners. if (!empty($radius)) { $this->doc .= 'draw:corner-radius="' . $radius . '" '; } $this->doc .= '>'; $this->state->enter('frame', 'frame'); $this->state->setInFrame(true); $this->state->setInParagraph(false); }
/** * Constructor. */ public function __construct() { parent::__construct(); }