示例#1
0
    def determine_mime(self):
        descr = get_description(self.obj.get_mime_type())
        if descr:
            self.mimetext.set_text(descr)

        path = self.file_path.get_text()
        path_full = media_path_full(self.db, path)
        if path != self.obj.get_path() and path_full != self.obj.get_path():
            #redetermine mime
            mime = get_type(find_file(path_full))
            self.obj.set_mime_type(mime)
            descr = get_description(mime)
            if descr:
                self.mimetext.set_text(descr)
            else:
                self.mimetext.set_text(_('Unknown'))
        #if mime type not set, is note
        if not self.obj.get_mime_type():
            self.mimetext.set_text(_('Note'))
示例#2
0
    def determine_mime(self):
        descr = get_description(self.obj.get_mime_type())
        if descr:
            self.mimetext.set_text(descr)

        path = self.file_path.get_text()
        path_full = media_path_full(self.db, path)
        if path != self.obj.get_path() and path_full != self.obj.get_path():
            # redetermine mime
            mime = get_type(find_file(path_full))
            self.obj.set_mime_type(mime)
            descr = get_description(mime)
            if descr:
                self.mimetext.set_text(descr)
            else:
                self.mimetext.set_text(_("Unknown"))
        # if mime type not set, is note
        if not self.obj.get_mime_type():
            self.mimetext.set_text(_("Note"))
