#!/bin/sh
#\
exec tclsh "$0" "$@"

cd [file dirname [info script]]
source ../ooxml.tcl
source ../ooxml-docx.tcl
source strings.tcl
namespace import ::ooxml::docx::docx

set docx [docx new]

featuresCovered "Import numbering styles from another .docx file, defining numbering styles."
# Importing numbering definition from another docx
$docx import numbering docx-example4-in.docx

# Some other random paragraph style definition
$docx style paragraph mystyle -color 00FF00 -fontsize 8pt

# Use the imported style
$docx paragraph "First" -numberingStyle 1 
$docx paragraph "Second" -numberingStyle 1 -level 0
$docx paragraph "Sub Second frist" -numberingStyle 1 -level 1
$docx paragraph "Sub Second second" -numberingStyle 1 -level 1 -pstyle mystyle
$docx paragraph "Third" -numberingStyle 1 -level 0

# Add some space
$docx paragraph ""
$docx paragraph ""

# Create a numbering definition from scratch
$docx numbering abstractNum 3 {
    {
        -numberFormat upperRoman
        -levelText "%1."
        -start 3
        -align start
        -indentation {start 2cm hanging 0.5cm}
        -fontsize 18pt
    }
    {
        -numberFormat chicago
        -levelText "%2"
        -indentation {start 3cm hanging 0.5cm}
        -fontsize 8pt
    }
}
puts [$docx numbering abstractNumIds]
# Use it
$docx paragraph "First" -numberingStyle 3
$docx paragraph "Second" -numberingStyle 3 -level 0
$docx paragraph "Sub Second first" -numberingStyle 3 -level 1
#$docx paragraph "Sub Second second" -numberingStyle 3 -level 1 -pstyle mystyle
$docx paragraph "Sub Second second" -numberingStyle 3 -level 1 
$docx paragraph "Third" -numberingStyle 3 -level 0 

$docx numbering abstractNum 4 {
    {
        -numberFormat bullet
        -levelText ""
        -start 3
        -indentation {start 1cm hanging 1.5cm}
        -font Symbol
    }
    {
        -numberFormat bullet
        -levelText "/"
        -indentation {start 2cm hanging 0.5cm}
    }
}
$docx paragraph "First $loreipsum" -numberingStyle 4
$docx paragraph "Second" -numberingStyle 4 -level 0
$docx paragraph "Sub Second frist" -numberingStyle 4 -level 1
$docx paragraph "Sub Second second" -numberingStyle 4 -level 1 -pstyle mystyle
$docx paragraph "Third" -numberingStyle 4 -level 0

$docx write docx-example5.docx
$docx destroy
