From 5884a15623f90c23cd00ad120985f09326c8aecf Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Thu, 10 Nov 2005 03:11:37 +0000 Subject: [PATCH] * src/docgen/LPRDoc.py: Remove extra line after the paragraph. svn: r5388 --- gramps2/ChangeLog | 1 + gramps2/src/docgen/LPRDoc.py | 38 ++++++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index a0d626110..d9978366b 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -11,6 +11,7 @@ * src/docgen//OpenOfficeDoc.py: Correct output for spacing. * src/docgen/LPRDoc.py: Properly use space above/below. * src/docgen/LPRDoc.py: Support post-leader directive. + * src/docgen/LPRDoc.py: Remove extra line after the paragraph. 2005-11-09 Martin Hawlisch * src/DbPrompter.py (DbPrompter): Use Combo to list multiple rcecent files diff --git a/gramps2/src/docgen/LPRDoc.py b/gramps2/src/docgen/LPRDoc.py index 2e2ad0218..75586e4f1 100644 --- a/gramps2/src/docgen/LPRDoc.py +++ b/gramps2/src/docgen/LPRDoc.py @@ -419,8 +419,10 @@ class GnomePrintPhoto: self.height = self.pixbuf.get_height() self.width = self.pixbuf.get_width() max_size = cm2u(max(x_size,y_size)) - self.scale_x = int( max_size * float(self.width)/max(self.height,self.width) ) - self.scale_y = int( max_size * float(self.height)/max(self.height,self.width) ) + self.scale_x = int(max_size * float(self.width)/max(self.height, + self.width)) + self.scale_y = int(max_size * float(self.height)/max(self.height, + self.width)) def get_image(self): """ @@ -506,7 +508,8 @@ class LPRDoc(BaseDoc.BaseDoc): self.gpc = self.job.get_context() #find out what the width and height of the page is - width, height = gnomeprint.job_get_page_size_from_config(self.job.get_config()) + width, height = gnomeprint.job_get_page_size_from_config( + self.job.get_config()) self.left_margin = cm2u(self.get_left_margin()) self.right_margin = width - cm2u(self.get_right_margin()) @@ -556,7 +559,7 @@ class LPRDoc(BaseDoc.BaseDoc): if not self.brand_new_page: self.end_page() self.start_page() - + #------------------------------------------------------------------------ # # Text methods @@ -597,7 +600,8 @@ class LPRDoc(BaseDoc.BaseDoc): # Add current text/directive to paragraoh, # then either add paragrah to the list of cell's paragraphs # or print it right away if not in cell - append_to_paragraph(self.paragraph,self.paragraph_directive,self.paragraph_text) + append_to_paragraph(self.paragraph,self.paragraph_directive, + self.paragraph_text) if self.in_cell: # We're inside cell. Add paragrah to celldata self.cell_data.append(self.paragraph) @@ -611,30 +615,34 @@ class LPRDoc(BaseDoc.BaseDoc): def start_bold(self): """Bold face.""" - append_to_paragraph(self.paragraph,self.paragraph_directive,self.paragraph_text) + append_to_paragraph(self.paragraph,self.paragraph_directive, + self.paragraph_text) self.paragraph_directive = _BOLD self.paragraph_text = "" self.brand_new_page = 0 def end_bold(self): """End bold face.""" - append_to_paragraph(self.paragraph,self.paragraph_directive,self.paragraph_text) + append_to_paragraph(self.paragraph,self.paragraph_directive, + self.paragraph_text) self.paragraph_directive = "" self.paragraph_text = "" self.brand_new_page = 0 def start_superscript(self): - append_to_paragraph(self.paragraph,self.paragraph_directive,self.paragraph_text) + append_to_paragraph(self.paragraph,self.paragraph_directive, + self.paragraph_text) self.paragraph_directive = _SUPER self.paragraph_text = "" self.brand_new_page = 0 - + def end_superscript(self): - append_to_paragraph(self.paragraph,self.paragraph_directive,self.paragraph_text) + append_to_paragraph(self.paragraph,self.paragraph_directive, + self.paragraph_text) self.paragraph_directive = "" self.paragraph_text = "" self.brand_new_page = 0 - + def start_table(self,name,style_name): """Begin new table.""" # initialize table, compute its width, find number of columns @@ -850,10 +858,15 @@ class LPRDoc(BaseDoc.BaseDoc): if y != self.top_margin: y = y - cm2u(paragraph.style.get_top_margin()) + line_number = 0 + total_lines = len(paragraph.get_lines()) + # Loop over lines which were assembled by paragraph.format() for (start_piece,start_word,end_piece,end_word,avail_width) \ in paragraph.get_lines(): + line_number += 1 + if paragraph.get_alignment() == BaseDoc.PARA_ALIGN_CENTER: x = x + 0.5 * avail_width elif paragraph.get_alignment() == BaseDoc.PARA_ALIGN_RIGHT: @@ -922,7 +935,8 @@ class LPRDoc(BaseDoc.BaseDoc): else: no_space = 1 - y = self.advance_line(y,paragraph) + if line_number < total_lines: + y = self.advance_line(y,paragraph) x = left_margin x = x - cm2u(paragraph.style.get_left_margin())