Skip to content

Commit

Permalink
Added support for language and contry settings. These are both taken …
Browse files Browse the repository at this point in the history
…from the property 'lang', e.g. 'de-de' sets the language to german and country to germany. If there is no '-' it is assumed that only the language shall be set.
  • Loading branch information
lpaulsen93 committed May 14, 2015
1 parent 920789a commit 3c12cb0
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ChangeLog.txt
@@ -1,3 +1,9 @@
2015-05-14 LarsDW223

* Added support for language and country settings. These are both taken from the property
'lang', e.g. 'de-de' sets the language to german and country to germany. If there is no '-'
it is assumed that only the language shall be set.

2015-05-12 LarsDW223

* Added support for text indentation for the first line of a paragraph.
Expand Down
46 changes: 46 additions & 0 deletions helper/stylefactory.php
Expand Up @@ -157,6 +157,14 @@ public static function createTextStyle(&$style, $properties, $disabled_props = N
$display = $properties ['display'];
$attrs++;
}
if ( empty ($disabled_props ['display']) === true ) {
$display = $properties ['display'];
$attrs++;
}
if ( empty ($disabled_props ['lang']) === true ) {
$lang = $properties ['lang'];
$attrs++;
}
if ( empty ($parent) === false ) {
$attrs++;
}
Expand All @@ -178,6 +186,13 @@ public static function createTextStyle(&$style, $properties, $disabled_props = N
unset($odt_valign);
}

// Separate country from language
if ( empty($lang) === false ) {
$parts = preg_split ('/-/', $lang);
$lang = $parts [0];
$country = $parts [1];
}

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

Expand Down Expand Up @@ -229,6 +244,16 @@ public static function createTextStyle(&$style, $properties, $disabled_props = N
if ( empty($display) === false ) {
$style .= 'text:display="'.$display.'" ';
}
if ( empty($lang) === false ) {
$style .= 'fo:language="'.$lang.'" ';
$style .= 'style:language-asian="'.$lang.'" ';
$style .= 'style:language-complex="'.$lang.'" ';
}
if ( empty($country) === false ) {
$style .= 'fo:country="'.$country.'" ';
$style .= 'style:country-asian="'.$country.'" ';
$style .= 'style:country-complex="'.$country.'" ';
}
$style .= '/>';
$style .= '</style:style>';

Expand Down Expand Up @@ -308,6 +333,10 @@ public static function createParagraphStyle(&$style, $properties, $disabled_prop
$display = $properties ['display'];
$attrs++;
}
if ( empty ($disabled_props ['lang']) === true ) {
$lang = $properties ['lang'];
$attrs++;
}
if ( empty ($disabled_props ['text-indent']) === true ) {
$text_indent = $properties ['text-indent'];
$attrs++;
Expand All @@ -333,6 +362,13 @@ public static function createParagraphStyle(&$style, $properties, $disabled_prop
unset($odt_valign);
}

// Separate country from language
if ( empty($lang) === false ) {
$parts = preg_split ('/-/', $lang);
$lang = $parts [0];
$country = $parts [1];
}

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

Expand Down Expand Up @@ -396,6 +432,16 @@ public static function createParagraphStyle(&$style, $properties, $disabled_prop
if ( empty($display) === false ) {
$style .= 'text:display="'.$display.'" ';
}
if ( empty($lang) === false ) {
$style .= 'fo:language="'.$lang.'" ';
$style .= 'style:language-asian="'.$lang.'" ';
$style .= 'style:language-complex="'.$lang.'" ';
}
if ( empty($country) === false ) {
$style .= 'fo:country="'.$country.'" ';
$style .= 'style:country-asian="'.$country.'" ';
$style .= 'style:country-complex="'.$country.'" ';
}
$style .= '/>';
$style .= '</style:style>';

Expand Down
2 changes: 1 addition & 1 deletion plugin.info.txt
@@ -1,7 +1,7 @@
base odt
author Andreas Gohr, Aurelien Bompard, Florian Lamml, LarsDW223
email andi@splitbrain.org, aurelien@bompard.org, infor@florian-lamml.de
date 2015-05-12
date 2015-05-14
name Open Document Plugin
desc Export the current Wiki page to a OpenOffice ODT file
url http://www.dokuwiki.org/plugin:odt
2 changes: 2 additions & 0 deletions renderer.php
Expand Up @@ -739,6 +739,7 @@ function header($text, $level, $pos){
}

function hr() {
$this->p_close();
$this->doc .= '<text:p text:style-name="Horizontal_20_Line"/>';
}

Expand Down Expand Up @@ -913,6 +914,7 @@ function footnote_close() {
$this->doc .= '<text:note text:id="ftn'.$i.'" text:note-class="footnote">';
$this->doc .= '<text:note-citation>'.($i+1).'</text:note-citation>';
$this->doc .= '<text:note-body>';
//FIXME: Can break document if paragraphs have been opened inside of $footnote!!!
$this->doc .= '<text:p text:style-name="Footnote">';
$this->doc .= $footnote;
$this->doc .= '</text:p>';
Expand Down

0 comments on commit 3c12cb0

Please sign in to comment.