summaryrefslogtreecommitdiff
path: root/librelogo/source/LibreLogo/LibreLogo.py
diff options
context:
space:
mode:
Diffstat (limited to 'librelogo/source/LibreLogo/LibreLogo.py')
-rw-r--r--librelogo/source/LibreLogo/LibreLogo.py51
1 files changed, 50 insertions, 1 deletions
diff --git a/librelogo/source/LibreLogo/LibreLogo.py b/librelogo/source/LibreLogo/LibreLogo.py
index d44ffa194a6d..dcbb37337454 100644
--- a/librelogo/source/LibreLogo/LibreLogo.py
+++ b/librelogo/source/LibreLogo/LibreLogo.py
@@ -67,6 +67,7 @@ __LineStyle_DOTTED__ = 2
class __Doc__:
def __init__(self, doc):
self.doc = doc
+ self.secure = False
try:
self.drawpage = doc.DrawPage # Writer
except:
@@ -381,10 +382,58 @@ class LogoProgram(threading.Thread):
self.code = code
threading.Thread.__init__(self)
+ def secure(self):
+ # 0 = secure
+ if _.secure:
+ return 0
+
+ # 1 = forms, fields or embedded objects are forbidden
+ if _.doc.DrawPage.Forms.getCount() > 0 or _.doc.getTextFields().createEnumeration().hasMoreElements() or _.doc.getEmbeddedObjects().getCount() > 0:
+ return 1
+
+ # 2 = hyperlinks with script events
+ nodes = _.doc.Text.createEnumeration()
+ while nodes.hasMoreElements():
+ node = nodes.nextElement()
+ if node.supportsService("com.sun.star.text.Paragraph"):
+ portions = node.createEnumeration()
+ while portions.hasMoreElements():
+ portion = portions.nextElement()
+ if portion.PropertySetInfo.hasPropertyByName("HyperLinkEvents"):
+ events = portion.getPropertyValue("HyperLinkEvents")
+ for event in events.getElementNames():
+ attributes = events.getByName(event)
+ for attribute in attributes:
+ if attribute.Name == "EventType" and attribute.Value == "Script":
+ return 2
+
+ # 2 = images with script events
+ images = _.doc.DrawPage.createEnumeration()
+ while images.hasMoreElements():
+ image = images.nextElement()
+ try:
+ events = image.Events
+ for event in events.getElementNames():
+ attributes = events.getByName(event)
+ for attribute in attributes:
+ if attribute.Name == "EventType" and attribute.Value == "Script":
+ return 2
+ except:
+ pass
+
+ _.secure = True
+ return 0
+
def run(self):
global __thread__
try:
- exec(self.code)
+ # check document security
+ secid = self.secure()
+ if secid > 0:
+ parent = _.doc.CurrentController.Frame.ContainerWindow
+ MessageBox(parent, "Document objects with%s script events" % [" possible", ""][secid-1], "LibreLogo program can't start", "errorbox")
+ else:
+ exec(self.code)
if _.origcursor:
__dispatcher__(".uno:Escape")
try: