Changes

Jump to: navigation, search

Report API

2,787 bytes added, 00:41, 28 April 2020
no edit summary
{{Out man note|The {{man label|Simple Document API interface}}|It is a report API([https://en.wikipedia.org/wiki/Application_programming_interface Application programming interface]) made for Gramps plugin/addon writers}} The [[Report_API|Simple Document API interface]] is for easy presentation of datethe data and can be used with [[Simple Access API]]. {{stub}}
In Gramps there are five different types of reports.
This common part is implemented in the [http://www.gramps-project.org/docs/gen/gen_plug.html#gen.plug.docgen.basedoc.BaseDoc BaseDoc class], which contains among others basic document opening, closing, and stylesheet handling methods. It also stores the physical description of a page (sheet of paper in print).
'''{{man note|Note!''' |The <tt>BaseDoc.open</tt> and the <tt>BaseDoc.close</tt> methods have to be implemented by the subclassed document generators.}}
===Page===
==Text document API==
 
The specification of the Textdoc API is [https://gramps-project.org/docs/gen/gen_plug.html#gramps.gen.plug.docgen.textdoc.TextDoc here]
 
The interface for adding media objects is as follows:
 
<pre>
add_media_object(name, align, w_cm, h_cm, alt='', style_name=None, crop=None)[source]
 
Add a photo of the specified width (in centimeters).
Parameters:
 
name – filename of the image to add
align – alignment of the image. Valid values are ‘left’, ‘right’, ‘center’, and ‘single’
w_cm – width in centimeters
h_cm – height in centimeters
alt – an alternative text to use. Useful for eg html reports
style_name – style to use for captions
crop – image cropping parameters
</pre>
 
Note that because of the structure of these documents, Images are only allowed as children (i.e. following) Document or Cell.
 
This interface is used in the following reports:
 
{| {{Prettytable}}
|-
! Report
! Built-in
! align
! style_name
! how called
|-
| Detailed Ancestral Report
| Built-in
| right
| DDR-Caption
| via gen/plug/report/utils.py
|-
| Detailed Descendant Report
| Built-in
| right
| DDR-Caption
| via gen/plug/report/utils.py
|-
| Individual Complete Report
| Built-in
| right
| None
| direct
|-
| Book (Title Page)
| Built-in
| center
| None
| direct
|-
| Person Everything
| Addon
| single
| PE-Level%d
| direct
|-
|}
 
None of the reports use 'alt'. It is understood (from looking at the code in odfdoc.py) that '''left''' and '''right''' alignment should cause the text to wrap around the media object, while for '''single''' alignment, there should be no text on either side of the media object.
 
Since style_name should be used as the style for the caption (i.e. the '''alt''' string) it should also be used for the image itself. Otherwise the caption would not be below the picture.
 
As at December 2014, output appears as follows:
 
{| {{Prettytable}}
|-
! Format
! right
! center
! single
|-
| HTML
| '''OK''' Picture on right, text wrapped round it
| ?
| Picture on left margin, text not wrapped
|-
| RTF
| Picture on left margin, text not wrapped
| ?
| '''OK''' Picture aligned with previous paragraph, text not wrapped
|-
| ODF
| '''OK''' Picture on right, text wrapped round it
| ?
| Picture centred, text not wrapped
|-
| PDF
| Picture on right, text not wrapped
| ?
| Picture on left margin, text not wrapped
|-
|}
==Draw document API==
{{stub}}
==Graph document API==
{{stub}}
[[Category:Developers/Reference]]
2,102
edits

Navigation menu