22 import re, sys, os.path
 
   23 sys.path.append(os.path.dirname(__file__))
 
   24 from style 
import Style, TextProperties, ListLevelProperties
 
   25 from 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.</p> 
   42 SHOW_ALL_LEVELS = 
True 
   43 SHOW_ONE_LEVEL = 
False 
   46     specArray = specifiers.split(delim)
 
   47     return styleFromList( name, specArray, spacing, showAllLevels )
 
   59     numFormatPattern = re.compile(
"([1IiAa])")
 
   60     cssLengthPattern = re.compile(
"([^a-z]+)\\s*([a-z]+)?")
 
   61     m = cssLengthPattern.search( spacing )
 
   63         cssLengthNum = float(m.group(1))
 
   64         if (m.lastindex == 2):
 
   65             cssLengthUnits = m.group(2)
 
   67     while i < len(specArray):
 
   68         specification = specArray[i]
 
   69         m = numFormatPattern.search(specification)
 
   71             numberFormat = m.group(1)
 
   72             numPrefix = specification[0:m.start(1)]
 
   73             numSuffix = specification[m.end(1):]
 
   81             bullet = specification
 
   90                 lls.setAttribute(
'numprefix', numPrefix)
 
   92                 lls.setAttribute(
'numsuffix', numSuffix)
 
   93             lls.setAttribute(
'displaylevels', displayLevels)
 
   97         llp.setAttribute(
'spacebefore', str(cssLengthNum * (i+1)) + cssLengthUnits)
 
   98         llp.setAttribute(
'minlabelwidth', str(cssLengthNum) + cssLengthUnits)
 
  100         listStyle.addElement(lls)