0005529: Implement clickable links in reports, at least for odf. Implemented for odf output only, using mark.type LOCAL_HYPERLINK and LOCAL_TARGET.

svn: r18766
This commit is contained in:
Tim G L Lyons 2012-01-24 18:13:23 +00:00
parent abddb6bcf6
commit 1ff2b969c4
3 changed files with 16 additions and 2 deletions

View File

@ -35,6 +35,7 @@ from paragraphstyle import ParagraphStyle, PARA_ALIGN_CENTER, PARA_ALIGN_LEFT,\
from tablestyle import TableStyle, TableCellStyle from tablestyle import TableStyle, TableCellStyle
from stylesheet import StyleSheetList, StyleSheet, SheetParser from stylesheet import StyleSheetList, StyleSheet, SheetParser
from graphicstyle import GraphicsStyle, SOLID, DASHED, DOTTED from graphicstyle import GraphicsStyle, SOLID, DASHED, DOTTED
from textdoc import TextDoc, IndexMark,INDEX_TYPE_ALP, INDEX_TYPE_TOC, URL_PATTERN from textdoc import TextDoc, IndexMark,INDEX_TYPE_ALP, INDEX_TYPE_TOC,\
URL_PATTERN, LOCAL_HYPERLINK, LOCAL_TARGET
from drawdoc import DrawDoc from drawdoc import DrawDoc
from graphdoc import GVDoc from graphdoc import GVDoc

View File

@ -62,6 +62,8 @@ URL_PATTERN = r'''(((https?|mailto):)(//([^ /?#"]*))?([^ ?#"]*)(\?([^ #"]*))?(#(
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
INDEX_TYPE_ALP = 0 INDEX_TYPE_ALP = 0
INDEX_TYPE_TOC = 1 INDEX_TYPE_TOC = 1
LOCAL_HYPERLINK = 2
LOCAL_TARGET = 3
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #

View File

@ -82,7 +82,8 @@ from xml.sax.saxutils import escape
from gen.plug.docgen import (BaseDoc, TextDoc, DrawDoc, graphicstyle, from gen.plug.docgen import (BaseDoc, TextDoc, DrawDoc, graphicstyle,
FONT_SANS_SERIF, SOLID, PAPER_PORTRAIT, FONT_SANS_SERIF, SOLID, PAPER_PORTRAIT,
INDEX_TYPE_TOC, PARA_ALIGN_CENTER, PARA_ALIGN_LEFT, INDEX_TYPE_TOC, PARA_ALIGN_CENTER, PARA_ALIGN_LEFT,
INDEX_TYPE_ALP, PARA_ALIGN_RIGHT, URL_PATTERN) INDEX_TYPE_ALP, PARA_ALIGN_RIGHT, URL_PATTERN,
LOCAL_HYPERLINK, LOCAL_TARGET)
from gen.plug.docgen.fontscale import string_width from gen.plug.docgen.fontscale import string_width
from libodfbackend import OdfBackend from libodfbackend import OdfBackend
import const import const
@ -1596,6 +1597,16 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc):
'text:string-value="%s" ' % key + 'text:string-value="%s" ' % key +
'text:outline-level="%d" />' % mark.level 'text:outline-level="%d" />' % mark.level
) )
elif mark.type == LOCAL_HYPERLINK:
self.cntnt.write(
'<text:a xlink:type="simple" xlink:href="%s">' % key)
self.cntnt.write(text)
self.cntnt.write('</text:a>')
return
elif mark.type == LOCAL_TARGET:
self.cntnt.write(
'<text:bookmark text:name="%s"/>' % key)
self.cntnt.write(text) self.cntnt.write(text)
def _write_manifest(self): def _write_manifest(self):