--- /dev/null
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Debian-Depends: poppler-utils (pdftotext)
+import sys
+from subprocess import Popen, PIPE
+
+if len(sys.argv) < 2:
+ sys.exit(0)
+
+for filename in sys.argv[1:]:
+ olddir = os.getcwd()
+ os.chdir(os.path.dirname(filename))
+ filename = os.path.basename(filename)
+ p1 = Popen(["/usr/bin/pdftotext", filename, "-"], stdout=PIPE)
+ p2 = Popen(["/bin/sed", "-e", "s|\t\r | |g;s|-‐|–|g;s| \+| |g"], stdin=p1.stdout, stdout=PIPE)
+ p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits.
+ output = p2.communicate()[0]
+ file(filename + '.txt', 'wt').write(output)
+ os.chdir(olddir)
+
+sys.exit(0)
--- /dev/null
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# Debian-Depends: python (>= 2.6)
+import sys
+import zipfile
+from xml.dom import minidom
+
+if len(sys.argv) < 2:
+ sys.exit(0)
+
+for filename in sys.argv[1:]:
+ if not zipfile.is_zipfile(filename):
+ continue
+
+ # file copy
+ filename_base, filename_ext = filename.rsplit('.', 1)
+ copyname = filename_base + '-déverrouillé.' + filename_ext
+ file(copyname, 'wb').write(file(filename, 'rb').read())
+
+ odf = zipfile.ZipFile(copyname, 'a', zipfile.ZIP_DEFLATED)
+
+ # sanity checks
+ if not odf:
+ continue # u"WARNING: skipping '%s': not a ZIP file" % filename
+ if not odf.namelist():
+ odf.close()
+ continue # u"WARNING: skipping '%s': not a ZIP file" % filename
+ if 'content.xml' not in odf.namelist() or \
+ 'styles.xml' not in odf.namelist() or \
+ 'settings.xml' not in odf.namelist():
+ odf.close()
+ continue # u"WARNING: skipping '%s': not an ODF file" % filename
+
+ ## content parsing
+ #modified = False
+ #content = minidom.parseString(odf.read('content.xml'))
+ ## unlock section protection
+ #for node in content.getElementsByTagName("text:section"):
+ # if node.getAttribute("text:protected") == 'true':
+ # node.setAttribute("text:protected", "false")
+ # modified = True
+ ## save content changes, only if necessary
+ #if modified:
+ # odf.getinfo("content.xml").filename = "content.old"
+ # odf.writestr("content.xml", content.toxml().encode('utf-8'))
+
+ # settings parsing
+ modified = False
+ settings = minidom.parseString(odf.read('settings.xml'))
+ for node in settings.getElementsByTagName("config:config-item"):
+ name = node.getAttribute("config:name")
+ # unlock form protection
+ if name == 'ProtectForm' and node.data == 'true':
+ node.data = 'false'
+ modified = True
+ # unlock document editing
+ elif name == 'LoadReadonly' and node.data == 'true':
+ node.data = 'false'
+ modified = True
+ # save settings changes, only if necessary
+ if modified:
+ odf.getinfo("settings.xml").filename = "settings.old"
+ odf.writestr("settings.xml", settings.toxml().encode('utf-8'))
+
+ odf.close()
+
+sys.exit(0)