summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2010-01-17 15:43:53 -0500
committerKohei Yoshida <kyoshida@novell.com>2010-01-17 15:43:53 -0500
commit2f869ddec7a47460494768e7729719c0e79beb60 (patch)
treecf168207f8af35b6fe494c35a3d6e77be5a2efe7
parent1b6adfc947d55d0b3f6c31889f91a0af5007ce1b (diff)
Initial work toward handling links.
-rw-r--r--source/docbook.py7
-rw-r--r--source/globals.py3
2 files changed, 9 insertions, 1 deletions
diff --git a/source/docbook.py b/source/docbook.py
index 71afb3a..3c80618 100644
--- a/source/docbook.py
+++ b/source/docbook.py
@@ -173,6 +173,8 @@ class DocBookConverter:
if filename == None:
return
self.__currentFileName = filename.getContent()
+ if len(self.__currentFileName) > 0 and self.__currentFileName[0] == '/':
+ self.__currentFileName = self.__currentFileName[1:]
def __getContentFromXHP (self, xhppath, dest):
xhproot = self.xhproots[xhppath]
@@ -182,6 +184,9 @@ class DocBookConverter:
# parent element for the xhp 'heading' paragraphs which should start a
# new sub-section when converting to docbook.
self.headingParent = None
+ encodedID = globals.encodeID(self.__currentFileName)
+ if len(encodedID) > 0:
+ dest.setAttr('id', encodedID)
for xhpelem in xhpbody.getChildNodes():
dest = self.__walkXHP(xhpelem, dest)
@@ -296,7 +301,7 @@ class DocBookConverter:
href = src.getAttr('href')
if href.startswith('text/scalc'):
link = dest.appendElement('link')
- link.setAttr('linkend', href)
+ link.setAttr('linkend', globals.encodeID(href))
self.__walkAllChildNodes(src, link)
else:
self.__walkAllChildNodes(src, dest)
diff --git a/source/globals.py b/source/globals.py
index 0322bd4..ec7168c 100644
--- a/source/globals.py
+++ b/source/globals.py
@@ -11,6 +11,9 @@ class Exception:
def __init__ (self, msg):
self.msg = msg
+def encodeID (orig):
+ return orig.replace('/', '_').replace('.', '_')
+
# global parameters
productName = 'OpenOffice.org'
#productName = 'Go-OO'