From 6fb6817e30f746d8d2100cc606a3cfbb1cbea86a Mon Sep 17 00:00:00 2001 From: László Németh Date: Mon, 15 Jul 2013 12:41:37 +0200 Subject: librelogo: hexa arguments fdo#66917 and cropped SVG saving Change-Id: I12ad6b63221bce0ed7d988f5c0f91dce81055ec0 --- librelogo/source/ChangeLog | 16 ++++++++++++- librelogo/source/LibreLogo/LibreLogo.py | 42 ++++++++++++++++++++++++++------- 2 files changed, 49 insertions(+), 9 deletions(-) (limited to 'librelogo') diff --git a/librelogo/source/ChangeLog b/librelogo/source/ChangeLog index 0a048135101c..e056c196df6c 100644 --- a/librelogo/source/ChangeLog +++ b/librelogo/source/ChangeLog @@ -1,4 +1,18 @@ -2012-02-24 László Németh: +2013-07-15 László Németh: + * optional named PICTURE blocks: PICTURE "name" [ CIRCLE 5 ] + * save PICTURE as cropped SVG file using path names, for example: + PICTURE "example.svg" [ CIRCLE 5 CIRCLE 20 ] ; save in the home directory + PICTURE "/home/user/example.svg" [ CIRCLE 10 ] ; absolute path (on Linux) + PICTURE "tmp/example.svg" [ CIRCLE 10 ] ; relative to the home directory + * support hexadecimal arguments + +2013-06-26 László Németh + * clockwise HEADING + +2013-04-30 László Németh + * fix hide/show turtle + +2013-02-24 László Németh: * fix Asian and CTL language support. Language recognition depends from the UI language of LibreOffice and the language(s) of the document. * fix turtle shape, the problem with the old arrow-like turtle shape diff --git a/librelogo/source/LibreLogo/LibreLogo.py b/librelogo/source/LibreLogo/LibreLogo.py index c13c70592881..e73a1736f7cd 100644 --- a/librelogo/source/LibreLogo/LibreLogo.py +++ b/librelogo/source/LibreLogo/LibreLogo.py @@ -697,10 +697,13 @@ def __cs__(select = True): if select: _.doc.CurrentController.select(_.drawpage) -def __dispatcher__(s, properties = ()): +def __dispatcher__(s, properties = (), doc = 0): ctx = XSCRIPTCONTEXT.getComponentContext() d = ctx.ServiceManager.createInstanceWithContext("com.sun.star.frame.DispatchHelper", ctx) - d.executeDispatch(_.doc.CurrentController.Frame, s, "", 0, properties) + if doc != 0: + d.executeDispatch(doc.CurrentController.Frame, s, "", 0, properties) + else: + d.executeDispatch(_.doc.CurrentController.Frame, s, "", 0, properties) def __getshape__(shapename): try: @@ -1195,15 +1198,17 @@ def position(n = -1): pos.X, pos.Y = pos.X + turtle.BoundRect.Width / 2.0, pos.Y + turtle.BoundRect.Height / 2.0 return [ pos.X * __MM10_TO_TWIP__ / __PT_TO_TWIP__, pos.Y * __MM10_TO_TWIP__ / __PT_TO_TWIP__ ] -def __groupstart__(): +def __groupstart__(name = ""): global __group__, __grouplefthang__, __groupstack__ __removeshape__(__ACTUAL__) __groupstack__.append(__group__) + if name != "": # store pic name (for correct repcount) + __groupstack__.append(name) __groupstack__.append(__grouplefthang__) __group__ = uno.getComponentContext().ServiceManager.createInstance('com.sun.star.drawing.ShapeCollection') __grouplefthang__ = 0 -def __groupend__(): +def __groupend__(name = ""): global __group__, __grouplefthang__, __groupstack__ g = 0 if __group__.getCount() > 1: @@ -1223,6 +1228,26 @@ def __groupend__(): elif __group__.getCount() == 1: g = __group__.getByIndex(0) __grouplefthang__ = min(__groupstack__.pop(), __grouplefthang__) + if name != "": + name = __groupstack__.pop() + if name and ".SVG" == name[-4:].upper() and g: + _.doc.CurrentController.select(g) + __dispatcher__(".uno:Copy") + ctx = XSCRIPTCONTEXT.getComponentContext() + d = ctx.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", ctx) + draw = d.loadComponentFromURL("private:factory/sdraw", "_blank", 0, ()) + drawpage = draw.getDrawPages().getByIndex(0) + __dispatcher__(".uno:Paste", (), draw) + pic = drawpage.getByIndex(0) + pic.setPosition(__Point__((g.BoundRect.Width - g.Size.Width)//2, (g.BoundRect.Height - g.Size.Height)//2)) + drawpage.Height, drawpage.Width = g.BoundRect.Height, g.BoundRect.Width + __time__.sleep(1) # avoid writing problem + if not os.path.isabs(name): + name = os.path.expanduser('~') + os.path.sep + name + __dispatcher__(".uno:ExportTo", (__getprop__("URL", unohelper.systemPathToFileUrl(name)), __getprop__("FilterName", "draw_svg_Export")), draw) + __time__.sleep(1) + draw.dispose() + __group__ = __groupstack__.pop() if __group__ and g: __group__.add(g) @@ -1255,7 +1280,8 @@ def __loadlang__(lang, a): { "i": repcount + str(next(loopi)), "j": repcount, "orig": re.sub( r"(?ui)(? (1 + sqrt(x)) + [r"\b(__(?:int|float|string)__len|round|abs|sin|cos|sqrt|set|list|tuple|sorted)\b ((?:\w|\d+([,.]\d+)?|0[xX][0-9a-fA-F]+|[-+*/]| )+)\)" , "\\1(\\2))" ], # fix parsing: (1 + sqrt x) -> (1 + sqrt(x)) [r"(?<=[-*/=+,]) ?\n\)(\w+)\(", "\\1()"], # read attributes, eg. x = fillcolor [r"(?<=return) ?\n\)(\w+)\(", "\\1()"], # return + user function [r"(?<=(?:Print|label)\() ?\n\)(\w+)\(", "\\1()\n"] # Print/label + user function @@ -1450,11 +1476,11 @@ def __compil__(s): expr = r"""(?iu)(?]|//|==|<=|>=|<>|!=)[ ]*|[ ]*-[ ]+|-|[ ]*[*][*][ ]*) # operators, eg. "**", " - ", "-", "- " \[*([-+]|\([ ]?)* # minus sign, parenthesis - ((%(functions)s)\b[ ]*\(*)*([0-9]+([.,][0-9]+)?|:?\w+(?:[.]\w+[\(]?[\)]?)?)]* + ((%(functions)s)\b[ ]*\(*)*(0x[0-9a-f]+|[0-9]+([.,][0-9]+)?|:?\w+(?:[.]\w+[\(]?[\)]?)?)]* ([ ]?\))*)* [\)]*){,%(repeat)s} ) -- cgit v1.2.3