Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Private Member Functions
MoinMoin.formatter.text_docbook.Table Class Reference

List of all members.

Public Member Functions

def __init__
def finalizeTable
def addRow
def addCell

Public Attributes

 formatter
 doc
 tableNode
 colWidths
 tgroup
 curColumn
 maxColumn
 row
 tbody

Private Member Functions

def _handleColWidth
def _handleColSpan
def _handleSimpleCellAttributes

Detailed Description

The Table class is used as a helper for collecting information about
what kind of table we are building. When all relelvant data is gathered
it calculates the different spans of the cells and columns.

Note that it expects all arguments to be passed in a dict.

Definition at line 944 of file text_docbook.py.


Constructor & Destructor Documentation

def MoinMoin.formatter.text_docbook.Table.__init__ (   self,
  formatter,
  doc,
  parent,
  argsdict = {} 
)

Definition at line 952 of file text_docbook.py.

00952 
00953     def __init__(self, formatter, doc, parent, argsdict={}):
00954         self.formatter = formatter
00955         self.doc = doc
00956 
00957         self.tableNode = self.doc.createElement('informaltable')
00958         parent.appendChild(self.tableNode)
00959         self.colWidths = {}
00960         self.tgroup = self.doc.createElement('tgroup')
00961         # Bug in yelp, the two lines below don't affect rendering
00962         #self.tgroup.setAttribute('rowsep', '1')
00963         #self.tgroup.setAttribute('colsep', '1')
00964         self.curColumn = 0
00965         self.maxColumn = 0
00966         self.row = None
00967         self.tableNode.appendChild(self.tgroup)
00968 
00969         self.tbody = self.doc.createElement('tbody') # Note: This gets appended in finalizeTable


Member Function Documentation

def MoinMoin.formatter.text_docbook.Table._handleColSpan (   self,
  element,
  argsdict = {} 
) [private]
Returns the number of colums this entry spans

Definition at line 1024 of file text_docbook.py.

01024 
01025     def _handleColSpan(self, element, argsdict={}):
01026         """Returns the number of colums this entry spans"""
01027         if not argsdict or not argsdict.has_key('colspan'):
01028             return 1
01029         assert(element.nodeName == "entry")
01030         extracols = int(argsdict['colspan'].strip('"')) - 1
01031         element.setAttribute('namest', "col_" + str(self.curColumn))
01032         element.setAttribute('nameend', "col_" + str(self.curColumn + extracols))
01033         return 1 + extracols

Here is the caller graph for this function:

def MoinMoin.formatter.text_docbook.Table._handleColWidth (   self,
  argsdict = {} 
) [private]

Definition at line 1014 of file text_docbook.py.

01014 
01015     def _handleColWidth(self, argsdict={}):
01016         if not argsdict.has_key("width"):
01017             return
01018         argsdict["width"] = argsdict["width"].strip('"')
01019         if not argsdict["width"].endswith("%"):
01020             self.formatter._emitComment("Width %s not supported" % argsdict["width"])
01021             return
01022 
01023         self.colWidths[str(self.curColumn)] = argsdict["width"][:-1] + "*"

Here is the caller graph for this function:

def MoinMoin.formatter.text_docbook.Table._handleSimpleCellAttributes (   self,
  element,
  argsdict = {} 
) [private]

Definition at line 1034 of file text_docbook.py.

01034 
01035     def _handleSimpleCellAttributes(self, element, argsdict={}):
01036         if not argsdict:
01037             return
01038         assert(element.nodeName == "entry")
01039 
01040         safe_values_for = {'valign': ('top', 'middle', 'bottom'),
01041                            'align': ('left', 'center', 'right'),
01042                           }
01043 
01044         if argsdict.has_key('rowspan'):
01045             extrarows = int(argsdict['rowspan'].strip('"')) - 1
01046             element.setAttribute('morerows', str(extrarows))
01047 
01048         if argsdict.has_key('align'):
01049             value = argsdict['align'].strip('"')
01050             if value in safe_values_for['align']:
01051                 element.setAttribute('align', value)
01052             else:
01053                 self.formatter._emitComment("Alignment %s not supported" % value)
01054                 pass
01055 
01056         if argsdict.has_key('valign'):
01057             value = argsdict['valign'].strip('"')
01058             if value in safe_values_for['valign']:
01059                 element.setAttribute('valign', value)
01060             else:
01061                 self.formatter._emitComment("Vertical alignment %s not supported" % value)
01062                 pass
01063 
01064 

Here is the caller graph for this function:

def MoinMoin.formatter.text_docbook.Table.addCell (   self,
  argsdict = {} 
)

Definition at line 997 of file text_docbook.py.

00997 
00998     def addCell(self, argsdict={}):
00999         if 'style' in argsdict:
01000             argsdict.update(self.formatter._convertStylesToDict(argsdict['style'].strip('"')))
01001 
01002         cell = self.doc.createElement('entry')
01003         cell.setAttribute('rowsep', '1')
01004         cell.setAttribute('colsep', '1')
01005 
01006         self.row.appendChild(cell)
01007         self._handleSimpleCellAttributes(cell, argsdict)
01008         self._handleColWidth(argsdict)
01009         self.curColumn += self._handleColSpan(cell, argsdict)
01010 
01011         self.maxColumn = max(self.curColumn, self.maxColumn)
01012 
01013         return cell

Here is the call graph for this function:

def MoinMoin.formatter.text_docbook.Table.addRow (   self,
  argsdict = {} 
)

Definition at line 989 of file text_docbook.py.

00989 
00990     def addRow(self, argsdict={}):
00991         self.curColumn = 0
00992         self.row = self.doc.createElement('row')
00993         # Bug in yelp, doesn't affect the outcome.
00994         self.row.setAttribute("rowsep", "1") #Rows should have lines between them
00995         self.tbody.appendChild(self.row)
00996         return self.row

Calculates the final width of the whole table and the width of each
column. Adds the colspec-elements and applies the colwidth attributes.
Inserts the tbody element to the tgroup and returns the tables container
element.

A lot of the information is gathered from the style attributes passed
to the functions

Definition at line 970 of file text_docbook.py.

00970 
00971     def finalizeTable(self):
00972         """Calculates the final width of the whole table and the width of each
00973         column. Adds the colspec-elements and applies the colwidth attributes.
00974         Inserts the tbody element to the tgroup and returns the tables container
00975         element.
00976 
00977         A lot of the information is gathered from the style attributes passed
00978         to the functions
00979         """
00980         self.tgroup.setAttribute('cols', str(self.maxColumn))
00981         for colnr in range(0, self.maxColumn):
00982             colspecElem = self.doc.createElement('colspec')
00983             colspecElem.setAttribute('colname', 'col_%s' % str(colnr))
00984             if self.colWidths.has_key(str(colnr)) and self.colWidths[str(colnr)] != "1*":
00985                 colspecElem.setAttribute('colwidth', self.colWidths[str(colnr)])
00986             self.tgroup.appendChild(colspecElem)
00987         self.tgroup.appendChild(self.tbody)
00988         return self.tableNode.parentNode


Member Data Documentation

Definition at line 958 of file text_docbook.py.

Definition at line 963 of file text_docbook.py.

Definition at line 954 of file text_docbook.py.

Definition at line 953 of file text_docbook.py.

Definition at line 964 of file text_docbook.py.

Definition at line 965 of file text_docbook.py.

Definition at line 956 of file text_docbook.py.

Definition at line 968 of file text_docbook.py.

Definition at line 959 of file text_docbook.py.


The documentation for this class was generated from the following file: