def _numbered_style(): """Create a numbered list style.""" style = ListStyle(name='_numbered_list') lls = ListLevelStyleNumber(level=1) lls.setAttribute('displaylevels', 1) lls.setAttribute('numsuffix', '. ') lls.setAttribute('numformat', '1') llp = ListLevelProperties() llp.setAttribute('listlevelpositionandspacemode', 'label-alignment') llla = ListLevelLabelAlignment(labelfollowedby='listtab') llla.setAttribute('listtabstopposition', '1.27cm') llla.setAttribute('textindent', '-0.635cm') llla.setAttribute('marginleft', '1.27cm') llp.addElement(llla) # llp.setAttribute('spacebefore', '') # llp.setAttribute('minlabelwidth', '') lls.addElement(llp) style.addElement(lls) return style
def _numbered_style(): """Create a numbered list style.""" style = ListStyle(name='_numbered_list') lls = ListLevelStyleNumber(level=1) lls.setAttribute('displaylevels', 1) lls.setAttribute('numsuffix', '. ') lls.setAttribute('numformat', '1') llp = ListLevelProperties() llp.setAttribute('listlevelpositionandspacemode', 'label-alignment') llla = ListLevelLabelAlignment(labelfollowedby='listtab') llla.setAttribute('listtabstopposition', '1.27cm') llla.setAttribute('textindent', '-0.635cm') llla.setAttribute('marginleft', '1.27cm') llp.addElement(llla) # llp.setAttribute('spacebefore', '') # llp.setAttribute('minlabelwidth', '') lls.addElement(llp) style.addElement(lls) return style
def styleFromList(styleName, specArray, spacing, showAllLevels): bullet = "" numPrefix = "" numSuffix = "" numberFormat = "" cssLengthNum = 0 cssLengthUnits = "" numbered = False displayLevels = 0 listStyle = ListStyle(name=styleName) numFormatPattern = re.compile("([1IiAa])") cssLengthPattern = re.compile("([^a-z]+)\\s*([a-z]+)?") m = cssLengthPattern.search(spacing) if (m != None): cssLengthNum = float(m.group(1)) if (m.lastindex == 2): cssLengthUnits = m.group(2) i = 0 while i < len(specArray): specification = specArray[i] m = numFormatPattern.search(specification) if (m != None): numberFormat = m.group(1) numPrefix = specification[0:m.start(1)] numSuffix = specification[m.end(1):] bullet = "" numbered = True if (showAllLevels): displayLevels = i + 1 else: displayLevels = 1 else: # it's a bullet style bullet = specification numPrefix = "" numSuffix = "" numberFormat = "" displayLevels = 1 numbered = False if (numbered): lls = ListLevelStyleNumber(level=(i + 1)) if (numPrefix != ''): lls.setAttribute('numprefix', numPrefix) if (numSuffix != ''): lls.setAttribute('numsuffix', numSuffix) lls.setAttribute('displaylevels', displayLevels) else: lls = ListLevelStyleBullet(level=(i + 1), bulletchar=bullet[0]) llp = ListLevelProperties() llp.setAttribute('spacebefore', str(cssLengthNum * (i + 1)) + cssLengthUnits) llp.setAttribute('minlabelwidth', str(cssLengthNum) + cssLengthUnits) lls.addElement(llp) listStyle.addElement(lls) i += 1 return listStyle
def styleFromList( styleName, specArray, spacing, showAllLevels): bullet = "" numPrefix = "" numSuffix = "" numberFormat = "" cssLengthNum = 0 cssLengthUnits = "" numbered = False displayLevels = 0 listStyle = ListStyle(name=styleName) numFormatPattern = re.compile("([1IiAa])") cssLengthPattern = re.compile("([^a-z]+)\\s*([a-z]+)?") m = cssLengthPattern.search( spacing ) if (m != None): cssLengthNum = float(m.group(1)) if (m.lastindex == 2): cssLengthUnits = m.group(2) i = 0 while i < len(specArray): specification = specArray[i] m = numFormatPattern.search(specification) if (m != None): numberFormat = m.group(1) numPrefix = specification[0:m.start(1)] numSuffix = specification[m.end(1):] bullet = "" numbered = True if (showAllLevels): displayLevels = i + 1 else: displayLevels = 1 else: # it's a bullet style bullet = specification numPrefix = "" numSuffix = "" numberFormat = "" displayLevels = 1 numbered = False if (numbered): lls = ListLevelStyleNumber(level=(i+1)) if (numPrefix != ''): lls.setAttribute('numprefix', numPrefix) if (numSuffix != ''): lls.setAttribute('numsuffix', numSuffix) lls.setAttribute('displaylevels', displayLevels) else: lls = ListLevelStyleBullet(level=(i+1),bulletchar=bullet[0]) llp = ListLevelProperties() llp.setAttribute('spacebefore', str(cssLengthNum * (i+1)) + cssLengthUnits) llp.setAttribute('minlabelwidth', str(cssLengthNum) + cssLengthUnits) lls.addElement( llp ) listStyle.addElement(lls) i += 1 return listStyle