~stub/ubuntu/precise/calibre/devel

« back to all changes in this revision

Viewing changes to src/calibre/ebooks/oeb/transforms/flatcss.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-04-12 11:29:25 UTC
  • mfrom: (42.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110412112925-c7171kt2bb5rmft4
Tags: 0.7.50+dfsg-2
* debian/control: Build with libpodofo-dev to enable PDF metadata.
  (Closes: #619632)
* debian/control: Add libboost1.42-dev build dependency. Apparently it is
  needed in some setups. (Closes: #619807)
* debian/rules: Call dh_sip to generate a proper sip API dependency, to
  prevent crashes like #616372 for partial upgrades.
* debian/control: Bump python-qt4 dependency to >= 4.8.3-2, which reportedly
  fixes crashes on startup. (Closes: #619701, #620125)

Show diffs side-by-side

added added

removed removed

Lines of Context:
100
100
 
101
101
class CSSFlattener(object):
102
102
    def __init__(self, fbase=None, fkey=None, lineh=None, unfloat=False,
103
 
                 untable=False):
 
103
                 untable=False, page_break_on_body=False):
104
104
        self.fbase = fbase
105
105
        self.fkey = fkey
106
106
        self.lineh = lineh
107
107
        self.unfloat = unfloat
108
108
        self.untable = untable
 
109
        self.page_break_on_body = page_break_on_body
109
110
 
110
111
    @classmethod
111
112
    def config(cls, cfg):
139
140
            bs.append('margin-right : %fpt'%\
140
141
                    float(self.context.margin_right))
141
142
            bs.extend(['padding-left: 0pt', 'padding-right: 0pt'])
 
143
            if self.page_break_on_body:
 
144
                bs.extend(['page-break-before: always'])
142
145
            if self.context.change_justification != 'original':
143
146
                bs.append('text-align: '+ self.context.change_justification)
144
147
            body.set('style', '; '.join(bs))
207
210
            font_size = self.sbase if self.sbase is not None else \
208
211
                self.context.source.fbase
209
212
        if 'align' in node.attrib:
210
 
            cssdict['text-align'] = node.attrib['align']
 
213
            if tag != 'img':
 
214
                cssdict['text-align'] = node.attrib['align']
 
215
            else:
 
216
                val = node.attrib['align']
 
217
                if val in ('middle', 'bottom', 'top'):
 
218
                    cssdict['vertical-align'] = val
 
219
                elif val in ('left', 'right'):
 
220
                    cssdict['text-align'] = val
211
221
            del node.attrib['align']
212
222
        if node.tag == XHTML('font'):
213
223
            node.tag = XHTML('span')