示例#3
0
    def print_object(self, level, o):

        if issubclass(o.__class__, gramps.gen.lib.address.Address):
            # Details of address are printed by the subclass conditions,
            # primarily by LocationBase, because address is a subclass of
            # LocationBase
            pass

        if issubclass(o.__class__, gramps.gen.lib.addressbase.AddressBase):
            for address in o.get_address_list():
                self.print_header(level, _("Address"), ref=address)
                self.print_object(level + 1, address)

        if isinstance(o, gramps.gen.lib.Attribute):
            # The unique information about attributes (the type) is printed by
            # AttributeBase
            pass

        if issubclass(o.__class__, gramps.gen.lib.attrbase.AttributeBase):
            for attribute in o.get_attribute_list():
                self.print_header(level,
                                  _("Attribute") + ". ",
                                  type_desc=str(attribute.get_type()),
                                  obj_type=attribute.get_value(),
                                  privacy=attribute.get_privacy(),
                                  ref=attribute)
                self.print_object(level + 1, attribute)

        if isinstance(o, gramps.gen.lib.ChildRef):
            # The unique information about ChildRef (the father relation and
            # mother relation) is printed by the main write_report function
            pass

        if issubclass(o.__class__, gramps.gen.lib.citationbase.CitationBase):
            if self.print_citations:
                self.print_header(level, "CitationBase tbd")

                for citation_handle in o.get_citation_list():
                    citation = self.database.get_citation_from_handle(
                        citation_handle)
                    self.print_object(level + 1, citation)

        if isinstance(o, gramps.gen.lib.Citation):
            # the unique information about Citation (the page) is printed by the
            # bibliography code. The other unique information, the confidence is
            # printed here
            if o.get_confidence_level() != gramps.gen.lib.Citation.CONF_NORMAL:
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Confidence") + " : ")
                self.doc.end_bold()
                self.doc.write_text(
                    conf_strings.get(o.get_confidence_level(), _('Unknown')))
                self.doc.end_paragraph()

            if self.print_citations:
                source_handle = o.get_reference_handle()
                source = self.database.get_source_from_handle(source_handle)
                self.print_object(level + 1, source)

        if issubclass(o.__class__, gramps.gen.lib.datebase.DateBase):
            if o.get_date_object() and not o.get_date_object().is_empty():
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Date") + " : ")
                self.doc.end_bold()
                self.doc.write_text(displayer.display(o.get_date_object()))
                self.doc.end_paragraph()

        if isinstance(o, gramps.gen.lib.Event):
            # The event type is printed by the main write_report function
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Description") + " : ")
            self.doc.end_bold()
            self.doc.write_text(str(o.get_description()))
            self.doc.end_paragraph()

        if issubclass(o.__class__, gramps.gen.lib.eventref.EventRef):
            # The unique information about EventRef (the EventRoleType) is
            # printed by the main write_report function
            event = self.database.get_event_from_handle(
                o.get_reference_handle())
            self.print_header(level,
                              _("Event"),
                              event.get_gramps_id(),
                              _("Event type"),
                              str(event.get_type()),
                              event.get_privacy(),
                              ref=event)
            self.print_object(level + 1, event)

        if isinstance(o, gramps.gen.lib.Family):
            # The unique information about Family (father, mother and children,
            # FamilyRelType and event references) are printed by the main
            # write_report function
            pass

        if isinstance(o, gramps.gen.lib.LdsOrd):
            # The Ordinance type is printed by LdsOrdBase
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Temple and status") + " : ")
            self.doc.end_bold()
            self.doc.write_text(", ".join(
                (TEMPLES.name(o.get_temple()), o.status2str())))
            self.doc.end_paragraph()

            f_h = o.get_family_handle()
            if f_h:
                family = self.database.get_family_from_handle(f_h)
                self.print_family_summary(level + 1, family,
                                          _("LDS Ordinance family"))

        if issubclass(o.__class__, gramps.gen.lib.ldsordbase.LdsOrdBase):
            for ldsord in o.get_lds_ord_list():
                self.print_header(level,
                                  _("LDS "),
                                  type_desc=_("Ordinance"),
                                  obj_type=ldsord.type2str(),
                                  privacy=ldsord.get_privacy(),
                                  ref=ldsord)
                self.print_object(level + 1, ldsord)

        if isinstance(o, gramps.gen.lib.Location):
            # The unique information about location (Parish) is printed by
            # Place. Location otherwise serves as a pointer to a LocationBase
            # object
            pass

        if issubclass(o.__class__, gramps.gen.lib.locationbase.LocationBase):
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(
                _("Street, City, County, State, Postal Code, "
                  "Country, Phone number") + " : ")
            self.doc.end_bold()
            self.doc.write_text(", ".join(
                (o.get_street(), o.get_city(), o.get_county(), o.get_state(),
                 o.get_postal_code(), o.get_country(), o.get_phone())))
            self.doc.end_paragraph()

        if issubclass(o.__class__, gramps.gen.lib.mediabase.MediaBase):
            for mediaref in o.get_media_list():
                self.print_header(level, _("Media Reference"), ref=mediaref)
                self.print_object(level + 1, mediaref)

        if isinstance(o, gramps.gen.lib.Media):
            # thumb is not printed. The mime type is printed by MediaRef
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Description and Path") + " : ")
            self.doc.end_bold()
            self.doc.write_text(o.get_description() + ", ")
            path = o.get_path()
            if path:
                mark = IndexMark(
                    "file://:" + media_path_full(self.database, path),
                    LOCAL_HYPERLINK)
                self.doc.write_text(path, mark=mark)
            self.doc.end_paragraph()

            mime_type = o.get_mime_type()
            if mime_type and mime_type.startswith("image"):
                filename = media_path_full(self.database, o.get_path())
                if os.path.exists(filename):
                    self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                    self.doc.add_media(filename, "single", 4.0, 4.0)
                    self.doc.end_paragraph()
                else:
                    self._user.warn(
                        _("Could not add photo to page"),
                        "%s: %s" % (filename, _('File does not exist')))

        if isinstance(o, gramps.gen.lib.MediaRef):
            media_handle = o.get_reference_handle()
            media = self.database.get_media_from_handle(media_handle)

            if o.get_rectangle():
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Referenced Region") + " : ")
                self.doc.end_bold()
                self.doc.write_text(", ".join(
                    (("%d" % i) for i in o.get_rectangle())))
                self.doc.end_paragraph()

                mime_type = media.get_mime_type()
                if mime_type and mime_type.startswith("image"):
                    filename = media_path_full(self.database, media.get_path())
                    if os.path.exists(filename):
                        self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                        self.doc.add_media(filename,
                                           "single",
                                           4.0,
                                           4.0,
                                           crop=o.get_rectangle())
                        self.doc.end_paragraph()

            desc = get_description(media.get_mime_type())
            if not desc:
                desc = _("unknown")
            self.print_header(level,
                              _("Media Object"),
                              media.get_gramps_id(),
                              _("Mime type"),
                              desc,
                              media.get_privacy(),
                              ref=media)
            self.print_object(level + 1, media)

        if isinstance(o, gramps.gen.lib.Name):
            # group_as, sort_as and display_as are not printed. NameType is
            # printed by the main write_report function
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(
                _("Given name(s): Title, Given, Suffix, "
                  "Call Name, Nick Name, Family Nick Name") + " : ")
            self.doc.end_bold()
            self.doc.write_text(", ".join(
                (o.get_title(), o.get_first_name(), o.get_suffix(),
                 o.get_call_name(), o.get_nick_name(),
                 o.get_family_nick_name())))
            self.doc.end_paragraph()

        if isinstance(o, gramps.gen.lib.Note):
            # The NoteType is printed by NoteBase. Whether the note is flowed or
            # not is not printed, but affects the way the note appears
            self.doc.write_styled_note(
                o.get_styledtext(),
                o.get_format(),
                "PE-Level%d" % min(level, 32),
                contains_html=o.get_type() ==
                gramps.gen.lib.notetype.NoteType.HTML_CODE)

        if issubclass(o.__class__, gramps.gen.lib.notebase.NoteBase):
            for n_h in o.get_note_list():
                note = self.database.get_note_from_handle(n_h)
                self.print_header(level, _("Note"), note.get_gramps_id(),
                                  _("Note type"), str(note.get_type()),
                                  note.get_privacy())
                self.print_object(level + 1, note)

        if issubclass(o.__class__, gramps.gen.lib.Person):
            # This is printed by the main write-report function
            pass

        if isinstance(o, gramps.gen.lib.Place):
            # The title, name, type, code and lat/long are printed by PlaceBase
            for placeref in o.get_placeref_list():
                self.print_header(level, _("Parent Place"))
                self.print_object(level + 1, placeref)


