diff --git a/src/gen/plug/report/_options.py b/src/gen/plug/report/_options.py
index 80b519b1f..778db6fd9 100644
--- a/src/gen/plug/report/_options.py
+++ b/src/gen/plug/report/_options.py
@@ -4,7 +4,7 @@
# Copyright (C) 2004-2007 Donald N. Allingham
# Copyright (C) 2008,2011 Gary Burton
# Copyright (C) 2010 Jakim Friant
-# Copyright (C) 2011 Paul Franklin
+# Copyright (C) 2011-2013 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
@@ -83,6 +83,7 @@ class OptionList(_options.OptionList):
self.margins = [2.54, 2.54, 2.54, 2.54]
self.format_name = None
self.css_filename = None
+ self.output = None
def set_style_name(self, style_name):
"""
@@ -234,6 +235,22 @@ class OptionList(_options.OptionList):
"""
return self.format_name
+ def set_output(self, output):
+ """
+ Set the output for the OptionList.
+ @param output: name of the output to set.
+ @type output: str
+ """
+ self.output = output
+
+ def get_output(self):
+ """
+ Return the output of the OptionList.
+ @returns: returns the output name
+ @rtype: str
+ """
+ return self.output
+
#-------------------------------------------------------------------------
#
# Collection of option lists
@@ -445,6 +462,9 @@ class OptionListCollection(_options.OptionListCollection):
if option_list.get_style_name():
f.write(' \n' %
escxml(option_list.get_style_name()) )
+ if option_list.get_output():
+ f.write(' \n' %
+ escxml(os.path.basename(option_list.get_output())) )
def parse(self):
"""
@@ -529,6 +549,9 @@ class OptionParser(_options.OptionParser):
self.collection.set_last_margin(pos, value)
else:
self.option_list.set_margin(pos, value)
+ elif tag == 'output':
+ if not self.common:
+ self.option_list.set_output(attrs['name'])
else:
# Tag is not report-specific, so we let the base class handle it.
_options.OptionParser.startElement(self, tag, attrs)
@@ -615,6 +638,8 @@ class OptionHandler(_options.OptionHandler):
self.paper_name = self.saved_option_list.get_paper_name()
if self.saved_option_list.get_format_name():
self.format_name = self.saved_option_list.get_format_name()
+ if self.saved_option_list.get_output():
+ self.output = self.saved_option_list.get_output()
def save_options(self):
"""
@@ -636,6 +661,7 @@ class OptionHandler(_options.OptionHandler):
def save_common_options(self):
# First we save common options
self.saved_option_list.set_style_name(self.style_name)
+ self.saved_option_list.set_output(self.output)
self.saved_option_list.set_orientation(self.orientation)
self.saved_option_list.set_custom_paper_size(self.custom_paper_size)
self.saved_option_list.set_margins(self.margins)
diff --git a/src/gui/plug/report/_docreportdialog.py b/src/gui/plug/report/_docreportdialog.py
index 61a5a7461..65df85c7e 100644
--- a/src/gui/plug/report/_docreportdialog.py
+++ b/src/gui/plug/report/_docreportdialog.py
@@ -3,6 +3,7 @@
#
# Copyright (C) 2007 Brian G. Matherly
# Copyright (C) 2010 Jakim Friant
+# Copyright (C) 2013 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
@@ -176,7 +177,10 @@ class DocReportDialog(ReportDialog):
else:
spath = self.get_default_directory()
default_name = self.dbname + "_" + self.raw_name
- base = "%s.%s" % (default_name, ext)
+ if self.options.get_output():
+ base = os.path.basename(self.options.get_output())
+ else:
+ base = "%s.%s" % (default_name, ext)
spath = os.path.normpath(os.path.join(spath, base))
self.target_fileentry.set_filename(spath)
diff --git a/src/gui/plug/report/_graphvizreportdialog.py b/src/gui/plug/report/_graphvizreportdialog.py
index 4bd8dc9fa..f988f3b08 100644
--- a/src/gui/plug/report/_graphvizreportdialog.py
+++ b/src/gui/plug/report/_graphvizreportdialog.py
@@ -169,7 +169,10 @@ class GraphvizReportDialog(ReportDialog):
else:
spath = self.get_default_directory()
default_name = self.dbname + "_" + self.raw_name
- base = "%s%s" % (default_name, ext) # "ext" already has a dot
+ if self.options.get_output():
+ base = os.path.basename(self.options.get_output())
+ else:
+ base = "%s%s" % (default_name, ext)
spath = os.path.normpath(os.path.join(spath, base))
self.target_fileentry.set_filename(spath)