Are document styles for a report shareable?

Gramps 6.0.6 on Windows 11.

Creating a new document style for a specific report saves it to disk with a filename that includes the family tree name embedded.

When I open another family tree and attempt to use that new style for the same report, it isn’t visible, so it seems a document style is tied not only to the report, but to the family tree as well. Is that true?

As a hack I renamed the file to contain only the report name without the family tree name, but that did not allow it to be seen by any family tree.

If I want to use the same document style across all family trees, what is the way besides creating a copy of the file for each family tree?

Example for Detailed Ancestor Report:
Document style filename: det_ancestor_report MyFamilyTree.xml
Document style location on Windows C:\Users\username\AppData\Roaming\gramps

Have you explored the Book Reports feature?

I’ve used it. Are you suggesting that as an alternative to defining document styles, which control font types, size and report-specific layout?

Are you talking about the various options and parameters in the report configuration dialog?

If so, the settings are saved at end of session in ~/.gramps/reportoptions.xml (Linux path, adapt for Windows). This file is reloaded when Gramps is started. Thus, you get the configuration of your last report.

I found this rather inconvenient because I repetitively create updated version of a set of reports, often belonging in the same report flavour. I modified my Gramps copy to be able to save report configuration in a user file and to reload selected settings.

Now my workflow is:

  1. load report configuration,
  2. optionally make adjustments (and optionally as well save these adjustments)
  3. generate the report

I can share my patch if you aren’t afraid of testing alien untrusted code.

Yes, Document Style is one of the settings in each report, but not the report options that get saved in reportoptions.xml.

Are these Document Styles selectable through a menu at bottom of report configuration dialog? This setting is saved as a Style name=…/> in report options.

It is then possible that the generation of the menu is incorrect (or your style is not saved in the expected directory).

All correct, and that’s how it’s working in Gramps 6.0.6. Say the new document style I create is named “My Cool Doc Style”. The way that document style is saved to disk is what I described in my OP:

Example for Detailed Ancestor Report:
Document style filename: det_ancestor_report MyFamilyTree.xml
Document style location on Windows C:\Users\username\AppData\Roaming\gramps

Now “My Cool Doc Style”, stored in det_ancestor_report MyFamilyTree.xml is accessible only to the family tree that it was created in, and no other family trees. In another family tree “My Cool Doc Style” won’t be found, so it will revert to “default”. Give it a try…

Look at gramps/gen/plug/report/_options.py

At line 747 there is this

def get_stylesheet_savefile(self):
    """Where to save user defined styles for this report."""
    # Get the first part of name, if it contains a comma:
    # (will just be module_name, if no comma)
    filename = "%s.xml" % self.module_name.split(",")[0]
    return os.path.join(USER_DATA, filename)

It mentions that if a comma is present do not add the database file name to a user’s style options.

At line 949

def __init__(self, name, dbase):
    ReportOptions.__init__(self, name + " " + dbase.db_name, dbase)
    MenuOptions.__init__(self)

Modify by adding the comma

def __init__(self, name, dbase):
    ReportOptions.__init__(self, name + ", " + dbase.db_name, dbase)
    MenuOptions.__init__(self)

See pull request #1900 and feature request #2455.

I see. The feature request makes it so that each report has an options file tied to a family tree which was implemented by appending the family tree name to the report options filename. Got it.

However, I’m thinking that Document Styles for a report should be shareable across any number of family trees; it has no ties to data AFAICT. True?

@DaveSch Your suggestion in effect reverts the feature, correct? I believe that would work because there would be only one report options file per report, and it would contain all the document styles in that file, so no matter which family tree I open, all defined document styles would be available to the report. I guess this would probably have been the behavior before feature #2455 was implemented.

Just verified that in Gramps v5.2.4, multiple Document Styles are all saved in the singular report options file and I can access all of them in any family tree.

So my conclusion is that with the new feature implementation Gramps gained the ability to have report options per family tree, but regressed in being able to share Document Styles across family trees.

It only reverts the style options so the style can be used regardless of database.

All the include/exclude options for a report are saved based upon each database.

1 Like