#            location = o.get_main_location()
#            if location.get_parish():
#                self.print_header(level, _("Main Location"),
#                                  type_desc=_("Parish"),
#                                  obj_type=location.get_parish())
#            else:
#                self.print_header(level, _("Main Location"))
#
#            self.print_object(level+1, location)
#
            for location in o.get_alternate_locations():
                if location.get_parish():
                    self.print_header(level,
                                      _("Alternate Location"),
                                      type_desc=_("Parish"),
                                      obj_type=location.get_parish())
                else:
                    self.print_header(level, _("Alternate Location"))
                self.print_object(level + 1, location)

        if issubclass(o.__class__, gramps.gen.lib.placebase.PlaceBase) or \
            issubclass(o.__class__, gramps.gen.lib.placeref.PlaceRef):
            if issubclass(o.__class__, gramps.gen.lib.placebase.PlaceBase):
                place_handle = o.get_place_handle()
            else:
                place_handle = o.get_reference_handle()
            if place_handle:
                place = self.database.get_place_from_handle(place_handle)
                if place:
                    place_title = place_displayer.display(self.database, place)
                    self.print_header(level,
                                      _("Place"),
                                      place.get_gramps_id(),
                                      _("Place Title"),
                                      place_title,
                                      privacy=place.get_privacy(),
                                      ref=place)
                    self.doc.start_paragraph("PE-Level%d" % min(level + 1, 32))
                    self.doc.start_bold()
                    self.doc.write_text(_("Name") + " : ")
                    self.doc.end_bold()
                    self.doc.write_text(place.get_name().value)
                    self.doc.start_bold()
                    self.doc.write_text(" " + _("Type") + " : ")
                    self.doc.end_bold()
                    self.doc.write_text(str(place.get_type()))
                    self.doc.start_bold()
                    self.doc.write_text(" " + _("Code") + " : ")
                    self.doc.end_bold()
                    self.doc.write_text(place.get_code())
                    self.doc.end_paragraph()

                    for name in place.get_alternative_names():
                        self.doc.start_paragraph("PE-Level%d" %
                                                 min(level + 1, 32))
                        self.doc.start_bold()
                        self.doc.write_text(_("Alternative Name") + " : ")
                        self.doc.end_bold()
                        self.doc.write_text(name.value)
                        self.doc.end_paragraph()

                    if place.get_longitude() or place.get_latitude():
                        self.doc.start_paragraph("PE-Level%d" %
                                                 min(level + 1, 32))
                        self.doc.start_bold()
                        self.doc.write_text(_("Latitude, Longitude") + " : ")
                        self.doc.end_bold()
                        self.doc.write_text(", ".join(
                            (place.get_longitude(), place.get_latitude())))
                        self.doc.end_paragraph()

                    self.print_object(level + 1, place)

        if issubclass(o.__class__,
                      gramps.gen.lib.primaryobj.BasicPrimaryObject):
            # The Gramps ID is printed by the enclosing object
            pass

        if issubclass(o.__class__, gramps.gen.lib.privacybase.PrivacyBase):
            # The privacy is printed by the enclosing object
            pass

        if isinstance(o, gramps.gen.lib.RepoRef):
            # The media type is printed by source
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Call number") + " : ")
            self.doc.end_bold()
            self.doc.write_text(o.get_call_number())
            self.doc.end_paragraph()

            repository_handle = o.get_reference_handle()
            repository = self.database.get_repository_from_handle(
                repository_handle)
            self.print_header(level,
                              _("Repository"),
                              repository.get_gramps_id(),
                              _("Repository type"),
                              str(repository.get_type()),
                              privacy=repository.get_privacy())
            self.print_object(level + 1, repository)

        if isinstance(o, gramps.gen.lib.Repository):
            # the repository type is printed by RepoRef
            pass

        if isinstance(o, gramps.gen.lib.Source):
            # The title, author, abbreviation and publication information are
            # printed by the bibliography code
            #            data_map = o.get_data_map()
            #            for key in data_map.keys():
            #                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            #                self.doc.start_bold()
            #                self.doc.write_text(_("Data") + ". " + key + " : ")
            #                self.doc.end_bold()
            #                self.doc.write_text(data_map[key])
            #                self.doc.end_paragraph()

            reporef_list = o.get_reporef_list()
            for reporef in reporef_list:
                self.print_header(level,
                                  _("Repository reference"),
                                  type_desc=_("Media type"),
                                  obj_type=str(reporef.get_media_type()),
                                  privacy=reporef.get_privacy())
                self.print_object(level + 1, reporef)

        if isinstance(o, gramps.gen.lib.Surname):
            if o.get_origintype():
                self.print_header(level,
                                  _("Surname"),
                                  type_desc=_("Origin type"),
                                  obj_type=str(o.get_origintype()))
            else:
                self.print_header(level, _("Surname"), privacy=o.get_privacy())
            self.doc.start_paragraph("PE-Level%d" % min(level + 1, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Prefix, surname, connector") + " : ")
            self.doc.end_bold()
            self.doc.write_text(", ".join(
                (o.get_prefix(), o.get_surname(), o.get_connector())))
            if o.get_primary():
                self.doc.write_text(" " + _("{This is the primary surname}"))
            self.doc.end_paragraph()

        if isinstance(o, gramps.gen.lib.surnamebase.SurnameBase):
            surname_list = o.get_surname_list()
            for surname in surname_list:
                self.print_object(level, surname)

        if issubclass(o.__class__, gramps.gen.lib.tagbase.TagBase):
            for tag_handle in o.get_tag_list():
                tag = self.database.get_tag_from_handle(tag_handle)
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Tag name") + " : ")
                self.doc.end_bold()
                self.doc.write_text(tag.get_name())
                self.doc.end_paragraph()
                self.print_object(level + 1, tag)

        if issubclass(o.__class__, gramps.gen.lib.Tag):
            # The tag name is printed by TagBase
            if o.get_color() != "#000000000000" or o.get_priority() != 0:
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Tag colour and priority") + " : ")
                self.doc.end_bold()
                self.doc.write_text(o.get_color() + ", " +
                                    "%d" % o.get_priority())
                self.doc.end_paragraph()

        if issubclass(o.__class__, gramps.gen.lib.urlbase.UrlBase):
            for url in o.get_url_list():
                self.print_header(level,
                                  _("URL"),
                                  type_desc=_("Type"),
                                  obj_type=str(url.get_type()),
                                  privacy=url.get_privacy())
                self.print_object(level + 1, url)

        if isinstance(o, gramps.gen.lib.Url):
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Description and Path") + " : ")
            self.doc.end_bold()
            self.doc.write_text(o.get_description() + ", ")
            path = o.get_path()
            if path:
                mark = IndexMark(path, LOCAL_HYPERLINK)
                self.doc.write_text(path, mark=mark)
            self.doc.end_paragraph()

        return o
示例#4
0
    def print_object(self, level, o):

        if issubclass(o.__class__, gramps.gen.lib.address.Address):
            # Details of address are printed by the subclass conditions,
            # primarily by LocationBase, because address is a subclass of
            # LocationBase
            pass

        if issubclass(o.__class__, gramps.gen.lib.addressbase.AddressBase):
            for address in o.get_address_list():
                self.print_header(level, _("Address"), ref=address)
                self.print_object(level+1, address)

        if isinstance(o, gramps.gen.lib.Attribute):
            # The unique information about attributes (the type) is printed by
            # AttributeBase
            pass

        if issubclass(o.__class__, gramps.gen.lib.attrbase.AttributeBase):
            for attribute in o.get_attribute_list():
                self.print_header(level, _("Attribute")+". ",
                                  type_desc=str(attribute.get_type()),
                                  obj_type=attribute.get_value(),
                                  privacy=attribute.get_privacy(),
                                  ref=attribute)
                self.print_object(level+1, attribute)

        if isinstance(o, gramps.gen.lib.ChildRef):
            # The unique information about ChildRef (the father relation and
            # mother relation) is printed by the main write_report function
            pass

        if issubclass(o.__class__, gramps.gen.lib.citationbase.CitationBase):
            if self.print_citations:
                self.print_header(level, "CitationBase tbd")

                for citation_handle in o.get_citation_list():
                    citation = self.database.get_citation_from_handle(
                                                            citation_handle)
                    self.print_object(level+1, citation)

        if isinstance(o, gramps.gen.lib.Citation):
            # the unique information about Citation (the page) is printed by the
            # bibliography code. The other unique information, the confidence is
            # printed here
            if o.get_confidence_level() != gramps.gen.lib.Citation.CONF_NORMAL:
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Confidence") + " : ")
                self.doc.end_bold()
                self.doc.write_text(conf_strings.get(o.get_confidence_level(),
                                                     _('Unknown')))
                self.doc.end_paragraph()

            if self.print_citations:
                source_handle = o.get_reference_handle()
                source = self.database.get_source_from_handle(source_handle)
                self.print_object(level+1, source)

        if issubclass(o.__class__, gramps.gen.lib.datebase.DateBase):
            if o.get_date_object() and not o.get_date_object().is_empty():
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Date") + " : ")
                self.doc.end_bold()
                self.doc.write_text(displayer.display(o.get_date_object()))
                self.doc.end_paragraph()

        if isinstance(o, gramps.gen.lib.Event):
            # The event type is printed by the main write_report function
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Description") + " : ")
            self.doc.end_bold()
            self.doc.write_text(str(o.get_description()))
            self.doc.end_paragraph()

        if issubclass(o.__class__, gramps.gen.lib.eventref.EventRef):
            # The unique information about EventRef (the EventRoleType) is
            # printed by the main write_report function
            event = self.database.get_event_from_handle(o.get_reference_handle())
            self.print_header(level, _("Event"), event.get_gramps_id(),
                              _("Event type"), str(event.get_type()),
                              event.get_privacy(),
                              ref=event)
            self.print_object(level+1, event)

        if isinstance(o, gramps.gen.lib.Family):
            # The unique information about Family (father, mother and children,
            # FamilyRelType and event references) are printed by the main
            # write_report function
            pass

        if isinstance(o, gramps.gen.lib.LdsOrd):
            # The Ordinance type is printed by LdsOrdBase
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Temple and status") + " : ")
            self.doc.end_bold()
            self.doc.write_text(", ".join((TEMPLES.name(o.get_temple()),
                                           o.status2str()
                                   )))
            self.doc.end_paragraph()

            f_h = o.get_family_handle()
            if f_h:
                family = self.database.get_family_from_handle(f_h)
                self.print_family_summary(level+1, family,
                                          _("LDS Ordinance family"))

        if issubclass(o.__class__, gramps.gen.lib.ldsordbase.LdsOrdBase):
            for ldsord in o.get_lds_ord_list():
                self.print_header(level, _("LDS "),
                                  type_desc=_("Ordinance"),
                                  obj_type=ldsord.type2str(),
                                  privacy=ldsord.get_privacy(),
                                  ref=ldsord)
                self.print_object(level+1, ldsord)

        if isinstance(o, gramps.gen.lib.Location):
            # The unique information about location (Parish) is printed by
            # Place. Location otherwise serves as a pointer to a LocationBase
            # object
            pass

        if issubclass(o.__class__, gramps.gen.lib.locationbase.LocationBase):
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Street, City, County, State, Postal Code, "
                                  "Country, Phone number") + " : ")
            self.doc.end_bold()
            self.doc.write_text(", ".join((o.get_street(),
                                            o.get_city(),
                                            o.get_county(),
                                            o.get_state(),
                                            o.get_postal_code(),
                                            o.get_country(),
                                            o.get_phone())))
            self.doc.end_paragraph()

        if issubclass(o.__class__, gramps.gen.lib.mediabase.MediaBase):
            for mediaref in o.get_media_list():
                self.print_header(level, _("Media Reference"), ref=mediaref)
                self.print_object(level+1, mediaref)

        if isinstance(o, gramps.gen.lib.MediaObject):
            # thumb is not printed. The mime type is printed by MediaRef
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Description and Path") + " : ")
            self.doc.end_bold()
            self.doc.write_text(o.get_description() + ", ")
            path = o.get_path()
            if path:
                mark = IndexMark("file://:" +
                                 media_path_full(self.database, path),
                                 LOCAL_HYPERLINK)
                self.doc.write_text(path, mark=mark)
            self.doc.end_paragraph()

            mime_type = o.get_mime_type()
            if mime_type and mime_type.startswith("image"):
                filename = media_path_full(self.database, o.get_path())
                if os.path.exists(filename):
                    self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                    self.doc.add_media_object(filename, "single", 4.0, 4.0)
                    self.doc.end_paragraph()
                else:
                    self._user.warn(_("Could not add photo to page"),
                          "%s: %s" % (filename, _('File does not exist')))

        if isinstance(o, gramps.gen.lib.MediaRef):
            mediaobject_handle = o.get_reference_handle()
            mediaobject = self.database.get_object_from_handle(mediaobject_handle)

            if o.get_rectangle():
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Referenced Region") + " : ")
                self.doc.end_bold()
                self.doc.write_text(", ".join((("%d" % i) for i in o.get_rectangle())))
                self.doc.end_paragraph()

                mime_type = mediaobject.get_mime_type()
                if mime_type and mime_type.startswith("image"):
                    filename = media_path_full(self.database,
                                               mediaobject.get_path())
                    if os.path.exists(filename):
                        self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                        self.doc.add_media_object(filename, "single", 4.0, 4.0,
                                                  crop=o.get_rectangle()
                                                  )
                        self.doc.end_paragraph()

            desc = get_description(mediaobject.get_mime_type())
            if not desc:
                desc = _("unknown")
            self.print_header(level, _("Media Object"),
                              mediaobject.get_gramps_id(),
                              _("Mime type"),
                              desc,
                              mediaobject.get_privacy(),
                              ref=mediaobject)
            self.print_object(level+1, mediaobject)

        if isinstance(o, gramps.gen.lib.Name):
            # group_as, sort_as and display_as are not printed. NameType is
            # printed by the main write_report function
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Given name(s): Title, Given, Suffix, "
                                  "Call Name, Nick Name, Family Nick Name") +
                                  " : ")
            self.doc.end_bold()
            self.doc.write_text(", ".join((o.get_title(),
                                           o.get_first_name(),
                                           o.get_suffix(),
                                           o.get_call_name(),
                                           o.get_nick_name(),
                                           o.get_family_nick_name())))
            self.doc.end_paragraph()

        if isinstance(o, gramps.gen.lib.Note):
            # The NoteType is printed by NoteBase. Whether the note is flowed or
            # not is not printed, but affects the way the note appears
            self.doc.write_styled_note(o.get_styledtext(),
                                       o.get_format(),
                                       "PE-Level%d" % min(level, 32),
                                       contains_html = o.get_type()
                                        == gramps.gen.lib.notetype.NoteType.HTML_CODE
                                      )

        if issubclass(o.__class__, gramps.gen.lib.notebase.NoteBase):
            for n_h in o.get_note_list():
                note = self.database.get_note_from_handle(n_h)
                self.print_header(level, _("Note"), note.get_gramps_id(),
                                  _("Note type"), str(note.get_type()),
                                  note.get_privacy())
                self.print_object(level+1, note)

        if issubclass(o.__class__, gramps.gen.lib.Person):
            # This is printed by the main write-report function
            pass

        if isinstance(o, gramps.gen.lib.Place):
            # The title, name, type, code and lat/long are printed by PlaceBase
            for placeref in o.get_placeref_list():
                self.print_header(level, _("Parent Place"))
                self.print_object(level+1, placeref)

