예제 #1
0
    def __init__(self, doc, parent, columns, model, width, flowStyle):

        # TODO : make a copy of model.columns here so that
        # TableInstance.addColumn does not modify the model (?)
        # Currently this is done by child()ing the model...

        # self.rows = []
        self.currentRow = None
        self._rowIndex = -1

        if width is None:
            width = parent.getTextWidth()

        assert isnumber(width), "%s is not a number" % repr(width)

        assert isinstance(model, TableModel)

        # child() the model because updates to the table instance should
        # not update the TableModel
        self.model = model.child()

        if flowStyle is None:
            flowStyle = model.flowStyle

        ChildEnvironment.__init__(self, doc, parent, width, flowStyle,
                                  self.model.paraStyle)

        if columns is not None:
            assert self.model.getColumnCount() is 0
            self.model.isgrowing = False
            # self.columns = []
            if issequence(columns):
                # it is a sequence of relative widths
                ##					s = 0
                ##					for w in columns:
                ##						s += w
                s = reduce(lambda x, y: x + y, columns)
                # print s
                for w in columns:
                    self.addColumn(width=w * self.width / s)
            elif type(columns) is types.StringType:
                # string of colspecs characters
                for c in columns:
                    s = self._paraStyle.child(alignment=colspecs[c])
                    s.setName("%s.defaultParaStyle" % \
                        c.__class__.__name__)

                    self.addColumn(style=s)
            else:
                raise "%s : invalid colSpecs" % repr(columns)
        #else:
        #	 self.columns = list(self.model.columns)

        if self.model.getColumnCount() > 0:
            self.computeColWidths()
        #else:
        #	 print 'foo'
        #		  "beginTable() must specify the number of columns"
        """make a copy using list() so that adding cell formats won't
예제 #2
0
	def __init__(self, doc,
					 parent,
					 width=None,
					 flowStyle=None, paraStyle=None):
		#assert isinstance(parent,TableInstance)
		ChildEnvironment.__init__(self,doc,
										  parent,width,
										  flowStyle,paraStyle)
		self.cells = []
		self.currentCell = None
		self._colIndex = 0
예제 #3
0
 def __init__(self,
              doc,
              parent,
              width=None,
              flowStyle=None,
              paraStyle=None):
     #assert isinstance(parent,TableInstance)
     ChildEnvironment.__init__(self, doc, parent, width, flowStyle,
                               paraStyle)
     self.cells = []
     self.currentCell = None
     self._colIndex = 0
예제 #4
0
    def __init__(self, doc, parent, width, listStyle, itemStyle):

        ChildEnvironment.__init__(self, doc, parent, width, itemStyle)
        # self._currentItem = None
        self.itemCount = 0
        self.listStyle = listStyle
        # self._items = []

        # dynamically create ParagraphStyle with the indentation
        # depending on the nesting level of the list:
        # TODO : manage _paraStyle for ListItem
        level = self.getListLevel()
        self._paraStyle = self._paraStyle.child(
            leftIndent=level * listStyle.bulletWidth, bulletIndent=(level - 1) * listStyle.bulletWidth
        )
예제 #5
0
    def __init__(self, doc, parent, width, listStyle, itemStyle):

        ChildEnvironment.__init__(self, doc, parent, width, itemStyle)
        #self._currentItem = None
        self.itemCount = 0
        self.listStyle = listStyle
        #self._items = []

        # dynamically create ParagraphStyle with the indentation
        # depending on the nesting level of the list:
        # TODO : manage _paraStyle for ListItem
        level = self.getListLevel()
        self._paraStyle = self._paraStyle.child(
            leftIndent=level * listStyle.bulletWidth,
            bulletIndent=(level - 1) * listStyle.bulletWidth)
예제 #6
0
	def __init__(self, doc,
					 parent,
					 columns, model, width,
					 flowStyle ):

		# TODO : make a copy of model.columns here so that
		# TableInstance.addColumn does not modify the model (?)
		# Currently this is done by child()ing the model...

		# self.rows = []
		self.currentRow = None
		self._rowIndex = -1

		if width is None:
			width = parent.getTextWidth()
			
		assert isnumber(width), "%s is not a number" % repr(width)
			
		assert isinstance(model,TableModel)
		
		# child() the model because updates to the table instance should
		# not update the TableModel
		self.model = model.child()
			
		if flowStyle is None:
			flowStyle = model.flowStyle

		ChildEnvironment.__init__(self, doc,
										  parent,width,
										  flowStyle,
										  self.model.paraStyle)
		
		if columns is not None:
			assert self.model.getColumnCount() is 0
			self.model.isgrowing = False
			# self.columns = []
			if issequence(columns):
				# it is a sequence of relative widths 
##					s = 0
##					for w in columns:
##						s += w
				s = reduce(lambda x, y: x+y, columns)
				# print s
				for w in columns:
					self.addColumn(width=w * self.width / s)
			elif type(columns) is types.StringType:
				# string of colspecs characters
				for c in columns:
					s = self._paraStyle.child(alignment=colspecs[c])
					s.setName("%s.defaultParaStyle" % \
								 c.__class__.__name__)
					
					self.addColumn(style=s)
			else:
				raise "%s : invalid colSpecs" % repr(columns)
		#else:
		#	 self.columns = list(self.model.columns)

		if self.model.getColumnCount() > 0:
			self.computeColWidths()
		#else:
		#	 print 'foo'
		#		  "beginTable() must specify the number of columns"
			
		
		"""make a copy using list() so that adding cell formats won't