appy.pod: fixed bug https://bugs.launchpad.net/bugs/720270 (cell repetition).

This commit is contained in:
Gaetan Delannay 2011-02-18 15:58:59 +01:00
parent a8366379dd
commit 312b1f4cef
7 changed files with 586 additions and 559 deletions

View file

@ -147,7 +147,7 @@ class ForAction(BufferAction):
if isinstance(self.elem, Cell): if isinstance(self.elem, Cell):
isCell = True isCell = True
nbOfColumns = self.elem.tableInfo.nbOfColumns nbOfColumns = self.elem.tableInfo.nbOfColumns
initialColIndex = self.elem.tableInfo.curColIndex initialColIndex = self.elem.colIndex
currentColIndex = initialColIndex currentColIndex = initialColIndex
rowAttributes = self.elem.tableInfo.curRowAttrs rowAttributes = self.elem.tableInfo.curRowAttrs
# If self.exprResult is empty, dump an empty cell to avoid # If self.exprResult is empty, dump an empty cell to avoid

View file

@ -296,6 +296,9 @@ class MemoryBuffer(Buffer):
self.elements[self.getLength()] = newElem self.elements[self.getLength()] = newElem
if isinstance(newElem, Cell) or isinstance(newElem, Table): if isinstance(newElem, Cell) or isinstance(newElem, Table):
newElem.tableInfo = self.env.getTable() newElem.tableInfo = self.env.getTable()
if isinstance(newElem, Cell):
# Remember where this cell is in the table
newElem.colIndex = newElem.tableInfo.curColIndex
def addExpression(self, expression): def addExpression(self, expression):
# Create the POD expression # Create the POD expression

View file

@ -55,6 +55,7 @@ class Cell(PodElement):
subTags = [Text.OD] subTags = [Text.OD]
def __init__(self): def __init__(self):
self.tableInfo = None # ~OdTable~ self.tableInfo = None # ~OdTable~
self.colIndex = None # The column index for this cell, within its table.
class Row(PodElement): class Row(PodElement):
OD = XmlElement('table-row', nsUri=ns.NS_TABLE) OD = XmlElement('table-row', nsUri=ns.NS_TABLE)

View file

@ -154,7 +154,11 @@ class PodEnvironment(OdfEnvironment):
self.getTable().curColIndex = -1 self.getTable().curColIndex = -1
self.getTable().curRowAttrs = self.currentElem.attrs self.getTable().curRowAttrs = self.currentElem.attrs
elif elem == Cell.OD.elem: elif elem == Cell.OD.elem:
self.getTable().curColIndex += 1 colspan = 1
attrSpan = '%s:number-columns-spanned' % tableNs
if self.currentElem.attrs.has_key(attrSpan):
colspan = int(self.currentElem.attrs[attrSpan])
self.getTable().curColIndex += colspan
elif elem == ('%s:table-column' % tableNs): elif elem == ('%s:table-column' % tableNs):
attrs = self.currentElem.attrs attrs = self.currentElem.attrs
if attrs.has_key('%s:number-columns-repeated' % tableNs): if attrs.has_key('%s:number-columns-repeated' % tableNs):
@ -263,13 +267,15 @@ class PodParser(OdfParser):
if isMainElement: if isMainElement:
parent = e.currentBuffer.parent parent = e.currentBuffer.parent
if not e.currentBuffer.action: if not e.currentBuffer.action:
# Delete this buffer and transfer content to parent # Delete this buffer and transfer content to
# parent.
e.currentBuffer.transferAllContent() e.currentBuffer.transferAllContent()
parent.removeLastSubBuffer() parent.removeLastSubBuffer()
e.currentBuffer = parent e.currentBuffer = parent
else: else:
if isinstance(parent, FileBuffer): if isinstance(parent, FileBuffer):
# Execute buffer action and delete the buffer # Execute buffer action and delete the
# buffer.
e.currentBuffer.action.execute() e.currentBuffer.action.execute()
parent.removeLastSubBuffer() parent.removeLastSubBuffer()
e.currentBuffer = parent e.currentBuffer = parent

File diff suppressed because it is too large Load diff

Binary file not shown.

Binary file not shown.