#            location = o.get_main_location()
#            if location.get_parish():
#                self.print_header(level, _("Main Location"),
#                                  type_desc=_("Parish"),
#                                  obj_type=location.get_parish())
#            else:
#                self.print_header(level, _("Main Location"))
#
#            self.print_object(level+1, location)
#
            for location in o.get_alternate_locations():
                if location.get_parish():
                    self.print_header(level, _("Alternate Location"),
                                      type_desc=_("Parish"),
                                      obj_type=location.get_parish())
                else:
                    self.print_header(level, _("Alternate Location"))
                self.print_object(level+1, location)

        if issubclass(o.__class__, gramps.gen.lib.placebase.PlaceBase) or \
            issubclass(o.__class__, gramps.gen.lib.placeref.PlaceRef):
            if issubclass(o.__class__, gramps.gen.lib.placebase.PlaceBase):
                place_handle = o.get_place_handle()
            else:
                place_handle = o.get_reference_handle()
            place = self.database.get_place_from_handle(place_handle)
            if place:
                place_title = place_displayer.display(self.database, place)
                self.print_header(level, _("Place"), place.get_gramps_id(),
                                  _("Place Title"), place_title,
                                  privacy=place.get_privacy(),
                                  ref=place)
                self.doc.start_paragraph("PE-Level%d" % min(level+1, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Name") + " : ")
                self.doc.end_bold()
                self.doc.write_text(place.get_name().value)
                self.doc.start_bold()
                self.doc.write_text(" " + _("Type") + " : ")
                self.doc.end_bold()
                self.doc.write_text(str(place.get_type()))
                self.doc.start_bold()
                self.doc.write_text(" " + _("Code") + " : ")
                self.doc.end_bold()
                self.doc.write_text(place.get_code())
                self.doc.end_paragraph()

                for name in place.get_alternative_names():
                    self.doc.start_paragraph("PE-Level%d" % min(level+1, 32))
                    self.doc.start_bold()
                    self.doc.write_text(_("Alternative Name") + " : ")
                    self.doc.end_bold()
                    self.doc.write_text(name)
                    self.doc.end_paragraph()

                if place.get_longitude() or place.get_latitude():
                    self.doc.start_paragraph("PE-Level%d" % min(level+1, 32))
                    self.doc.start_bold()
                    self.doc.write_text(_("Latitude, Longitude") + " : ")
                    self.doc.end_bold()
                    self.doc.write_text(", ".join((place.get_longitude(),
                                                   place.get_latitude())))
                    self.doc.end_paragraph()

                self.print_object(level+1, place)

        if issubclass(o.__class__, gramps.gen.lib.primaryobj.BasicPrimaryObject):
            # The Gramps ID is printed by the enclosing object
            pass


        if issubclass(o.__class__, gramps.gen.lib.privacybase.PrivacyBase):
            # The privacy is printed by the enclosing object
            pass

        if isinstance(o, gramps.gen.lib.RepoRef):
            # The media type is printed by source
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Call number") + " : ")
            self.doc.end_bold()
            self.doc.write_text(o.get_call_number())
            self.doc.end_paragraph()

            repository_handle = o.get_reference_handle()
            repository = self.database.get_repository_from_handle(repository_handle)
            self.print_header(level, _("Repository"), repository.get_gramps_id(),
                              _("Repository type"), str(repository.get_type()),
                              privacy=repository.get_privacy())
            self.print_object(level+1, repository)

        if isinstance(o, gramps.gen.lib.Repository):
            # the repository type is printed by RepoRef
            pass

        if isinstance(o, gramps.gen.lib.Source):
            # The title, author, abbreviation and publication information are
            # printed by the bibliography code
#            data_map = o.get_data_map()
#            for key in data_map.keys():
#                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
#                self.doc.start_bold()
#                self.doc.write_text(_("Data") + ". " + key + " : ")
#                self.doc.end_bold()
#                self.doc.write_text(data_map[key])
#                self.doc.end_paragraph()

            reporef_list = o.get_reporef_list()
            for reporef in reporef_list:
                self.print_header(level, _("Repository reference"),
                                  type_desc=_("Media type"),
                                  obj_type=str(reporef.get_media_type()),
                                  privacy=reporef.get_privacy())
                self.print_object(level+1, reporef)

        if isinstance(o, gramps.gen.lib.Surname):
            if o.get_origintype():
                self.print_header(level, _("Surname"),
                                  type_desc=_("Origin type"),
                                  obj_type=str(o.get_origintype()))
            else:
                self.print_header(level, _("Surname"),
                                  privacy=o.get_privacy())
            self.doc.start_paragraph("PE-Level%d" % min(level+1, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Prefix, surname, connector") + " : ")
            self.doc.end_bold()
            self.doc.write_text(", ".join((o.get_prefix(), o.get_surname(),
                                           o.get_connector())))
            if o.get_primary():
                self.doc.write_text(" " + _("{This is the primary surname}"))
            self.doc.end_paragraph()

        if isinstance(o, gramps.gen.lib.surnamebase.SurnameBase):
            surname_list = o.get_surname_list()
            for surname in surname_list:
                self.print_object(level, surname)

        if issubclass(o.__class__, gramps.gen.lib.tagbase.TagBase):
            for tag_handle in o.get_tag_list():
                tag = self.database.get_tag_from_handle(tag_handle)
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Tag name") + " : ")
                self.doc.end_bold()
                self.doc.write_text(tag.get_name())
                self.doc.end_paragraph()
                self.print_object(level+1, tag)

        if issubclass(o.__class__, gramps.gen.lib.Tag):
            # The tag name is printed by TagBase
            if o.get_color() != "#000000000000" or o.get_priority() != 0:
                self.doc.start_paragraph("PE-Level%d" % min(level, 32))
                self.doc.start_bold()
                self.doc.write_text(_("Tag colour and priority") + " : ")
                self.doc.end_bold()
                self.doc.write_text(o.get_color() + ", " +
                                    "%d" % o.get_priority())
                self.doc.end_paragraph()

        if issubclass(o.__class__, gramps.gen.lib.urlbase.UrlBase):
            for url in o.get_url_list():
                self.print_header(level, _("URL"),
                                  type_desc=_("Type"),
                                  obj_type=str(url.get_type()),
                                  privacy=url.get_privacy())
                self.print_object(level+1, url)

        if isinstance(o, gramps.gen.lib.Url):
            self.doc.start_paragraph("PE-Level%d" % min(level, 32))
            self.doc.start_bold()
            self.doc.write_text(_("Description and Path") + " : ")
            self.doc.end_bold()
            self.doc.write_text(o.get_description() + ", ")
            path = o.get_path()
            if path:
                mark = IndexMark(path, LOCAL_HYPERLINK)
                self.doc.write_text(path, mark=mark)
            self.doc.end_paragraph()

        return o