librelogo/source/ChangeLog              |   16 +++++++++++-
 librelogo/source/LibreLogo/LibreLogo.py |   42 +++++++++++++++++++++++++-------
 2 files changed, 49 insertions(+), 9 deletions(-)

New commits:
commit 8a8f7fb852c7ce2713b107d8d9a33450199ae86b
Author: László Németh <nem...@numbertext.org>
Date:   Mon Jul 15 12:41:37 2013 +0200

    librelogo: hexa arguments fdo#66917 and cropped SVG saving
    
    Change-Id: I12ad6b63221bce0ed7d988f5c0f91dce81055ec0
    Reviewed-on: https://gerrit.libreoffice.org/4916
    Reviewed-by: Németh László <nem...@numbertext.org>
    Tested-by: Németh László <nem...@numbertext.org>

diff --git a/librelogo/source/ChangeLog b/librelogo/source/ChangeLog
index 0a04813..e056c19 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 bf925c8..49983d3 100644
--- a/librelogo/source/LibreLogo/LibreLogo.py
+++ b/librelogo/source/LibreLogo/LibreLogo.py
@@ -694,10 +694,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:
@@ -1192,15 +1195,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:
@@ -1220,6 +1225,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)
@@ -1252,7 +1277,8 @@ def __loadlang__(lang, a):
         { "i": repcount + str(next(loopi)), "j": repcount, "orig": re.sub( 
r"(?ui)(?<!:)\b%s\b" % repcount, repcount + str(next(loopi)-1), r.group(0)) }
     __comp__[lang] = [
     [r"(?i)(?<!:)(\b|(?=[-:]))(?:%s)\b" % "|".join([a[i].lower() for i in a if 
not "_" in i and i != "DECIMAL"]), lambda s: s.group().upper()], # uppercase 
all native commands in the source code
-    [r"(?<!:)\b(?:%s) [[]" % a['GROUP'], "\n__groupstart__()\nfor 
__groupindex__ in range(2):\n[\nif __groupindex__ == 
1:\n[\n__groupend__()\nbreak\n]\n"],
+    [r"(?<!:)\b(?:%s) \[(?= |\n)" % a['GROUP'], "\n__groupstart__()\nfor 
__groupindex__ in range(2):\n[\nif __groupindex__ == 
1:\n[\n__groupend__()\nbreak\n]\n"],
+    [r"(?<!:)\b(?:%s) (%s[^[]*)\[(?= |\n)" % (a['GROUP'], 
__DECODE_STRING_REGEX__), "\n__groupstart__(\\1)\nfor __groupindex__ in 
range(2):\n[\nif __groupindex__ == 1:\n[\n__groupend__(\\1)\nbreak\n]\n"],
     [r"(?<!:)\b(?:%s)\b" % a['GROUP'], "\n__removeshape__(__ACTUAL__)\n"],
     [r"(\n| )][ \n]*\[(\n| )", "\n]\nelse:\n[\n"], # if/else block
     [r"(?<!\n)\[(?= |\n)", ":\n[\n"], # start block
@@ -1350,7 +1376,7 @@ def __loadlang__(lang, a):
     [r"\b([0-9]+([,.][0-9]+)?)(%s)(?!\w)" % a['INCH'], "\\1*72"],
     [r"\b([0-9]+([,.][0-9]+)?)(%s)\b" % a['MM'], "\\1*%s" % __MM_TO_PT__],
     [r"\b([0-9]+([,.][0-9]+)?)(%s)\b" % a['CM'], "\\1*%s*10" % __MM_TO_PT__],
-    
[r"\b(__(?:int|float|string)__len|round|abs|sin|cos|sqrt|set|list|tuple|sorted)\b
 ((?:\w|\d+([,.]\d+)?|[-+*/]| )+)\)" , "\\1(\\2))" ], # fix parsing: (1 + sqrt 
x) -> (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
@@ -1447,11 +1473,11 @@ def __compil__(s):
     expr = r"""(?iu)(?<!def[ ])(?<![:\w])%(name)s(?!\w)(?!\()(?![ ]\()
         (
             ([ ]+\[*([-+]|\([ ]?)*((%(functions)s)\b[ ]*\(*)*
-            (?:[0-9]+([,.][0-9]+)?|:?\w+(?:[.]\w+[\(]?[\)]?)?]*|\[])]*[\)]*
+            
(?:0x[0-9a-f]+|[0-9]+([,.][0-9]+)?|:?\w+(?:[.]\w+[\(]?[\)]?)?]*|\[])]*[\)]*
             (
                 (?:[ ]*([+*/,<>]|//|==|<=|>=|<>|!=)[ ]*|[ ]*-[ ]+|-|[ 
]*[*][*][ ]*) # 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}
     )
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to