22 import re, sys, os.path
23 sys.path.append(os.path.dirname(__file__))
24 from odf.style import Style, TextProperties, ListLevelProperties
25 from odf.text import ListStyle,ListLevelStyleNumber,ListLevelStyleBullet
28 Create a <text:list-style> element from a string or array. 30 List styles require a lot of code to create one level at a time. 31 These routines take a string and delimiter, or a list of 32 strings, and creates a <text:list-style> element for you. 33 Each item in the string (or array) represents a list level 34 * style for levels 1-10.</p> 36 * <p>If an item contains <code>1</code>, <code>I</code>, 37 * <code>i</code>, <code>A</code>, or <code>a</code>, then it is presumed 38 * to be a numbering style; otherwise it is a bulleted style based on the 39 * first character in the item.</p> 43 SHOW_ALL_LEVELS =
True 44 SHOW_ONE_LEVEL =
False 47 specArray = specifiers.split(delim)
48 return styleFromList( name, specArray, spacing, showAllLevels )
60 numFormatPattern = re.compile(
"([1IiAa])")
61 cssLengthPattern = re.compile(
"([^a-z]+)\\s*([a-z]+)?")
62 m = cssLengthPattern.search( spacing )
64 cssLengthNum = float(m.group(1))
65 if (m.lastindex == 2):
66 cssLengthUnits = m.group(2)
68 while i < len(specArray):
69 specification = specArray[i]
70 m = numFormatPattern.search(specification)
72 numberFormat = m.group(1)
73 numPrefix = specification[0:m.start(1)]
74 numSuffix = specification[m.end(1):]
82 bullet = specification
91 lls.setAttribute(
'numprefix', numPrefix)
93 lls.setAttribute(
'numsuffix', numSuffix)
94 lls.setAttribute(
'displaylevels', displayLevels)
98 llp.setAttribute(
'spacebefore', str(cssLengthNum * (i+1)) + cssLengthUnits)
99 llp.setAttribute(
'minlabelwidth', str(cssLengthNum) + cssLengthUnits)
100 lls.addElement( llp )
101 listStyle.addElement(lls)
def ListLevelStyleBullet(args)
def ListLevelStyleNumber(args)
def styleFromList(styleName, specArray, spacing, showAllLevels)
def styleFromString(name, specifiers, delim, spacing, showAllLevels)
def ListLevelProperties(args)