Skip to content

Commit cb7c2e1

Browse files
committed
Added support for inserting a table of contents in the exported ODT file.
Use the syntax tag '{{odt>toc:setting=value}}' or only {{odt>toc}} for using default settings. See the function header of insert_TOC() for a detailed description of the possible settings. The page numbers are just a counter. The TOC needs to be updated e.g. in LibreOffice to get the real page numbers!
1 parent 09f226c commit cb7c2e1

File tree

9 files changed

+293
-8
lines changed

9 files changed

+293
-8
lines changed

ChangeLog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2015-07-08 LarsDW223
2+
3+
* Added syntax tag for including a TOC in the exported ODT file.
4+
15
2015-07-04 LarsDW223
26

37
* Added/merged support for exporting books to ODT (interface to bookcreator plugin).

helper/stylefactory.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@ public static function createParagraphStyle(&$style, $properties, $disabled_prop
273273
'style-display-name' => array ('section' => 'header', 'name' => 'style:display-name', 'is_attr' => false),
274274
'style-parent' => array ('section' => 'header', 'name' => 'style:parent-style-name', 'is_attr' => true),
275275
'style-class' => array ('section' => 'header', 'name' => 'style:class', 'is_attr' => true),
276+
'style-position' => array ('section' => 'tab-stop', 'name' => 'style:position', 'is_attr' => true),
277+
'style-type' => array ('section' => 'tab-stop', 'name' => 'style:type', 'is_attr' => true),
278+
'style-leader-style' => array ('section' => 'tab-stop', 'name' => 'style:leader-style', 'is_attr' => true),
279+
'style-leader-text' => array ('section' => 'tab-stop', 'name' => 'style:leader-text', 'is_attr' => true),
276280
'text-align' => array ('section' => 'paragraph', 'name' => 'fo:text-align', 'is_attr' => true),
277281
'text-indent' => array ('section' => 'paragraph', 'name' => 'fo:text-indent', 'is_attr' => true),
278282
'margin-top' => array ('section' => 'paragraph', 'name' => 'fo:margin-top', 'is_attr' => true),
@@ -356,6 +360,7 @@ public static function createParagraphStyle(&$style, $properties, $disabled_prop
356360
$header = '';
357361
$text = '';
358362
$paragraph = '';
363+
$tab = '';
359364
foreach ($properties as $property => $value) {
360365
if ( empty ($disabled_props [$property]) && !empty ($properties [$property]) ) {
361366
switch ($params [$property]['section']) {
@@ -388,6 +393,11 @@ public static function createParagraphStyle(&$style, $properties, $disabled_prop
388393
$paragraph .= ' style:auto-text-indent="false" ';
389394
}
390395
break;
396+
397+
case 'tab-stop':
398+
$tab .= $params [$property]['name'].'="'.$value.'" ';
399+
$tab .= self::writeExtensionNames ($params [$property]['name'], $value);
400+
break;
391401
}
392402
}
393403
}
@@ -405,8 +415,14 @@ public static function createParagraphStyle(&$style, $properties, $disabled_prop
405415
// Build style.
406416
$style = '<style:style '.$header.' style:family="paragraph"';
407417
$style .= '>';
408-
$style .= '<style:paragraph-properties '.$paragraph.'/>';
409-
$style .= '<style:text-properties '.$text.'/>';
418+
$style .= '<style:paragraph-properties '.$paragraph.'>';
419+
if ( !empty($tab) ) {
420+
$style .= '<style:tab-stops><style:tab-stop '.$tab.'/></style:tab-stops>';
421+
}
422+
$style .= '</style:paragraph-properties>';
423+
if ( !empty($text) ) {
424+
$style .= '<style:text-properties '.$text.'/>';
425+
}
410426
$style .= '</style:style>';
411427

412428
return $style_name;

lang/de-informal/lang.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
$lang['view'] = 'Die Seite im Open Document Format exportieren';
1111
$lang['export_odt_button'] = 'ODT exportieren';
1212
$lang['tpl_not_found'] = 'WARNUNG: Die ODT Vorlage "%s" konnte im Vorlagenverzeichnis "%s" nicht gefunden werden. Es wird die Standardvorlage verwendet.';
13+
$lang['toc_title'] = 'Inhaltsverzeichnis';
14+

lang/de/lang.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
$lang['view'] = 'Ins Open-Document-Format exportieren';
1111
$lang['export_odt_button'] = 'ODT exportieren';
1212
$lang['tpl_not_found'] = 'WARNUNG: Die ODT Vorlage "%s" konnte im Vorlagenverzeichnis "%s" nicht gefunden werden. Es wird die Standardvorlage verwendet.';
13+
$lang['toc_title'] = 'Inhaltsverzeichnis';

lang/en/lang.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@
1111
// template not found in the directory
1212
$lang['tpl_not_found'] = 'WARNING : the ODT template "%s" was not found in the templates directory "%s". Using the default template.';
1313

14+
// default TOC title
15+
$lang['toc_title'] = 'Table of Contents';

plugin.info.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
base odt
22
author Andreas Gohr, Aurelien Bompard, Florian Lamml, LarsDW223
33
email andi@splitbrain.org, aurelien@bompard.org, infor@florian-lamml.de
4-
date 2015-07-04
4+
date 2015-07-08
55
name Open Document Plugin
66
desc Export the current Wiki page to a OpenOffice ODT file
77
url http://www.dokuwiki.org/plugin:odt

renderer/book.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public function finalize_ODTfile() {
5959

6060
$this->meta->setTitle($this->title);
6161

62+
// Insert TOC (if required)
63+
$this->insert_TOC();
64+
6265
parent::finalize_ODTfile();
6366
}
6467

0 commit comments

Comments
 (0)