From 13467d6af78f1acf2ded6c24fee92f5a2819c4d2 Mon Sep 17 00:00:00 2001 From: Paul Franklin Date: Mon, 17 Feb 2014 13:05:55 -0800 Subject: [PATCH] enable "paper" options in books.xml --- gramps/gen/plug/report/_book.py | 200 +++++++++++++++++++++++++++++++- 1 file changed, 199 insertions(+), 1 deletion(-) diff --git a/gramps/gen/plug/report/_book.py b/gramps/gen/plug/report/_book.py index 3b9c5689d..545839b19 100644 --- a/gramps/gen/plug/report/_book.py +++ b/gramps/gen/plug/report/_book.py @@ -4,7 +4,7 @@ # Copyright (C) 2003-2007 Donald N. Allingham # Copyright (C) 2007-2008 Brian G. Matherly # Copyright (C) 2010 Jakim Friant -# Copyright (C) 2011-2012 Paul Franklin +# Copyright (C) 2011-2014 Paul Franklin # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -33,6 +33,7 @@ #------------------------------------------------------------------------- from ...const import GRAMPS_LOCALE as glocale _ = glocale.translation.gettext +import copy #------------------------------------------------------------------------ # @@ -167,6 +168,13 @@ class Book(object): self.name = "" self.dbname = "" + self.paper_name = None + self.paper_orientation = None + self.paper_metric = None + self.paper_custom_size = None + self.paper_margins = None + self.paper_format = None + self.paper_output = None if obj: self.item_list = obj.item_list else: @@ -254,6 +262,140 @@ class Book(object): """ return self.item_list + def set_paper_name(self, paper_name): + """ + Set the paper name for the Book. + @param paper_name: name of the paper to set. + @type paper_name: str + """ + self.paper_name = paper_name + + def get_paper_name(self): + """ + Return the paper name of the Book. + @returns: returns the paper name + @rtype: str + """ + return self.paper_name + + def set_orientation(self, orientation): + """ + Set the paper orientation for the Book. + @param orientation: orientation to set. Possible values are + PAPER_LANDSCAPE or PAPER_PORTRAIT + @type orientation: int + """ + self.paper_orientation = orientation + + def get_orientation(self): + """ + Return the paper orientation for the Book. + @returns: returns the selected orientation. Valid values are + PAPER_LANDSCAPE or PAPER_PORTRAIT + @rtype: int + """ + return self.paper_orientation + + def set_paper_metric(self, paper_metric): + """ + Set the paper metric for the Book. + @param paper_metric: whether to use metric. + @type paper_metric: boolean + """ + self.paper_metric = paper_metric + + def get_paper_metric(self): + """ + Return the paper metric of the Book. + @returns: returns whether to use metric + @rtype: boolean + """ + return self.paper_metric + + def set_custom_paper_size(self, paper_size): + """ + Set the custom paper size for the Book. + @param paper_size: paper size to set in cm. + @type paper_size: [float, float] + """ + self.paper_custom_size = paper_size + + def get_custom_paper_size(self): + """ + Return the custom paper size for the Book. + @returns: returns the custom paper size in cm + @rtype: [float, float] + """ + return self.paper_custom_size + + def set_margins(self, margins): + """ + Set the paper margins for the Book. + @param margins: margins to set. Possible values are floats in cm + @type margins: [float, float, float, float] + """ + self.paper_margins = copy.copy(margins) + + def get_margins(self): + """ + Return the paper margins for the Book. + @returns margins: returns the margins, floats in cm + @rtype margins: [float, float, float, float] + """ + return copy.copy(self.paper_margins) + + def set_margin(self, pos, value): + """ + Set a paper margin for the Book. + @param pos: Position of margin [left, right, top, bottom] + @param value: floating point in cm + @type pos: int + @type value: float + """ + self.paper_margins[pos] = value + + def get_margin(self, pos): + """ + Return a paper margin for the Book. + @param pos: Position of margin [left, right, top, bottom] + @type pos: int + @returns: float cm of margin + @rtype: float + """ + return self.paper_margins[pos] + + def set_format_name(self, format_name): + """ + Set the format name for the Book. + @param format_name: name of the format to set. + @type format_name: str + """ + self.paper_format = format_name + + def get_format_name(self): + """ + Return the format name of the Book. + @returns: returns the format name + @rtype: str + """ + return self.paper_format + + def set_output(self, output): + """ + Set the output for the Book. + @param output: name of the output to set. + @type output: str + """ + self.paper_output = output + + def get_output(self): + """ + Return the output of the Book. + @returns: returns the output name + @rtype: str + """ + return self.paper_output + #------------------------------------------------------------------------ # # BookList class @@ -358,6 +500,24 @@ class BookList(object): f.write('