From 74abeff02b750fb22fc3d56299abc2cd12d357d3 Mon Sep 17 00:00:00 2001 From: Andras Timar Date: Wed, 7 Nov 2012 23:31:44 +0100 Subject: integrate librelogo to the build Change-Id: I4cd29f6a893d72a49233bb53d19701d0bdd0e078 --- Makefile.top | 1 + Module_tail_build.mk | 1 + RepositoryModule_ooo.mk | 1 + l10ntools/source/localize.cxx | 1 + librelogo/Addons.xcu | 310 ----- librelogo/ChangeLog | 82 -- librelogo/Configuration_librelogo.mk | 18 + librelogo/Extension_librelogo.mk | 46 + librelogo/LibreLogo/LibreLogo.py | 1407 -------------------- librelogo/LibreLogoDummy.py | 14 - librelogo/META-INF/manifest.xml | 9 - librelogo/Makefile | 7 + librelogo/Module_librelogo.mk | 17 + librelogo/Office/UI/StartModuleWindowState.xcu | 22 - librelogo/Office/UI/WriterWindowState.xcu | 22 - librelogo/README | 44 +- librelogo/description-en.txt | 1 - librelogo/description-hu.txt | 1 - librelogo/description.xml | 21 - librelogo/help/en-US/LibreLogo/LibreLogo.xhp | 614 --------- librelogo/help/en-US/LibreLogo/doc.txt | 787 ----------- librelogo/help/en-US/LibreLogo/gendoc.sh | 3 - librelogo/help/en-US/LibreLogo/head | 17 - librelogo/help/en-US/help.tree | 18 - librelogo/icons/lc_arrowshapes.circular-arrow.png | Bin 787 -> 0 bytes .../icons/lc_arrowshapes.circular-leftarrow.png | Bin 1082 -> 0 bytes librelogo/icons/lc_arrowshapes.down-arrow.png | Bin 527 -> 0 bytes librelogo/icons/lc_arrowshapes.up-arrow.png | Bin 487 -> 0 bytes librelogo/icons/lc_basicstop.png | Bin 616 -> 0 bytes librelogo/icons/lc_editglossary.png | Bin 705 -> 0 bytes librelogo/icons/lc_navigationbarleft.png | Bin 831 -> 0 bytes librelogo/icons/lc_newdoc.png | Bin 445 -> 0 bytes librelogo/icons/lc_runbasic.png | Bin 740 -> 0 bytes librelogo/icons/sc_arrowshapes.circular-arrow.png | Bin 482 -> 0 bytes .../icons/sc_arrowshapes.circular-leftarrow.png | Bin 631 -> 0 bytes librelogo/icons/sc_arrowshapes.down-arrow.png | Bin 340 -> 0 bytes librelogo/icons/sc_arrowshapes.up-arrow.png | Bin 323 -> 0 bytes librelogo/icons/sc_basicstop.png | Bin 397 -> 0 bytes librelogo/icons/sc_editglossary.png | Bin 429 -> 0 bytes librelogo/icons/sc_navigationbarleft.png | Bin 626 -> 0 bytes librelogo/icons/sc_newdoc.png | Bin 350 -> 0 bytes librelogo/icons/sc_runbasic.png | Bin 534 -> 0 bytes librelogo/make.py | 30 - librelogo/prj/build.lst | 2 + librelogo/prj/d.lst | 0 librelogo/pythonpath/en.properties | 151 --- librelogo/pythonpath/hu.properties | 151 --- librelogo/pythonpath/librelogodummy_path.py | 3 - librelogo/source/ChangeLog | 82 ++ librelogo/source/LibreLogo/LibreLogo.py | 1407 ++++++++++++++++++++ librelogo/source/LibreLogoDummy.py | 14 + librelogo/source/META-INF/manifest.xml | 9 + librelogo/source/README | 43 + librelogo/source/description-en-US.txt | 1 + librelogo/source/description.xml | 20 + librelogo/source/help/en-US/LibreLogo.xhp | 388 ++++++ librelogo/source/help/en-US/help.tree | 18 + librelogo/source/help/en-US/tree_strings.xhp | 29 + .../source/icons/lc_arrowshapes.circular-arrow.png | Bin 0 -> 787 bytes .../icons/lc_arrowshapes.circular-leftarrow.png | Bin 0 -> 1082 bytes .../source/icons/lc_arrowshapes.down-arrow.png | Bin 0 -> 527 bytes librelogo/source/icons/lc_arrowshapes.up-arrow.png | Bin 0 -> 487 bytes librelogo/source/icons/lc_basicstop.png | Bin 0 -> 616 bytes librelogo/source/icons/lc_editglossary.png | Bin 0 -> 705 bytes librelogo/source/icons/lc_navigationbarleft.png | Bin 0 -> 831 bytes librelogo/source/icons/lc_newdoc.png | Bin 0 -> 445 bytes librelogo/source/icons/lc_runbasic.png | Bin 0 -> 740 bytes .../source/icons/sc_arrowshapes.circular-arrow.png | Bin 0 -> 482 bytes .../icons/sc_arrowshapes.circular-leftarrow.png | Bin 0 -> 631 bytes .../source/icons/sc_arrowshapes.down-arrow.png | Bin 0 -> 340 bytes librelogo/source/icons/sc_arrowshapes.up-arrow.png | Bin 0 -> 323 bytes librelogo/source/icons/sc_basicstop.png | Bin 0 -> 397 bytes librelogo/source/icons/sc_editglossary.png | Bin 0 -> 429 bytes librelogo/source/icons/sc_navigationbarleft.png | Bin 0 -> 626 bytes librelogo/source/icons/sc_newdoc.png | Bin 0 -> 350 bytes librelogo/source/icons/sc_runbasic.png | Bin 0 -> 534 bytes .../source/pythonpath/LibreLogo_en_US.properties | 151 +++ librelogo/source/pythonpath/librelogodummy_path.py | 3 + .../registry/data/org/openoffice/Office/Addons.xcu | 286 ++++ .../Office/UI/StartModuleWindowState.xcu | 18 + .../org/openoffice/Office/UI/WriterWindowState.xcu | 18 + 81 files changed, 2582 insertions(+), 3706 deletions(-) delete mode 100644 librelogo/Addons.xcu delete mode 100644 librelogo/ChangeLog create mode 100644 librelogo/Configuration_librelogo.mk create mode 100644 librelogo/Extension_librelogo.mk delete mode 100644 librelogo/LibreLogo/LibreLogo.py delete mode 100644 librelogo/LibreLogoDummy.py delete mode 100644 librelogo/META-INF/manifest.xml create mode 100644 librelogo/Makefile create mode 100644 librelogo/Module_librelogo.mk delete mode 100644 librelogo/Office/UI/StartModuleWindowState.xcu delete mode 100644 librelogo/Office/UI/WriterWindowState.xcu delete mode 100644 librelogo/description-en.txt delete mode 100644 librelogo/description-hu.txt delete mode 100644 librelogo/description.xml delete mode 100644 librelogo/help/en-US/LibreLogo/LibreLogo.xhp delete mode 100644 librelogo/help/en-US/LibreLogo/doc.txt delete mode 100755 librelogo/help/en-US/LibreLogo/gendoc.sh delete mode 100644 librelogo/help/en-US/LibreLogo/head delete mode 100644 librelogo/help/en-US/help.tree delete mode 100644 librelogo/icons/lc_arrowshapes.circular-arrow.png delete mode 100644 librelogo/icons/lc_arrowshapes.circular-leftarrow.png delete mode 100644 librelogo/icons/lc_arrowshapes.down-arrow.png delete mode 100644 librelogo/icons/lc_arrowshapes.up-arrow.png delete mode 100644 librelogo/icons/lc_basicstop.png delete mode 100644 librelogo/icons/lc_editglossary.png delete mode 100644 librelogo/icons/lc_navigationbarleft.png delete mode 100644 librelogo/icons/lc_newdoc.png delete mode 100644 librelogo/icons/lc_runbasic.png delete mode 100644 librelogo/icons/sc_arrowshapes.circular-arrow.png delete mode 100644 librelogo/icons/sc_arrowshapes.circular-leftarrow.png delete mode 100644 librelogo/icons/sc_arrowshapes.down-arrow.png delete mode 100644 librelogo/icons/sc_arrowshapes.up-arrow.png delete mode 100644 librelogo/icons/sc_basicstop.png delete mode 100644 librelogo/icons/sc_editglossary.png delete mode 100644 librelogo/icons/sc_navigationbarleft.png delete mode 100644 librelogo/icons/sc_newdoc.png delete mode 100644 librelogo/icons/sc_runbasic.png delete mode 100644 librelogo/make.py create mode 100644 librelogo/prj/build.lst create mode 100644 librelogo/prj/d.lst delete mode 100644 librelogo/pythonpath/en.properties delete mode 100644 librelogo/pythonpath/hu.properties delete mode 100644 librelogo/pythonpath/librelogodummy_path.py create mode 100644 librelogo/source/ChangeLog create mode 100644 librelogo/source/LibreLogo/LibreLogo.py create mode 100644 librelogo/source/LibreLogoDummy.py create mode 100644 librelogo/source/META-INF/manifest.xml create mode 100644 librelogo/source/README create mode 100644 librelogo/source/description-en-US.txt create mode 100644 librelogo/source/description.xml create mode 100644 librelogo/source/help/en-US/LibreLogo.xhp create mode 100644 librelogo/source/help/en-US/help.tree create mode 100644 librelogo/source/help/en-US/tree_strings.xhp create mode 100644 librelogo/source/icons/lc_arrowshapes.circular-arrow.png create mode 100644 librelogo/source/icons/lc_arrowshapes.circular-leftarrow.png create mode 100644 librelogo/source/icons/lc_arrowshapes.down-arrow.png create mode 100644 librelogo/source/icons/lc_arrowshapes.up-arrow.png create mode 100644 librelogo/source/icons/lc_basicstop.png create mode 100644 librelogo/source/icons/lc_editglossary.png create mode 100644 librelogo/source/icons/lc_navigationbarleft.png create mode 100644 librelogo/source/icons/lc_newdoc.png create mode 100644 librelogo/source/icons/lc_runbasic.png create mode 100644 librelogo/source/icons/sc_arrowshapes.circular-arrow.png create mode 100644 librelogo/source/icons/sc_arrowshapes.circular-leftarrow.png create mode 100644 librelogo/source/icons/sc_arrowshapes.down-arrow.png create mode 100644 librelogo/source/icons/sc_arrowshapes.up-arrow.png create mode 100644 librelogo/source/icons/sc_basicstop.png create mode 100644 librelogo/source/icons/sc_editglossary.png create mode 100644 librelogo/source/icons/sc_navigationbarleft.png create mode 100644 librelogo/source/icons/sc_newdoc.png create mode 100644 librelogo/source/icons/sc_runbasic.png create mode 100644 librelogo/source/pythonpath/LibreLogo_en_US.properties create mode 100644 librelogo/source/pythonpath/librelogodummy_path.py create mode 100644 librelogo/source/registry/data/org/openoffice/Office/Addons.xcu create mode 100644 librelogo/source/registry/data/org/openoffice/Office/UI/StartModuleWindowState.xcu create mode 100644 librelogo/source/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu diff --git a/Makefile.top b/Makefile.top index fb879512a659..1a7a9e24024c 100644 --- a/Makefile.top +++ b/Makefile.top @@ -110,6 +110,7 @@ libcmis\ libmspub\ liborcus\ libpng\ +librelogo\ libvisio\ libwpd\ libwpg\ diff --git a/Module_tail_build.mk b/Module_tail_build.mk index f70f6c4e7648..ddff7ab8d0c1 100644 --- a/Module_tail_build.mk +++ b/Module_tail_build.mk @@ -96,6 +96,7 @@ $(eval $(call gb_Module_add_moduledirs,tail_end,\ libcmis \ libmspub \ liborcus \ + librelogo \ libvisio \ libwpd \ libwpg \ diff --git a/RepositoryModule_ooo.mk b/RepositoryModule_ooo.mk index 16732d4464a8..b0112df655b0 100644 --- a/RepositoryModule_ooo.mk +++ b/RepositoryModule_ooo.mk @@ -107,6 +107,7 @@ $(eval $(call gb_Module_add_moduledirs,ooo,\ libmspub \ liborcus \ libpng \ + librelogo \ libvisio \ libwpd \ libwpg \ diff --git a/l10ntools/source/localize.cxx b/l10ntools/source/localize.cxx index 3700efea5fd9..8dfb8ec4835d 100644 --- a/l10ntools/source/localize.cxx +++ b/l10ntools/source/localize.cxx @@ -297,6 +297,7 @@ bool includeProject(rtl::OUString const & project) { "framework", "helpcontent2", "instsetoo_native", + "librelogo", "mysqlc", "nlpsolver", "officecfg", diff --git a/librelogo/Addons.xcu b/librelogo/Addons.xcu deleted file mode 100644 index 29080ed9194e..000000000000 --- a/librelogo/Addons.xcu +++ /dev/null @@ -1,310 +0,0 @@ - - - - - - - - com.sun.star.text.TextDocument - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$goforward?language=Python&location=user:uno_packages - - - Forward - Előre - - - _self - - - - - com.sun.star.text.TextDocument - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$gobackward?language=Python&location=user:uno_packages - - - Back - Hátra - - - _self - - - - - com.sun.star.text.TextDocument - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$left?language=Python&location=user:uno_packages - - - Left - Balra - - - _self - - - - - com.sun.star.text.TextDocument - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$right?language=Python&location=user:uno_packages - - - Right - Jobbra - - - _self - - - - - com.sun.star.text.TextDocument - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$run?language=Python&location=user:uno_packages - - - Start (the program in the Writer document) - Indítás (a Writer dokumentumban lévő programé) - - - _self - - - - - com.sun.star.text.TextDocument - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$stop?language=Python&location=user:uno_packages - - - Stop - Leállítás - - - _self - - - - - com.sun.star.text.TextDocument - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$home?language=Python&location=user:uno_packages - - - Home - Haza - - - _self - - - - - com.sun.star.text.TextDocument - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$clearscreen?language=Python&location=user:uno_packages - - - Clear screen - Képernyőtörlés - - - _self - - - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$commandline?language=Python&location=user:uno_packages - - - FORWARD (fd), BACK (bk), LEFT (lt), RIGHT (rt) • fd 72, bk 1cm + 1in + 1", lt 90, rt 1.5h -REPEAT num [ commands ], REPCOUNT • repeat 100 [ fd repcount lt 91 ] -PENUP (pu), PENDOWN (pd), FILL, CLOSE, HOME, CLEARSCREEN (cs), PENSIZE (ps 5) -PENCOLOR (pc), FILLCOLOR (fc) • pc “red”, pc 0xff0000, fc [255, 0, 0], fc any -POSITION (pos), HEADING (seth) • pos [0, 0], pos pagesize, seth 60, seth [0, 0] -CIRCLE, ELLIPSE, BOX, RECTANGLE • circle 10 ellipse [5, 9] box 10 rectangle [5, 2] -LABEL, TEXT, PRINT • label “Some text”, circle 200 text “center of the actual shape” -FONTFAMILY “Font” FONTSIZE 9 FONTCOLOR “red” FONTWEIGHT “bold” -TO name arguments ... END, TO name arguments, OUTPUT return_value, END -RANDOM, SQRT, INT, COUNT, ABS, SIN, COS, INPUT • ps random 100, print count “string” -PICTURE (pic) [ ... ] • group different shapes: pic [ fd 100 circle 50 ] -ELŐRE (e), HÁTRA (h), BALRA (b), JOBBRA (j) • e 72, h 1cm + 1in + 1", b 90, j 1,5ó -ISMÉTLÉS (ism) hányszor [ parancsok ], HÁNYADIK • ism 100 [ e hányadik b 91 ] -TOLLATFEL (tf), TOLLATLE (tl), TÖLT, ZÁR, HAZA, TÖRÖLKÉP, TOLLVASTAGSÁG (tv 5) -TOLLSZÍN (tsz), TÖLTŐSZÍN (tlsz) • tsz „kék”, tsz 0xff0000, tsz [0, 0, 0], tsz tetsz -HELY, IRÁNY • hely [0, 0], hely oldalméret, irány 60, irány [0, 0] -KÖR, ELLIPSZIS, NÉGYZET, TÉGLALAP • kör 100, ellipszis [50, 100], négyzet 100 -CÍMKE, SZÖVEG, KI • „címke szöveg”, kör 200 szöveg „körfelirat” ki 5+5 -BETŰCSALÁD „betű” BETŰMÉRET 24 BETŰSZÍN „kék” BETŰVASTAGSÁG „vastag” -EZ név változók ... VÉGE, EZ név változók, EREDMÉNY visszatérési_érték, VÉGE -VÉLETLENSZÁM (vszám), GYÖK, EGÉSZ, DARAB (db), BE • e vszám 100, ki db „betűk” -KÉP [ ... ] • alakzatok csoportosítása: kép [ e 100 kör 50 ] - - - _self - - - com.sun.star.text.TextDocument - - - Editfield - - - 300 - - - - - com.sun.star.text.TextDocument - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$__translate__?language=Python&location=user:uno_packages - - - Uppercase commands, also translate them to the language of the document - Parancsok nagybetűsítése és fordítása a dokumentum nyelvére - - - _self - - - - - - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$goforward?language=Python&location=user:uno_packages - - - - %origin%/icons/sc_arrowshapes.up-arrow.png - - - %origin%/icons/lc_arrowshapes.up-arrow.png - - - - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$gobackward?language=Python&location=user:uno_packages - - - - %origin%/icons/sc_arrowshapes.down-arrow.png - - - %origin%/icons/lc_arrowshapes.down-arrow.png - - - - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$left?language=Python&location=user:uno_packages - - - - %origin%/icons/sc_arrowshapes.circular-leftarrow.png - - - %origin%/icons/lc_arrowshapes.circular-leftarrow.png - - - - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$right?language=Python&location=user:uno_packages - - - - %origin%/icons/sc_arrowshapes.circular-arrow.png - - - %origin%/icons/lc_arrowshapes.circular-arrow.png - - - - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$run?language=Python&location=user:uno_packages - - - - %origin%/icons/sc_runbasic.png - - - %origin%/icons/lc_runbasic.png - - - - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$stop?language=Python&location=user:uno_packages - - - - %origin%/icons/sc_basicstop.png - - - %origin%/icons/lc_basicstop.png - - - - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$home?language=Python&location=user:uno_packages - - - - %origin%/icons/sc_navigationbarleft.png - - - %origin%/icons/lc_navigationbarleft.png - - - - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$clearscreen?language=Python&location=user:uno_packages - - - - %origin%/icons/sc_newdoc.png - - - %origin%/icons/lc_newdoc.png - - - - - - vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$__translate__?language=Python&location=user:uno_packages - - - - %origin%/icons/sc_editglossary.png - - - %origin%/icons/lc_editglossary.png - - - - - - - - diff --git a/librelogo/ChangeLog b/librelogo/ChangeLog deleted file mode 100644 index 17f19a88a998..000000000000 --- a/librelogo/ChangeLog +++ /dev/null @@ -1,82 +0,0 @@ -2012-11-06 László Németh: - * uppercase/translation icon: - - expands and uppercase Logo commands (fd -> FORWARD) - - translation between supported languages (commands, decimal sign, for/in order) - * new icon for clear screen - * add English manual (see LibreLogo/Logo/Turtle graphics in Help) - -2012-10-25 László Németh: - * fix positioning to the faulty program line - * program cache depends from the (modified) language of the document, too - -2012-10-21 László Németh: - * speed up command line - * add multiline tooltip to the command line (it works well from LibO 3.6.2) - * random color constants: ~color, eg. '~orange', '~green' etc. - * handle modulo operator - * ask before the compilation of long documents (avoid freezings) - * add compilation cache to the multiline programs - * better help window caption in the command line - -2012-06-27 László Németh: - * fix __string__ (use localized decimal sign) - * fix repcount in loops with inner picture block - * handle reopened documents - * modified argument list of custom dashed penstyle - * fix warning messages at maximum recursion depth and memory - * add hatching styles (fillstyle num or - fillstyle [line count(max 3), color, distance, degree] - * add localized set(), range(), sorted() - * fix turtle selection at program start - * modified turtle colors - * fix showturtle - * fix LineStyle_SOLID and LineStyle_DASHED - * add repcount to the infinite loop - * add logical expression and better list support to the simple LibreLogo expression parser - * add string size limit for Print() - * support "pic" without block: new shape - * use localized __string__ for STR instead of str - * add min, max, and regex functions: sub, search, findall - * fix double round in localizations - * more stable dotted lines in the PDF export (implemented as arrays of dot-headed arrows) - * circles with dotted lines - * working pos and pagesize indices in expressions - -2012-05-17 László Németh: - * fix opt. suffix syntax of for+in (eg. with Finnish :ssa, Hungarian -ban) - * add dashed outline of turtle to show "pen up" state - * fix initial turtle focus for OpenOffice.org and older LibreOffice versions - * parsing simple (with 0 or 1 argument) user functions in complex expressions - * add localized "global" - * add localized operator "in" for logical expressions - * parsing user functions with 2 or more arguments in simple numerical expressions - * function heading supports coordinates - * function position supports drawing - * function pensize supports argument any - * set SizeProtect feature of turtle shape - * replace random while repcount variable with iterator - * fix repcount checking in conditions of "while" loops - * add repcount support to "for x in y" loops - * fix OUTPUT and STOP for lines with multiple commands - * fix = -> == conversion in logical expressions in OUTPUT - * fix multiple document support using CreationDate instead of Title - * better OpenOffice.org 3.2 compatibility (optional usage of feature Visible) - -2012-05-08 László Németh: - * picture [] handles left hanging shapes better - * function random works on lists or list-convertable objects (string, tuple, dict, set), too - * faster "label" (remove unnecessary shape search) - * document-level turtle states - * clean name spaces - * localization of "pi" (localizations support greek letter pi as alternative) - * localized "float" - * int & float support localized decimal signs and measurements (float '10,5cm') - * print, label, text support localized decimal sign - -2012-05-02 László Németh: - * fix slow drawing of new line shapes (unnecessary shape search) - * "circle" and "square" are synonyms of ellipse and rectangle, eg. - square num = rectangle [num, num] - -2012-04-27 László Németh: - * Initial release diff --git a/librelogo/Configuration_librelogo.mk b/librelogo/Configuration_librelogo.mk new file mode 100644 index 000000000000..00983886a362 --- /dev/null +++ b/librelogo/Configuration_librelogo.mk @@ -0,0 +1,18 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Configuration_Configuration,librelogo,nodeliver)) + +$(eval $(call gb_Configuration_add_localized_datas,librelogo,librelogo/source/registry/data,\ + org/openoffice/Office/Addons.xcu \ + org/openoffice/Office/UI/StartModuleWindowState.xcu \ + org/openoffice/Office/UI/WriterWindowState.xcu \ +)) + +# vim:set shiftwidth=4 softtabstop=4 expandtab: diff --git a/librelogo/Extension_librelogo.mk b/librelogo/Extension_librelogo.mk new file mode 100644 index 000000000000..1c80e9dcba80 --- /dev/null +++ b/librelogo/Extension_librelogo.mk @@ -0,0 +1,46 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Extension_Extension,librelogo,librelogo/source)) + +$(eval $(call gb_Extension_add_files,librelogo,icons,\ + $(SRCDIR)/librelogo/source/icons/lc_arrowshapes.circular-arrow.png \ + $(SRCDIR)/librelogo/source/icons/lc_arrowshapes.circular-leftarrow.png \ + $(SRCDIR)/librelogo/source/icons/lc_arrowshapes.down-arrow.png \ + $(SRCDIR)/librelogo/source/icons/lc_arrowshapes.up-arrow.png \ + $(SRCDIR)/librelogo/source/icons/lc_basicstop.png \ + $(SRCDIR)/librelogo/source/icons/lc_editglossary.png \ + $(SRCDIR)/librelogo/source/icons/lc_navigationbarleft.png \ + $(SRCDIR)/librelogo/source/icons/lc_newdoc.png \ + $(SRCDIR)/librelogo/source/icons/lc_runbasic.png \ + $(SRCDIR)/librelogo/source/icons/sc_arrowshapes.circular-arrow.png \ + $(SRCDIR)/librelogo/source/icons/sc_arrowshapes.circular-leftarrow.png \ + $(SRCDIR)/librelogo/source/icons/sc_arrowshapes.down-arrow.png \ + $(SRCDIR)/librelogo/source/icons/sc_arrowshapes.up-arrow.png \ + $(SRCDIR)/librelogo/source/icons/sc_basicstop.png \ + $(SRCDIR)/librelogo/source/icons/sc_editglossary.png \ + $(SRCDIR)/librelogo/source/icons/sc_navigationbarleft.png \ + $(SRCDIR)/librelogo/source/icons/sc_newdoc.png \ + $(SRCDIR)/librelogo/source/icons/sc_runbasic.png \ +)) + +$(eval $(call gb_Extension_add_file,librelogo,LibreLogoDummy.py,$(SRCDIR)/librelogo/source/LibreLogoDummy.py)) +$(eval $(call gb_Extension_add_file,librelogo,pythonpath/librelogodummy_path.py,$(SRCDIR)/librelogo/source/pythonpath/librelogodummy_path.py)) +$(eval $(call gb_Extension_add_file,librelogo,LibreLogo/LibreLogo.py,$(SRCDIR)/librelogo/source/LibreLogo/LibreLogo.py)) +$(eval $(call gb_Extension_add_file,librelogo,Addons.xcu,$(call gb_XcuFile_for_extension,librelogo/source/registry/data/org/openoffice/Office/Addons.xcu))) +$(eval $(call gb_Extension_add_file,librelogo,Office/UI/StartModuleWindowState.xcu,$(call gb_XcuFile_for_extension,librelogo/source/registry/data/org/openoffice/Office/UI/StartModuleWindowState.xcu))) +$(eval $(call gb_Extension_add_file,librelogo,Office/UI/WriterWindowState.xcu,$(call gb_XcuFile_for_extension,librelogo/source/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu))) + +$(eval $(call gb_Extension_localize_properties,librelogo,pythonpath/LibreLogo_en_US.properties,$(SRCDIR)/librelogo/source/pythonpath/LibreLogo_en_US.properties)) + +$(eval $(call gb_Extension_add_helpfile,librelogo,$(SRCDIR)/librelogo/source/help/en-US,org.openoffice.comp.pyuno.LibreLogo/LibreLogo.xhp,LibreLogo.xhp)) + +$(eval $(call gb_Extension_add_helptreefile,librelogo,$(SRCDIR)/librelogo/source/help/en-US,/help.tree,/help.tree,org.openoffice.comp.pyuno.LibreLogo)) + +# vim:set shiftwidth=4 softtabstop=4 expandtab: diff --git a/librelogo/LibreLogo/LibreLogo.py b/librelogo/LibreLogo/LibreLogo.py deleted file mode 100644 index 34f271b4bbfa..000000000000 --- a/librelogo/LibreLogo/LibreLogo.py +++ /dev/null @@ -1,1407 +0,0 @@ -# -*- encoding: UTF-8 -*- -# -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -import sys, os, uno, unohelper -import re, random, traceback, itertools -import threading, time as __time__ - -ctx = uno.getComponentContext() -__lngpath__ = re.sub("[\w_.]*$", "", ctx.ServiceManager.createInstanceWithContext("org.openoffice.LibreLogo.LibreLogoDummy", ctx).get_path()) -__translang__ = "cz|de|dk|en|es|fr|hu|it|nl|no|pl|pt|ru|se|sl" # FIXME supported languages for language guessing, expand this list, according to the localizations -__lng__ = {} -__docs__ = {} -__prevcode__ = None -__prevlang__ = None -__prevcompiledcode__ = None -__thread__ = None -__lock__ = threading.Lock() -__halt__ = False -__compiled__ = "" -__group__ = 0 -__groupstack__ = [] -__grouplefthang__ = 0 -__comp__ = {} -__strings__ = [] -__colors__ = {} -__COLORS__ = ['BLACK', 0x000000], ['SILVER', 0xc0c0c0], ['GRAY', 0x808080], \ - ['WHITE', 0xffffff], ['MAROON', 0x800000], ['RED', 0xff0000], \ - ['PURPLE', 0x800080], ['FUCHSIA', 0xff00ff], ['GREEN', 0x008000], \ - ['LIME', 0x00ff00], ['OLIVE', 0x808000], ['YELLOW', 0xffff00], \ - ['NAVY', 0x000080], ['BLUE', 0x0000ff], ['TEAL', 0x008080], \ - ['AQUA', 0x00ffff], ['PINK', 0xffc0cb], ['TOMATO', 0xff6347], \ - ['ORANGE', 0xffa500], ['GOLD', 0xffd700], ['VIOLET', 0x9400d3], \ - ['SKYBLUE', 0x87ceeb], ['CHOCOLATE', 0xd2691e], ['BROWN', 0xa52a2a], \ - ['INVISIBLE', 0xff000000] -__SLEEP_SLICE_IN_MILLISECONDS__ = 500 -__PT_TO_TWIP__ = 20 -__MM_TO_PT__ = 1/(25.4/72) -__MM10_TO_TWIP__ = 1/(2540.0/72/20) # 0.01 mm to twentieth point -__FILLCOLOR__ = 0x8000ff00 -__LINEWIDTH__ = 0.5 * __PT_TO_TWIP__ -__ENCODED_STRING__ = "_s_%s___" -__DECODE_STRING_REGEX__ = "_s_([0-9]+)___" -__LINEBREAK__ = "#_@L_i_N_e@_#" -__TURTLE__ = "turtle" -__ACTUAL__ = "actual" -__BASEFONTFAMILY__ = "Linux Biolinum G" -__LineStyle_DOTTED__ = 2 - -class __Doc__: - def __init__(self, doc): - self.doc = doc - try: - self.drawpage = doc.DrawPage # Writer - except: - self.drawpage = doc.DrawPages.getByIndex(0) # Draw, Impress - self.shapecache = {} - self.zoomvalue = 0 - self.initialize() - - def initialize(self): - self.pen = 1 - self.pencolor = 0 - self.pensize = __LINEWIDTH__ - self.linestyle = __LineStyle_SOLID__ - self.linejoint = __ROUNDED__ - self.oldlc = 0 - self.oldlw = 0 - self.oldls = __LineStyle_SOLID__ - self.oldlj = __ROUNDED__ - self.continuous = True - self.areacolor = __FILLCOLOR__ - self.hatch = None - self.textcolor = 0 - self.fontfamily = __BASEFONTFAMILY__ - self.fontheight = 12 - self.fontweight = 100 - self.fontstyle = 0 - -from math import pi, sin, cos, asin, sqrt - -from com.sun.star.awt import Point as __Point__ -from com.sun.star.drawing import LineDash as __LineDash__ -from com.sun.star.drawing import Hatch as __Hatch__ -from com.sun.star.drawing import PolyPolygonBezierCoords as __Bezier__ -from com.sun.star.text.TextContentAnchorType import AT_PAGE as __AT_PAGE__ -from com.sun.star.text.WrapTextMode import THROUGHT as __THROUGHT__ -from com.sun.star.drawing.LineJoint import NONE as __Joint_NONE__ -from com.sun.star.drawing.LineJoint import BEVEL as __BEVEL__ -from com.sun.star.drawing.LineJoint import MITER as __MITER__ -from com.sun.star.drawing.LineJoint import ROUND as __ROUNDED__ -from com.sun.star.drawing.LineStyle import SOLID as __LineStyle_SOLID__ -from com.sun.star.drawing.LineStyle import DASH as __LineStyle_DASHED__ -from com.sun.star.drawing.DashStyle import RECT as __DashStyle_RECT__ -from com.sun.star.drawing.DashStyle import ROUND as __DashStyle_ROUND__ -from com.sun.star.drawing.DashStyle import ROUNDRELATIVE as __DashStyle_ROUNDRELATIVE__ -from com.sun.star.drawing.CircleKind import FULL as __FULL__ -from com.sun.star.drawing.CircleKind import SECTION as __SECTION__ -from com.sun.star.drawing.CircleKind import CUT as __CUT__ -from com.sun.star.drawing.CircleKind import ARC as __ARC__ -from com.sun.star.awt.FontSlant import NONE as __Slant_NONE__ -from com.sun.star.awt.FontSlant import ITALIC as __Slant_ITALIC__ -from com.sun.star.awt import Size as __Size__ -from com.sun.star.awt import WindowDescriptor as __WinDesc__ -from com.sun.star.awt.WindowClass import MODALTOP as __MODALTOP__ -from com.sun.star.awt.VclWindowPeerAttribute import OK as __OK__ -from com.sun.star.awt.VclWindowPeerAttribute import YES_NO_CANCEL as __YES_NO_CANCEL__ # OK_CANCEL, YES_NO, RETRY_CANCEL, DEF_OK, DEF_CANCEL, DEF_RETRY, DEF_YES, DEF_NO -from com.sun.star.awt.PushButtonType import OK as __Button_OK__ -from com.sun.star.awt.PushButtonType import CANCEL as __Button_CANCEL__ -from com.sun.star.util.MeasureUnit import APPFONT as __APPFONT__ -from com.sun.star.beans import PropertyValue as __property__ -from com.sun.star.lang import Locale - -def __getprop__(name, value): - p, p.Name, p.Value = __property__(), name, value - return p - -def __l12n__(lng): - try: - return __lng__[lng] - except: - try: - __lng__[lng] = dict([[i.split("=")[0].strip(), i.split("=")[1].strip().decode("unicode-escape")] for i in open(__lngpath__ + lng + ".properties", 'r').readlines() if "=" in i]) - return __lng__[lng] - except: - return None - -# dot for dotted line (implemented as an array of dot-headed arrows, because PostScript dot isn't supported by Writer) -__bezierdot__ = __Bezier__() -__dots__ = [] -for i in range(32): - __dots__ += [__Point__(round(sin(360.0/32 * i * pi/180.0) * 1000), round(cos(360.0/32 * i * pi/180) * 1000))] -__bezierdot__.Coordinates = (tuple(__dots__),) -__bezierdot__.Flags = ((0,) * 32,) - -def __getdocument__(): - global __docs__, _ - doc = XSCRIPTCONTEXT.getDocument() - try: - _ = __docs__[doc.Title] - _.doc.Title # Is existing instance (not the garbage of the previous instance of a reopened document or a new "Untitled 1")? - except: - _ = __Doc__(doc) - __docs__[doc.Title] = _ - -# input function, result: input string or 0 -def Input(s): - try: - ctx = uno.getComponentContext() - smgr = ctx.ServiceManager - text = "" - - # dialog - d = smgr.createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", ctx) - ps = _.doc.CurrentController.Frame.ContainerWindow.getPosSize() - lo = _.doc.CurrentController.Frame.ContainerWindow.convertSizeToLogic(__Size__(ps.Width, ps.Height), __APPFONT__) - d.PositionX, d.PositionY, d.Width, d.Height = lo.Width/2 - 75, lo.Height/2 - 25, 150, 50 - - # label - l = d.createInstance("com.sun.star.awt.UnoControlFixedTextModel" ) - - if type(s) == list: - text = s[1] - s = s[0] - l.PositionX, l.PositionY, l.Width, l.Height, l.Name, l.TabIndex, l.Label = 5, 4, 140, 14, "l1", 2, s - - # textbox or combobox - e = d.createInstance("com.sun.star.awt.UnoControlEditModel") - e.PositionX, e.PositionY, e.Width, e.Height, e.Name, e.TabIndex = 5, 14, 140, 12, "e1", 0 - - # buttons - b = d.createInstance( "com.sun.star.awt.UnoControlButtonModel" ) - b.PositionX, b.PositionY, b.Width, b.Height, b.Name, b.TabIndex, b.PushButtonType, b.DefaultButton = 55, 32, 45, 14, "b1", 1, __Button_OK__, True - b2 = d.createInstance( "com.sun.star.awt.UnoControlButtonModel" ) - b2.PositionX, b2.PositionY, b2.Width, b2.Height, b2.Name, b2.TabIndex, b2.PushButtonType = 100, 32, 45, 14, "b2", 1, __Button_CANCEL__ - - # insert the control models into the dialog model - d.insertByName( "l1", l) - d.insertByName( "b1", b) - d.insertByName( "b2", b2) - d.insertByName( "e1", e) - - # create the dialog control and set the model - controlContainer = smgr.createInstanceWithContext("com.sun.star.awt.UnoControlDialog", ctx) - controlContainer.setModel(d) - - # create a peer - toolkit = smgr.createInstanceWithContext("com.sun.star.awt.ExtToolkit", ctx) - controlContainer.setVisible(False) - controlContainer.createPeer(toolkit, None) - - # execute it - inputtext = controlContainer.execute() - if inputtext: - inputtext = e.Text - - # dispose the dialog - controlContainer.dispose() - return inputtext - except Exception, e: - __trace__() - -def __string__(s, decimal = None): # convert decimal sign, localized BOOL and SET - if not decimal: - decimal = _.decimal - if decimal == ',' and type(s) == float: - return str(s).replace(".", ",") - if type(s) in [list, tuple, dict, set]: - __strings__ = [] - s = re.sub("(?u)(['\"])(([^'\"]|\\['\"])*)(? "for x in y" - exception += ['IN'] - text = re.sub(ur"(?ui)\b((?:%s) +:?\w+) +([^\n]+)(?:%s) +(?=[[] |[[]\n)" % (lang['FOR'], in1), "\\1 %s \\2 " % in2, text) - text = re.sub(ur"(?ui)(:?\b\w+|[[][^[\n]*])\b(?:%s)\b" % in1, "%s \\1" % in2, text) - elif in1[0] != '-' and in2[0] == '-': # "for x in y" -> "for x y-in" - exception += ['IN'] - text = re.sub(ur"(?ui)(?<=\n)((?:%s)\b +:?\w+) +(?:%s) +([^\n]+?) +(?=[[] |[[]\n)" % (lang['FOR'], in1), "\\1 \\2%s " % in2, text) - text = re.sub(ur"(?ui)(?", line ' - message = traceback.format_exc() - l = re.findall(TRACEPATTERN + '[0-9]+', message) - if len(l) > 0 and not "SystemExit" in message: - line = len(re.findall(__LINEBREAK__, ''.join(self.code.split("\n")[:int(l[-1][len(TRACEPATTERN):])]))) + 1 - caption = __l12n__(_.lng)['LIBRELOGO'] - if __prevcode__ and "\n" in __prevcode__: - __gotoline__(line) - caption = __l12n__(_.lng)['ERROR'] % line - parent = _.doc.CurrentController.Frame.ContainerWindow - if "maximum recursion" in message: - MessageBox(parent, __l12n__(_.lng)['ERR_STOP'] + " " + __l12n__(_.lng)['ERR_MAXRECURSION'] % sys.getrecursionlimit(), __l12n__(_.lng)['LIBRELOGO']) - elif "cannot initialize memory" in message or "Couldn't instantiate" in message: - MessageBox(parent, __l12n__(_.lng)['ERR_STOP'] + " " + __l12n__(_.lng)['ERR_MEMORY'], __l12n__(_.lng)['LIBRELOGO']) - elif "ZeroDivisionError" in message: - MessageBox(parent, __l12n__(_.lng)['ERR_ZERODIVISION'], caption, "errorbox") - elif "IndexError" in message: - MessageBox(parent, __l12n__(_.lng)['ERR_INDEX'], caption, "errorbox") - elif "KeyError" in message: - MessageBox(parent, __l12n__(_.lng)['ERR_KEY'] % eval(re.search("KeyError: ([^\n]*)", message).group(1)), caption, "errorbox") - elif "NameError" in message: - if "__repeat__" in message: - MessageBox(parent, __l12n__(_.lng)['ERR_ARGUMENTS'] % (__locname__('REPEAT'), 1, 0), caption, "errorbox") - else: - MessageBox(parent, __l12n__(_.lng)['ERR_NAME'] % \ - to_unicode(re.search("(?<=name ')[\w_]*(?=')", message).group(0)), caption, "errorbox") - elif "TypeError" in message and "argument" in message and "given" in message: - r = re.search("([\w_]*)[(][)][^\n]* (\w+) arguments? [(](\d+)", message) # XXX later: handle 'no arguments' + plural - MessageBox(parent, __l12n__(_.lng)['ERR_ARGUMENTS'] % (__locname__(r.group(1)), r.group(2), r.group(3)), caption, "errorbox") - else: - origline = __compiled__.split("\n")[line-1] - if not "com.sun.star" in message and not "__repeat__" in message and not "*)" in message and ("[" in origline or "]" in origline): - MessageBox(parent, __l12n__(_.lng)['ERR_BLOCK'], caption, "errorbox") - else: - MessageBox(parent, __l12n__(_.lng)['ERROR'] %line, __l12n__(_.lng)['LIBRELOGO'], "errorbox") - __trace__() - except: - pass - with __lock__: - __thread__ = None - - -def __encodestring__(m): - __strings__.append(re.sub("\\[^\\]", "", m.group(2))) - return __ENCODED_STRING__ % (len(__strings__) - 1) - -def __decodestring__(m): - return "u'%s'" % __strings__[int(m.group(1))] - -def __decodestring2__(m): - return __l12n__(_.lng)['LEFTSTRING'][0] + __strings__[int(m.group(1))] + __l12n__(_.lng)['RIGHTSTRING'][0] - -def __initialize__(): - global __halt__, __thread__ - __getdocument__() - _.zoomvalue = _.doc.CurrentController.getViewSettings().ZoomValue - shape = __getshape__(__TURTLE__) - if not shape: - shape = _.doc.createInstance( "com.sun.star.drawing.PolyPolygonShape" ) - shape.AnchorType = __AT_PAGE__ - shape.TextWrap = __THROUGHT__ - shape.Opaque = True - _.drawpage.add(shape) - shape.PolyPolygon = ((__Point__(-60, 0), __Point__(0, -100), __Point__(60, 0)), (__Point__(0, 0), __Point__(0, 100)), \ - (__Point__(-250, 0),), (__Point__(0, 250),), (__Point__(250, 0),), (__Point__(0, -250),), # single points for wider selection - (__Point__(0, 0),)) # last point for position handling - _.shapecache[__TURTLE__] = shape - shape.Name = __TURTLE__ - _.initialize() - turtlehome() - _.doc.CurrentController.select(shape) - shape.LineJoint = __MITER__ - shape.Shadow = True - shape.FillColor, transparence = __splitcolor__(_.areacolor) - shape.FillTransparence = min(95, transparence) - shape.ShadowColor, shape.ShadowTransparence, shape.ShadowXDistance, shape.ShadowYDistance = (0, 20, 0, 0) -# shape.ShadowColor, shape.ShadowTransparence, shape.ShadowXDistance, shape.ShadowYDistance = (0, max(20, 100 - transparence), 0, 0) - shape.LineColor, shape.LineTransparence = __splitcolor__(_.pencolor) - shape.LineWidth = min(_.pensize, (1 + _.pen * 2) * __PT_TO_TWIP__) - shape.SizeProtect = True - -def pagesize(n = -1): - if n == -1: - ps = _.doc.CurrentController.getViewCursor().PageStyleName - page = _.doc.StyleFamilies.getByName("PageStyles").getByName(ps) - return [page.Width * __MM10_TO_TWIP__ / __PT_TO_TWIP__, page.Height * __MM10_TO_TWIP__ / __PT_TO_TWIP__] - return None - -def turtlehome(): - turtle = __getshape__(__TURTLE__) - if turtle: - ps = _.doc.CurrentController.getViewCursor().PageStyleName - page = _.doc.StyleFamilies.getByName("PageStyles").getByName(ps) - turtle.setPosition(__Point__((page.Width - turtle.BoundRect.Width)/2, (page.Height - turtle.BoundRect.Height)/2)) - turtle.LineStyle = __LineStyle_SOLID__ - turtle.LineJoint = __MITER__ - turtle.LineWidth = min(_.pensize, (1 + _.pen * 2) * __PT_TO_TWIP__) - turtle.LineColor, none = __splitcolor__(_.pencolor) - turtle.LineTransparence = 25 - turtle.RotateAngle = 0 - turtle.ZOrder = 1000 - -def __pen__(n): - _.pen = n - turtle = __getshape__(__TURTLE__) - if turtle: - if n: - turtle.LineStyle = __LineStyle_SOLID__ - turtle.LineWidth = min(_.pensize, 3 * __PT_TO_TWIP__) - else: - turtle.LineStyle = __LineStyle_DASHED__ - turtle.LineDash = __LineDash__(__DashStyle_RECT__, 0, 0, 1, __PT_TO_TWIP__, __PT_TO_TWIP__) - turtle.LineWidth = min(_.pensize, __PT_TO_TWIP__) - - -def __visible__(shape, visible = -1): # for OOo 3.2 compatibility - try: - if visible == -1: - return shape.Visible - shape.Visible = visible - except: - return True - -def hideturtle(): - turtle = __getshape__(__TURTLE__) - if turtle: - __visible__(turtle, False) - turtle.LineTransparence, turtle.FillTransparence = 100, 100 # for saved files - __dispatcher__(".uno:Escape") - -def showturtle(): - turtle = __getshape__(__TURTLE__) - if turtle: - if not turtle.Parent: - _.drawpage.add(turtle) - pencolor(_.pencolor) - fillcolor(_.areacolor) - pensize(_.pensize/__PT_TO_TWIP__) - __visible__(turtle, True) - _.doc.CurrentController.select(__getshape__(__TURTLE__)) - else: - __initialize__() - -def left(arg=None): - if __thread__: - return None - __initialize__() - turtle = uno.getComponentContext().ServiceManager.createInstance('com.sun.star.drawing.ShapeCollection') - turtle.add(__getshape__(__TURTLE__)) - _.doc.CurrentController.select(turtle) -# _.doc.CurrentController.select(__getshape__(__TURTLE__)) # it works from LibreOffice 3.5 - rotate(__TURTLE__, 1500) - return None - -def right(arg=None): - if __thread__: - return None - __initialize__() - turtle = uno.getComponentContext().ServiceManager.createInstance('com.sun.star.drawing.ShapeCollection') - turtle.add(__getshape__(__TURTLE__)) - _.doc.CurrentController.select(turtle) - rotate(__TURTLE__, -1500) - return None - -def goforward(arg=None): - if __thread__: - return None - __initialize__() - turtle = uno.getComponentContext().ServiceManager.createInstance('com.sun.star.drawing.ShapeCollection') - turtle.add(__getshape__(__TURTLE__)) - _.doc.CurrentController.select(turtle) - forward(10) - return None - -def gobackward(arg=None): - if __thread__: - return None - __initialize__() - turtle = uno.getComponentContext().ServiceManager.createInstance('com.sun.star.drawing.ShapeCollection') - turtle.add(__getshape__(__TURTLE__)) - _.doc.CurrentController.select(turtle) - backward(10) - return None - -def commandline(arg=None, arg2=None): - run(arg, arg2) - -def __setlang__(): - global _ - loc = _.doc.CurrentController.getViewCursor().CharLocale - _.lng = loc.Language + '_' + loc.Country - if not __l12n__(_.lng): - _.lng = loc.Language - if not __l12n__(_.lng): - _.lng = "en" - -def run(arg=None, arg2 = -1): - global _, __thread__, __halt__, _, __prevcode__, __prevlang__, __prevcompiledcode__ - if __thread__: - return None - with __lock__: - __thread__ = 1 - try: - __initialize__() - __setlang__() - if arg2 == -1: - arg2 = _.doc.getText().getString() - if len(arg2) > 20000: - if MessageBox(_.doc.CurrentController.Frame.ContainerWindow, __l12n__(_.lng)['ERR_NOTAPROGRAM'], __l12n__(_.lng)['LIBRELOGO'], "querybox", __YES_NO_CANCEL__) <> 2: - with __lock__: - __thread__ = None - return None - __gotoline__(1) - if __prevcode__ and __prevcode__ == arg2 and __prevlang__ == _.lng: - __thread__ = LogoProgram(__prevcompiledcode__) - else: - __prevcode__ = arg2 - __prevlang__ = _.lng - __prevcompiledcode__ = __compil__(arg2) - __thread__ = LogoProgram(__prevcompiledcode__) - __halt__ = False - turtle = uno.getComponentContext().ServiceManager.createInstance('com.sun.star.drawing.ShapeCollection') - turtle.add(__getshape__(__TURTLE__)) - _.doc.CurrentController.select(turtle) - __thread__.start() - except Exception as e: - __thread__ = None - __trace__() - return None - -def stop(arg=None): - global __halt__ - with __lock__: - __halt__ = True - return None - -def home(arg=None): - if __thread__: - return None - __getdocument__() - turtle = __getshape__(__TURTLE__) - if turtle: - __removeshape__(__TURTLE__) - _.drawpage.remove(turtle) - __initialize__() - __dispatcher__(".uno:Escape") - if not __halt__: - return None - _.pencolor = 0 - _.pensize = __LINEWIDTH__ - _.areacolor = __FILLCOLOR__ - pen = 1 - __removeshape__(__ACTUAL__) - -def clearscreen(arg=None): - __getdocument__() - turtle = __getshape__(__TURTLE__) - if not turtle: - __initialize__() - if not __halt__: - return - __cs__(False) - __dispatcher__(".uno:Escape") - -def __checkhalt__(): - global __thread__, __halt__ - if __halt__: - with __lock__: - __thread__ = None - sys.exit() - -def __cs__(select = True): - turtle = __getshape__(__TURTLE__) - if turtle: - __visible__(turtle, False) - if _.doc.CurrentController.select(_.drawpage) and \ - _.doc.CurrentController.getSelection().ImplementationName == "com.sun.star.drawing.SvxShapeCollection": - __dispatcher__(".uno:Delete") - if turtle: - __visible__(turtle, True) - if select: - _.doc.CurrentController.select(_.drawpage) - -def __dispatcher__(s, properties = ()): - ctx = XSCRIPTCONTEXT.getComponentContext() - d = ctx.ServiceManager.createInstanceWithContext("com.sun.star.frame.DispatchHelper", ctx) - d.executeDispatch(_.doc.CurrentController.Frame, s, "", 0, properties) - -def __getshape__(shapename): - try: - if _.shapecache[shapename].Parent: - return _.shapecache[shapename] - _.shapecache.pop(shapename) - except: - pass - return None - -def __angle__(deg): - if deg == u'any': - return random.random() * 36000 - return deg * 100 - -def turnleft(deg): - rotate(__TURTLE__, __angle__(deg)) - -def turnright(deg): - rotate(__TURTLE__, -__angle__(deg)) - -def heading(deg = -1, go = False): - turtle = __getshape__(__TURTLE__) - if deg == -1: - return turtle.RotateAngle / 100 - else: - if deg == u'any': - turtle.RotateAngle = random.random() * 36000 - elif type(deg) == list: - pos = turtle.getPosition() - px, py = pos.X + turtle.BoundRect.Width / 2.0, pos.Y + turtle.BoundRect.Height / 2.0 - dx = px * __MM10_TO_TWIP__ - deg[0] * __PT_TO_TWIP__ - dy = deg[1] * __PT_TO_TWIP__ - py * __MM10_TO_TWIP__ - n = sqrt(dx**2 + dy**2) - if dy > 0 and n > 0: - turtle.RotateAngle = a = -(180 + asin(dx / n) / (pi/180)) * 100 + 72000 # +720 for max(angle, preciseAngle) of __go__() - elif n > 0: - turtle.RotateAngle = a = asin(dx / n) / (pi/180) * 100 + 72000 - if go and n > 0: - __go__(__TURTLE__, -n, False, a) - else: - turtle.RotateAngle = deg * 100 - -def rotate(shapename, deg): - shape = __getshape__(shapename) - if shape: - shape.RotateAngle = shape.RotateAngle + deg - -def forward(n): - if type(n) == list: - pos = position() - position([pos[0] + n[0], pos[1] + n[1]]) - else: - __go__(__TURTLE__, -n * __PT_TO_TWIP__) - -def backward(n): - if type(n) == list: - forward([-n[0], -n[1]]) - turnright(180) - else: - __go__(__TURTLE__, n * __PT_TO_TWIP__) - -def __dots__(n, pos, dx, dy, r = 0): # dots for dotted polyline or circle - k = abs(int(1.0 * n / max(10, _.pensize) / 2.0)) - dots = [] - px, py = pos.X, pos.Y - for i in range(k + 1): - if k > 0: - if r: - px, py = pos.X + sin(360.0/k * i * pi/180.0) * r, pos.Y + cos(360.0/k * i * pi/180) * r - else: - px, py = pos.X + round(i * dx/k), pos.Y + round(i * dy/k) - dots += [(__Point__(px, py),__Point__(px + 10, py + 10))] - return dots - -def __draw__(d): - shape = _.doc.createInstance( "com.sun.star.drawing." + d) - shape.AnchorType = __AT_PAGE__ - shape.TextWrap = __THROUGHT__ - __visible__(shape, False) - while __zoom__(): # temporary fix program halt with continuous zoom - while __zoom__(): - __time__.sleep(0.2) - __time__.sleep(0.2) - _.drawpage.add(shape) - if __group__: - __group__.add(shape) - return shape - -def __zoom__(): - z = _.doc.CurrentController.getViewSettings().ZoomValue - if z <> _.zoomvalue: - _.zoomvalue = z - return True - return False - -def __lefthang__(shape): - global __grouplefthang__ - if __group__: - p = shape.getPosition() - if p.X < __grouplefthang__: - __grouplefthang__ = p.X - -def __go__(shapename, n, dot = False, preciseAngle = -1): - turtle = __getshape__(shapename) - turtlepos = None - if shapename == __TURTLE__: - try: - turtlepos = turtle.PolyPolygon[-1][-1] - except: - pass - pos = turtle.getPosition() - dx = n * sin((pi/180)*(max(turtle.RotateAngle, preciseAngle)/100)) - dy = n * cos((pi/180)*(max(turtle.RotateAngle, preciseAngle)/100)) - turtle.setPosition(__Point__(pos.X + dx / __MM10_TO_TWIP__, pos.Y + dy / __MM10_TO_TWIP__)) - if (_.pencolor <> _.oldlc or _.pensize <> _.oldlw or _.linestyle <> _.oldls or _.linejoint <> _.oldlj): - __removeshape__(__ACTUAL__) - shape = None - else: - shape = __getshape__(__ACTUAL__) - _.oldlw = _.pensize - _.oldlc = _.pencolor - _.oldls = _.linestyle - _.oldlj = _.linejoint - if shape and not _.pen and not dot: - _.continuous = False - return - c, c2 = __Point__(pos.X + turtle.BoundRect.Width / 2.0, pos.Y + turtle.BoundRect.Height / 2.0), __Point__(round(dx), round(dy)) - if shape and "LineShape" in shape.ShapeType: - if _.continuous or dot: - last = shape.PolyPolygon[-1][-1] - if not (turtlepos and (abs(last.X - turtlepos.X) > 100 or abs(last.Y - turtlepos.Y) > 100) and - (not __group__ or (shape.getPosition().X > 0 and turtle.getPosition().X > 0))): # picture [ ] keeps hanging shapes - if dot or _.linestyle == __LineStyle_DOTTED__: - shape.PolyPolygon = tuple( list(shape.PolyPolygon) + __dots__(n, turtlepos, dx, dy)) - else: - last.X = last.X + c2.X - last.Y = last.Y + c2.Y - shape.PolyPolygon = tuple( list(shape.PolyPolygon[:-1]) + [tuple( list(shape.PolyPolygon[-1]) + [last])]) - __lefthang__(shape) - return - elif turtlepos: - shape.PolyPolygon = tuple( list(shape.PolyPolygon) + [(turtlepos, __Point__(turtlepos.X + c2.X, turtlepos.Y + c2.Y))]) - _.continuous = True - __lefthang__(shape) - return - if not _.pen and not dot: - return - shape = __draw__("PolyLineShape") - shape.RotateAngle = 0 - shape.PolyPolygon = tuple([tuple([__Point__(0, 0)])]) - shape.setPosition(c) - last = shape.PolyPolygon[-1][-1] - last2 = __Point__(last.X + c2.X, last.Y + c2.Y) - shape.LineStyle, shape.LineDash = __linestyle__(_.linestyle) - shape.LineJoint = _.linejoint - if dot or _.linestyle == __LineStyle_DOTTED__: - shape.PolyPolygon = tuple( list(shape.PolyPolygon) + __dots__(n, last, c2.X, c2.Y)) - shape.LineStart = __bezierdot__ - shape.LineStartCenter = True - shape.LineStartWidth = _.pensize / __MM10_TO_TWIP__ - shape.LineWidth = 0 - else: - shape.PolyPolygon = tuple([tuple( list(shape.PolyPolygon[-1]) + [last2])]) - shape.LineWidth = _.pensize / __MM10_TO_TWIP__ - shape.LineColor, shape.LineTransparence = __splitcolor__(_.pencolor) - __visible__(shape, True) - shape.Name = __ACTUAL__ - _.shapecache[__ACTUAL__] = shape - _.oldlw = _.pensize - _.oldlc = _.pencolor - _.oldls = _.linestyle - _.oldlj = _.linejoint - _.continuous = True - __lefthang__(shape) - -def __fillit__(filled = True): - oldshape = __getshape__(__ACTUAL__) - if oldshape.LineStartCenter: - __removeshape__(__ACTUAL__) # FIXME close dotted polyline - return - if oldshape and "LineShape" in oldshape.ShapeType: - shape = __draw__("PolyPolygonShape") - shape.PolyPolygon = oldshape.PolyPolygon - shape.setPosition(oldshape.getPosition()) - shape.LineStyle, shape.LineDash = __linestyle__(_.linestyle) - shape.LineJoint = _.linejoint - if _.hatch: - shape.FillBackground = True - shape.FillHatch = _.hatch - shape.FillStyle = 3 - else: - shape.FillStyle = int(filled) - shape.LineWidth = _.pensize / __MM10_TO_TWIP__ - shape.LineColor, shape.LineTransparence = __splitcolor__(_.pencolor) - shape.FillColor, shape.FillTransparence = __splitcolor__(_.areacolor) - shape.setString(oldshape.getString()) - oldshape.Name = "" - shape.Name = __ACTUAL__ - _.shapecache[__ACTUAL__] = shape - if __group__: - __group__.remove(oldshape) - __visible__(shape, True) - _.drawpage.remove(oldshape) - elif oldshape and "PolyPolygon" in oldshape.ShapeType: - oldshape.LineStyle = int(_.pen) - oldshape.LineJoint = _.linejoint - if _.hatch: - oldshape.FillBackground = True - oldshape.FillHatch = _.hatch - oldshape.FillStyle = 3 - else: - oldshape.FillStyle = int(filled) - oldshape.LineWidth = _.pensize / __MM10_TO_TWIP__ - oldshape.LineColor, oldshape.LineTransparence = __splitcolor__(_.pencolor) - oldshape.FillColor, oldshape.FillTransparence = __splitcolor__(_.areacolor) - -def point(): - oldpen, _.pen = _.pen, 1 - oldstyle, _.linestyle = _.linestyle, __LineStyle_DOTTED__ - __go__(__TURTLE__, 0, True) - _.pen, _.linestyle = oldpen, oldstyle - -def __boxshape__(shapetype, l): - if type(l) <> type([]): # default for circle and square - l = [l, l] - turtle = __getshape__(__TURTLE__) - shape = __draw__(shapetype + "Shape") - if _.hatch: - shape.FillBackground = True - shape.FillHatch = _.hatch - shape.FillStyle = 3 - else: - shape.FillStyle = 1 - pos = turtle.getPosition() - pos.X = pos.X - (l[0] * __PT_TO_TWIP__ / __MM10_TO_TWIP__ / 2) + turtle.BoundRect.Width / 2.0 - pos.Y = pos.Y - (l[1] * __PT_TO_TWIP__ / __MM10_TO_TWIP__ / 2) + turtle.BoundRect.Height / 2.0 - shape.setPosition(pos) - shape.setSize(__Size__(l[0] * __PT_TO_TWIP__ / __MM10_TO_TWIP__, l[1] * __PT_TO_TWIP__ / __MM10_TO_TWIP__)) - shape.LineStyle, shape.LineDash = __linestyle__(_.linestyle) - shape.LineWidth = _.pensize / __MM10_TO_TWIP__ - shape.LineJoint = _.linejoint - shape.LineColor, shape.LineTransparence = __splitcolor__(_.pencolor) - shape.FillColor, shape.FillTransparence = __splitcolor__(_.areacolor) - shape.RotateAngle = turtle.RotateAngle - if shapetype == "Rectangle" and len(l) > 2: - shape.CornerRadius = l[2] * __PT_TO_TWIP__ - elif shapetype == "Ellipse" and len(l) > 2: - try: - shape.CircleKind = __SECTION__ - shape.CircleStartAngle = (-l[3] - 270) * 100 - shape.CircleEndAngle = (-l[2] - 270) * 100 - shape.CircleKind = [__FULL__, __SECTION__, __CUT__, __ARC__][l[4]] - except: - pass - __visible__(shape, True) - __removeshape__(__ACTUAL__) - _.shapecache[__ACTUAL__] = shape - __lefthang__(shape) - -def ellipse(l): - if _.linestyle == __LineStyle_DOTTED__: - __removeshape__(__ACTUAL__) - point() - shape = __getshape__(__ACTUAL__) - shape.PolyPolygon = tuple(__dots__(l * pi * __PT_TO_TWIP__, shape.PolyPolygon[0][0], 0, 0, l/2 * __PT_TO_TWIP__)) - else: - __boxshape__("Ellipse", l) - -def rectangle(l): - if _.linestyle == __LineStyle_DOTTED__: - __removeshape__(__ACTUAL__) - point() - shape = __getshape__(__ACTUAL__) - shape.PolyPolygon = tuple(__dots__(l * pi * __PT_TO_TWIP__, shape.PolyPolygon[0][0], 0, 0, l/2 * __PT_TO_TWIP__)) - else: - __boxshape__("Rectangle", l) - -def label(st): - turtle = __getshape__(__TURTLE__) - shape = __draw__("TextShape") - shape.RotateAngle = turtle.RotateAngle - pos = turtle.getPosition() - pos.X = pos.X + turtle.BoundRect.Width / 2.0 - pos.Y = pos.Y + turtle.BoundRect.Height / 2.0 - shape.setSize(__Size__(1, 1)) - shape.TextAutoGrowWidth = True - text(shape, st) - shape.setPosition(__Point__(pos.X - shape.BoundRect.Width/2, pos.Y - shape.BoundRect.Height/2)) - __visible__(shape, True) - __lefthang__(shape) - -def text(shape, st): - if shape: - shape.setString(__string__(st, _.decimal)) - c = shape.createTextCursor() - c.gotoStart(False) - c.gotoEnd(True) - c.CharColor, none = __splitcolor__(_.textcolor) - c.CharHeight = _.fontheight - c.CharWeight = __fontweight__(_.fontweight) - c.CharPosture = __fontstyle__(_.fontstyle) - c.CharFontName = _.fontfamily - -def sleep(t): - for i in range(t/__SLEEP_SLICE_IN_MILLISECONDS__): - __checkhalt__() - __time__.sleep(0.5) - __checkhalt__() - __time__.sleep(t%__SLEEP_SLICE_IN_MILLISECONDS__/1000.0) - -def __removeshape__(shapename): - try: - _.shapecache.pop(shapename).Name = "" - except: - pass - -def __fontweight__(w): - if type(w) == int: - return w - elif re.match(__l12n__(_.lng)['BOLD'], w, flags = re.I): - return 150 - elif re.match(__l12n__(_.lng)['NORMAL'], w, flags = re.I): - return 100 - return 100 - -def __fontstyle__(w): - if type(w) == int: - return w - elif re.match(__l12n__(_.lng)['ITALIC'], w, flags = re.I): - return __Slant_ITALIC__ - elif re.match(__l12n__(_.lng)['UPRIGHT'], w, flags = re.I): - return __Slant_NONE__ - return __Slant_NONE__ - -def __color__(c): - if type(c) in [int, float, long]: - return c - if type(c) == unicode: - if c == u'any': -# return __COLORS__[int(random.random() * 24)][1] - return int(random.random() * 2**31) # max. 50% transparency - if c[0:1] == '~': - c = __componentcolor__(__colors__[_.lng][c[1:].lower()]) - for i in range(3): - c[i] = max(min(c[i] + int(random.random() * 64) - 32, 255), 0) - return __color__(c) - return __colors__[_.lng][c.lower()] - if type(c) == list: - if len(c) == 1: - return __COLORS__[int(c[0])][1] - if len(c) == 3: - return (int(c[0])%256 << 16) + (int(c[1])%256 << 8) + int(c[2])%256 - return (int(c[3])%256 << 24) + (int(c[0])%256 << 16) + (int(c[1])%256 << 8) + int(c[2])%256 - -def __linestyle__(s): - if _.pen == 0: - return 0, __LineDash__() - if _.linestyle == __LineStyle_DASHED__: - return _.linestyle, __LineDash__(__DashStyle_RECT__, 0, 0, 1, 100, 100) - elif _.linestyle == __LineStyle_DOTTED__: - return __LineStyle_DASHED__, __LineDash__(__DashStyle_RECT__, 1, 1, 0, 0, 100000) - elif type(s) == list: - return __LineStyle_DASHED__, __LineDash__((s[5:6] or [0])[0], s[0], s[1] * __PT_TO_TWIP__, s[2], s[3] * __PT_TO_TWIP__, s[4] * __PT_TO_TWIP__) - return s, __LineDash__() - -def fillstyle(s): - if type(s) == list: - color, null = __splitcolor__(__color__(s[1])) - _.hatch = __Hatch__(s[0] - 1, color, s[2] * __PT_TO_TWIP__, s[3] * 10) - elif s == 0: - _.hatch = None - elif s <= 10: # using hatching styles of Writer - fillstyle([[1, 0, 5, 0], [1, 0, 5, 45], [1, 0, 5, -45], [1, 0, 5, 90], [2, [127, 0, 0], 5, 45], [2, [127, 0, 0], 5, 0], [2, [0, 0, 127], 5, 45], [2, [0, 0, 127], 5, 0], [3, [0, 0, 127], 5, 0], [1, 0, 25, 45]][s-1]) - -def __splitcolor__(c): - """Split color constants to RGB (3-byte) + transparency (%)""" - return int(c) & 0xffffff, (int(c) >> 24) / (255.0/100) - -def __componentcolor__(c): - a = [ (c & 0xff0000) >> 16, (c & 0xff00) >> 8, c & 0xff ] - if c > 2**24: - a.append((c & 0xff000000) >> 24) - return a - -def pencolor(n = -1): - if n != -1: - _.pencolor = __color__(n) - turtle = __getshape__(__TURTLE__) - if turtle and __visible__(turtle): - turtle.LineColor, turtle.LineTransparence = __splitcolor__(_.pencolor) - else: - return __componentcolor__(_.pencolor) - -def pensize(n = -1): - if n != -1: - if n == 'any': - _.pensize = random.random() * 10 * __PT_TO_TWIP__ - else: - _.pensize = n * __PT_TO_TWIP__ - turtle = __getshape__(__TURTLE__) - if turtle and __visible__(turtle): - turtle.LineWidth = min(_.pensize, (1 + _.pen * 2) * __PT_TO_TWIP__) - return _.pensize / __PT_TO_TWIP__ - -def penstyle(n = -1): - if n == -1: - try: - return __locname__(_.linestyle.value) - except: - return __locname__('DOTTED') - if type(n) == list and len(n) >= 5: - _.linestyle = n - elif re.match(__l12n__(_.lng)['SOLID'], n, flags = re.I): - _.linestyle = __LineStyle_SOLID__ - elif re.match(__l12n__(_.lng)['DASH'], n, flags = re.I): - _.linestyle = __LineStyle_DASHED__ - elif re.match(__l12n__(_.lng)['DOTTED'], n, flags = re.I): - _.linestyle = __LineStyle_DOTTED__ - -def penjoint(n = -1): - if n == -1: - return __locname__(_.linejoint.value) - if re.match(__l12n__(_.lng)['NONE'], n, flags = re.I): - _.linejoint = __Joint_NONE__ - elif re.match(__l12n__(_.lng)['BEVEL'], n, flags = re.I): - _.linejoint = __BEVEL__ - elif re.match(__l12n__(_.lng)['MITER'], n, flags = re.I): - _.linejoint = __MITER__ - elif re.match(__l12n__(_.lng)['ROUNDED'], n, flags = re.I): - _.linejoint = __ROUNDED__ - -def fillcolor(n = -1): - if n != -1: - _.areacolor = __color__(n) - turtle = __getshape__(__TURTLE__) - if turtle and __visible__(turtle): - turtle.FillColor, transparence = __splitcolor__(_.areacolor) - turtle.FillTransparence = min(95, transparence) - else: - return __componentcolor__(_.areacolor) - -def fontcolor(n = -1): - if n != -1: - _.textcolor = __color__(n) - else: - return __componentcolor__(_.textcolor) - -def position(n = -1): - turtle = __getshape__(__TURTLE__) - if turtle: - if n != -1: - if n == 'any': - ps = pagesize() - heading([random.random() * ps[0], random.random() * ps[1]], True) - else: - heading(n, True) - else: - pos = turtle.getPosition() - 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__(): - global __group__, __grouplefthang__, __groupstack__ - __removeshape__(__ACTUAL__) - __groupstack__.append(__group__) - __groupstack__.append(__grouplefthang__) - __group__ = uno.getComponentContext().ServiceManager.createInstance('com.sun.star.drawing.ShapeCollection') - __grouplefthang__ = 0 - -def __groupend__(): - global __group__, __grouplefthang__, __groupstack__ - g = 0 - if __group__.getCount() > 1: - if __grouplefthang__ < 0: - for i in range(__group__.Count): - s = __group__.getByIndex(i) - p = s.getPosition() - p.X = p.X + -__grouplefthang__ - s.setPosition(p) - g = _.drawpage.group(__group__) - p = g.getPosition() - p.X = p.X + __grouplefthang__ - g.setPosition(p) - else: - g = _.drawpage.group(__group__) - g.TextWrap = __THROUGHT__ - elif __group__.getCount() == 1: - g = __group__.getByIndex(0) - __grouplefthang__ = min(__groupstack__.pop(), __grouplefthang__) - __group__ = __groupstack__.pop() - if __group__ and g: - __group__.add(g) - __removeshape__(__ACTUAL__) - -def __int__(x): # handle eg. int("10cm") - if type(x) == str or type(x) == unicode: - x = __float__(x) - return int(x) - -def __float__(x): # handle eg. float("10,5cm") - if type(x) == str or type(x) == unicode: - for i in __comp__[_.lng]: - x = re.sub(u"(?iu)" + i[0], i[1], x) - x = eval(x) - return float(x) - -def __loadlang__(lang, a): - global comp, __colors__ - __colors__[lang] = {} - for i in __COLORS__: - for j in a[i[0]].split("|"): - __colors__[lang][j] = i[1] - - repcount = a['REPCOUNT'].split('|')[0] - loopi = itertools.count() - loop = lambda r: "%(i)s = 1\n%(orig)s%(j)s = %(i)s\n%(i)s += 1\n" % \ - { "i": repcount + str(loopi.next()), "j": repcount, "orig": re.sub( ur"(?ui)(?])=(?!=)", "==", r.group(0))], # = -> ==, XXX x = y = 1? - [ur"(?<=\n)(for\b :?\w+) ([^\n]+)(?<=\w|]|}|\))(?=-|:)(?:%s)\b" % a['IN'], "\\1 in \\2"], # "for x y-in" -> "for x in y" - [ur"(:?\b\w+|[[][^[\n]*])\b(?:%s)\b" % a['IN'], "in \\1"], # "x y-in" -> "x in y" - [ur"(? /1.0, but not with // - [ur"\b([0-9]+([,.][0-9]+)?)(%s)\b" % a['HOUR'], "\\1*30"], # 12h = 12*30° - [ur"(?<=\d)(%s)" % a['DEG'], ""], # 1° -> 1 - [ur"(? (1 + sqrt(x)) - [ur"(?<=[-*/=+,]) ?\n\)(\w+)\(", "\\1()"], # read attributes, eg. x = fillcolor - [ur"(?<=return) ?\n\)(\w+)\(", "\\1()"], # return + user function - [ur"(?<=(?:Print|label)\() ?\n\)(\w+)\(", "\\1()\n"] # Print/label + user function - ] - -def __concatenation__(r): # keep line positions with extra line breaks - s = re.subn("~[ \t]*\n", " ", r.group(0)) - return s[0] + "\n" * s[1] - -def __compil__(s): - global _, comp, __strings__, __compiled__ - try: - loc = _.doc.CurrentController.getViewCursor().CharLocale - try: - _.lng = loc.Language + '_' + loc.Country - __loadlang__(_.lng, __l12n__(_.lng)) - except: - __trace__() - _.lng = loc.Language - __loadlang__(_.lng, __l12n__(_.lng)) - except: - __trace__() - _.lng = 'en' - if not _.lng in __comp__: - __loadlang__(_.lng, __l12n__(_.lng)) - - _.decimal = __l12n__(_.lng)['DECIMAL'] - names = {} - - rmsp = re.compile(r"[ ]*([=+*/]|==|<=|>=|<>|!=|-[ ]+)[ ]*") - chsp = re.compile(r"[ \t]+") - chch = re.compile(r"(?u)(? 0: - globs = "global %s" % ", ".join(subnames) - # search user functions (function calls with two or more arguments need explicite Python parentheses) - functions += [ re.findall("(?u)\w+",i[0])[0] for i in re.findall(ur"""(?iu)(?<=__def__ )([^\n]*)\n # beginning of a procedure - (?:[^\n]*(? 0: - s = re.sub(ur"(?]|//|==|<=|>=|<>|!=)[ ]*|[ ]*-[ ]+|-|[ ]*[*][*][ ]*) # operators, eg. "**", " - ", "-", "- " - \[*([-+]|\([ ]?)* # minus sign, parenthesis - ((%(functions)s)\b[ ]*\(*)*([0-9]+([.,][0-9]+)?|:?\w+(?:[.]\w+[\(]?[\)]?)?)]* - ([ ]?\))*)* - [\)]*){,%(repeat)s} - ) -""" - chargsp = re.compile(r"(? - - - - - - - - \ No newline at end of file diff --git a/librelogo/Makefile b/librelogo/Makefile new file mode 100644 index 000000000000..ccb1c85a04da --- /dev/null +++ b/librelogo/Makefile @@ -0,0 +1,7 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- + +module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST)))) + +include $(module_directory)/../solenv/gbuild/partial_build.mk + +# vim: set noet sw=4 ts=4: diff --git a/librelogo/Module_librelogo.mk b/librelogo/Module_librelogo.mk new file mode 100644 index 000000000000..cd0245d77d8d --- /dev/null +++ b/librelogo/Module_librelogo.mk @@ -0,0 +1,17 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Module_Module,librelogo)) + +$(eval $(call gb_Module_add_targets,librelogo,\ + Configuration_librelogo \ + Extension_librelogo \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/librelogo/Office/UI/StartModuleWindowState.xcu b/librelogo/Office/UI/StartModuleWindowState.xcu deleted file mode 100644 index c772f2aa1594..000000000000 --- a/librelogo/Office/UI/StartModuleWindowState.xcu +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - Logo - Logo - - - false - - - false - - - - - diff --git a/librelogo/Office/UI/WriterWindowState.xcu b/librelogo/Office/UI/WriterWindowState.xcu deleted file mode 100644 index b10980cd3262..000000000000 --- a/librelogo/Office/UI/WriterWindowState.xcu +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - Logo - Logo - - - false - - - false - - - - - diff --git a/librelogo/README b/librelogo/README index cc32af2e3fa5..af75698f5f2d 100644 --- a/librelogo/README +++ b/librelogo/README @@ -1,43 +1 @@ -LibreOffice Logo 0.2 RC2 - -License: GNU LGPL & GPL, MPL - -Home page: http://www.numbertext.org/logo - -(c) László Németh (nemeth at numbertextdotorg) - -FSF.hu Foundation, http://www.fsf.hu - -Icons copyright: OpenOffice.org/LibreOffice - -Introduction -============ - -LibreLogo is a Logo-like progamming language with interactive vectorgraphics for education and DTP - -- presentation: http://www.numbertext.org/logo/librelogo.pdf -- basic Logo syntax for back compability with educational Logo systems -- interactive vectorgraphics in LibreOffice Writer -- native commands (easily translatable) -- Python data structures (list, tuple, set, dictionary) and other Python features - -Usage -===== - -See Logo in LibreOffice Help and http://www.numbertext.org/logo for documentation. - -Translation -=========== - -create your_language_id.lng in LibreOffice/ based on en.lng. - -Compilation: - -python make.py - -Development -=========== - -LibreLogo uses the PyUNO scripting framework, so Addons.xcu URLs depend from the -full name of the package. Modify them according to the package name with the -version number. +LibreLogo is a Logo-like programming language with interactive vectorgraphics for education and DTP diff --git a/librelogo/description-en.txt b/librelogo/description-en.txt deleted file mode 100644 index 6e9566518da8..000000000000 --- a/librelogo/description-en.txt +++ /dev/null @@ -1 +0,0 @@ -Programming language and environment for education, graphic design and desktop publishing. Usage: View→Toolbars→Logo toolbar in Writer. See Logo in LibreOffice Help. diff --git a/librelogo/description-hu.txt b/librelogo/description-hu.txt deleted file mode 100644 index 9d0b626b470a..000000000000 --- a/librelogo/description-hu.txt +++ /dev/null @@ -1 +0,0 @@ -Programozási nyelv és környezet oktatáshoz, számítógépes grafikához és kiadványszerkesztéshez. Használat: Nézet→Eszköztárak→Logo eszköztár a Writerben. L. Logo a LibreOffice Súgóban. diff --git a/librelogo/description.xml b/librelogo/description.xml deleted file mode 100644 index 6ff4a9f1d19c..000000000000 --- a/librelogo/description.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - LibreLogo - - - - László Németh - Németh László - - - - - - - - - diff --git a/librelogo/help/en-US/LibreLogo/LibreLogo.xhp b/librelogo/help/en-US/LibreLogo/LibreLogo.xhp deleted file mode 100644 index e3aa04c08bdf..000000000000 --- a/librelogo/help/en-US/LibreLogo/LibreLogo.xhp +++ /dev/null @@ -1,614 +0,0 @@ - - - - - - - - - -LibreLogo -Logo -Turtle graphics - - -LibreLogo - -LibreLogo is a simple, native, Logo-like programming environment with turtle vector graphics for teaching of computing (programming and word processing), DTP and graphic design. See http://www.numbertext.org/logo/librelogo.pdf. - -LibreLogo toolbar - -The LibreLogo toolbar (View » Toolbars » Logo) contains turtle moving, program run and stop, home and clear screen and syntax highlighting/translating icons and an input bar (command line). - -Turtle moving icons - -They are equivalents of the Logo commands “FORWARD 10”, “BACK 10”, “LEFT 15”, “RIGHT 15”. -Clicking on one of the icons will also focus the turtle shape scrolling the page to its position. - -Program run and start - -Click on the icon “run” to execute the text of the Writer document as a LibreLogo program. -Click on the icon “stop” to stop the program execution. - -Home - -Click on the icon “home” to reset the position and settings of the turtle. - -Clear screen - -Click on the icon “clear screen” to remove the drawing objects of the document. - -Command line - -Hit Enter in the command line to execute its content. To stop the program use the icon “stop”. -Hold down the Enter to repeat the command line, for example, on the following command sequence: - - FORWARD 200 LEFT 89
- -To reset the command line click triple in it or press Ctrl-A to select the previous commands, and type the new commands. - -Syntax highlighting/Translating - -It expands and upper case Logo commands in the Writer document. Change the language of the document (Tools » Options » Language Settings » Languages » Western) and click on this icon to translate the Logo program to the selected language. - -Program editing - -LibreLogo drawings and programs use the same Writer document. The LibreLogo canvas is on the first page of the Writer document. You can insert a page break before the LibreLogo programs and set the zoom/font size for a comfortable two page layout for LibreLogo programming: left (first) page is the canvas, right (second) page is for the LibreLogo programs. - -LibreLogo programming language - -LibreLogo is a native, easily localisable, Logo-like programming language. It is back-compatible with the older Logo systems in the case of the simple Logo programs used in education, eg. - - TO triangle :size
 REPEAT 3 [
   FORWARD :size
   LEFT 120
 ]
 END
 
 triangle 10 triangle 100 triangle 200
- -Differences from the Logo programming language - -List members are comma separated - - POSITION [0, 0]
- -Program blocks and lists - -Program blocks and lists have got different syntax. - -Program blocks need space or new line at parenthesization: - - REPEAT 10 [ forward 10 left 36 ]
- -Lists need close parenthesization: - - POSITION [0, 0]        ; and not POSITION [ 0, 0 ]
- -Function declarations - -LibreLogo has not supported 1-line function declarations, yet. TO and END need new lines. - - TO polygon
   FORWARD 1 RIGHT 1
   polygon      ; recursion
 END
- - polygon
- -Other features of LibreLogo - -Optional colon - -The colon is optional before variable names. - - TO triangle size
   REPEAT 3 [ FORWARD size LEFT 120 ]
 END
- -String notation - -String notation supports also orthographical and Python syntax. - - PRINT "word ; original Logo syntax
 PRINT “Arbitrary text.” ; orthography, Writer
 PRINT 'Arbitrary text.' ; Python syntax
- -Python list and string handling - - PRINT “text”[2] ; print “x”
 PRINT “text”[1:3] ; print “ex”
 PRINT [1, 2, 3, 4][1] ; print 2
 PRINT [1, 2, 3, 4][1:3] ; print [2, 3]
- -Python-like FOR loop - - FOR i IN [1, 2] [
   PRINT i
 ]
- -Python-like variable declaration - - x = 15
 PRINT x
- -There are no extra query functions - - PRINT FILLCOLOR
 p = POSITION
 PRINT p
 REPEAT 10 [ POSITION ANY POSITION p ]
- -Alternative parenthesization in function calls - - TO star size color
 FILLCOLOR color
 REPEAT 5 [ LEFT 72 FORWARD size RIGHT 144 FORWARD size ]
 FILL
 END
 
 star 100 “red”
 star (100, “green”)
 star(100, “blue”)
- -LibreLogo commands - -Basic syntax - -Case sensitivity - -Commands, color constants are case insensitive: - - PRINT “Hello, World!”
 print “Hello, World, again!”
- -Variable names are case sensitive: - - a = 5
 A = 7
 PRINT a
 PRINT A
- -Program lines - -Lines of a LibreLogo program are paragraphs in the LibreOffice Writer document. A program line can contain multiple commands: - - PRINT “Hello, World!” PRINT “LibreLogo”
- -Comments - -Lines or line parts are comments from a semicolon to the end of the line (paragraph): - - ; some comments
 PRINT 5 * 5 ; some comments
- -Break program lines to multiple paragraphs - -It’s possible to break a program line for more paragraphs using the character tilde at the end of the line: - - PRINT “This is a very long ” + ~
       “warning message”
- -Turtle moving - -FORWARD (fd) - - FORWARD 10 ; move forward 10pt (1pt = 1/72 inch)
 FORWARD 10pt ; see above
 FORWARD 0.5in ; move forward 0.5 inch (1 inch = 2.54 cm)
 FORWARD 1" ; see above
 FD 1mm
 FD 1cm
- -BACK (bk) - - BACK 10 ; move back 10pt
- -LEFT (lt) - - LEFT 90 ; turn counterclockwise 90 degrees
 LEFT 90° ; see above
 LT 3h ; see above (clock position)
 LT any ; turn to a random position
- -RIGHT (rt) - - RIGHT 90 ; turn clockwise 90 degrees
- -PENUP (pu) - - PENUP ; turtle will move without drawing
- -PENDOWN (pd) - - PENDOWN ; turtle will move with drawing
- -POSITION (pos) - - POSITION [0, 0] ; turn and move to the top-left corner
 POSITION PAGESIZE ; turn and move to the bottom-right corner
 POSITION [PAGESIZE[0], 0] ; turn and move to the top-right corner
 POSITION ANY ; turn and move to a random position
- -HEADING (seth) - - HEADING 0 ; turn north
 HEADING 12h ; see above
 HEADING ANY ; turn to a random position
- -Other turtle commands - -HIDETURTLE (ht) - - HIDETURTLE ; hide turtle (until the showturtle command)
- -SHOWTURTLE (st) - - SHOWTURTLE ; show turtle
- -HOME - - HOME ; reset initial turtle settings and position
- -CLEARSCREEN (cs) - - CLEARSCREEN ; remove drawing objects of the document
- -FILL and CLOSE - - FILL ; close and fill the actual line shape
 CLOSE ; close the actual line shape
- -Pen settings - -PENSIZE (ps) - - PENSIZE 100 ; line width is 100 points
 PENSIZE ANY ; equivalent of PENSIZE RANDOM 10
- -PENCOLOR/PENCOLOUR (pc) - - PENCOLOR “red” ; set red pen color (by color name, see color constants)
 PENCOLOR [255, 255, 0] ; set yellow color (RGB list)
 PENCOLOR 0xffff00 ; set yellow color (hexa code)
 PENCOLOR 0 ; set black color (0x000000)
 PENCOLOR ANY ; random color
 PENCOLOR [5] ; set red color (by color identifier, see color constants)
 PENCOLOR “invisible” ; invisible pen color for shapes without visible outline
 PENCOLOR “~red” ; set random red color
- -PENJOINT/LINEJOINT - - PENJOINT “rounded” ; rounded line joint (default)
 PENJOINT “miter” ; sharp line joint
 PENJOINT “bevel” ; bevel line joint
 PENJOINT “none” ; without line joint
- -PENSTYLE - - PENSTYLE “solid” ; solid line (default)
 PENSTYLE “dotted” ; dotted line
 PENSTYLE “dashed” ; dashed line
 
 ; custom dot–dash pattern specified by a list with the following arguments:
 ; – number of the neighbouring dots
 ; – length of a dot
 ; – number of the neighbouring dashes
 ; – length of a dash
 ; – distance of the dots/dashes
 ; – type (optional):
 ;   0 = dots are rectangles (default)
 ;   2 = dots are squares (lengths and distances are relative to the pensize)
 
 PENSTYLE [3, 1mm, 2, 4mm, 2mm, 2] ; ...––...––...––
- -Fill settings - -FILLCOLOR/FILLCOLOUR (fc) - - FILLCOLOR “blue” ; fill with blue color, see also PENCOLOR
 FILLCOLOR “invisible” CIRCLE 10 ; unfilled circle
- -FILLSTYLE - - FILLSTYLE 0 ; fill without hatches (default)
 FILLSTYLE 1 ; black single hatches (horizontal)
 FILLSTYLE 2 ; black single hatches (45 degrees)
 FILLSTYLE 3 ; black single hatches (-45 degrees)
 FILLSTYLE 4 ; black single hatches (vertical)
 FILLSTYLE 5 ; red crossed hatches (45 degrees)
 FILLSTYLE 6 ; red crossed hatches (0 degrees)
 FILLSTYLE 7 ; blue crossed hatches (45 degrees)
 FILLSTYLE 8 ; blue crossed hatches (0 degrees)
 FILLSTYLE 9 ; blue triple crossed
 FILLSTYLE 10 ; black wide single hatches (45 degrees)
 
 ; custom hatches specified by a list with the following arguments:
 ; – style (1 = single, 2 = double, 3 = triple hatching)
 ; – color
 ; – distance
 ; – degree
 
 FILLSTYLE [2, “green”, 3pt, 15°] ; green crossed hatches (15 degrees)
- -Drawing objects - -CIRCLE - - CIRCLE 100 ; draw a circle shape (diameter = 100pt)
- -ELLIPSE - - ELLIPSE [50, 100] ; draw an ellipse with 50 and 100 diameters
 ELLIPSE [50, 100, 2h, 12h] ; draw an elliptical sector (from 2h clock position to 12h)
 ELLIPSE [50, 100, 2h, 12h, 2]  ; draw an elliptical segment
 ELLIPSE [50, 100, 2h, 12h, 3]  ; draw an elliptical arc
- -SQUARE - - SQUARE 100 ; draw a square shape (size = 100pt)
- -RECTANGLE - - RECTANGLE [50, 100] ; draw a rectange shape (50×100pt)
 RECTANGLE [50, 100, 50] ; draw a rectangle 
- -POINT - - POINT ; draw a point with size and color of the pen
- -LABEL - - LABEL “text” ; print text in the turte position
 LABEL 'text' ; see above
 LABEL "text ; see above (only for single words)
- -TEXT - - CIRCLE 10 TEXT “text” ; set text of the actual drawing object
- -Font settings - -FONTCOLOR/FONTCOLOUR - - FONTCOLOR “green” ; set font color
- -FONTFAMILY - - FONTFAMILY “Linux Libertine G” ; set font (family)
 FONTFAMILY “Linux Libertine G:smcp=1” ; set also font feature (small caps)
 FONTFAMILY “Linux Libertine G:smcp=1&onum=1” ; small caps + old figures
- -FONTSIZE - - FONTSIZE 12 ; set 12pt
- -FONTWEIGHT - - FONTWEIGHT “bold” ; set bold font
 FONTWEIGHT “normal” ; set normal weight
- -FONTSTYLE - - FONTSTYLE “italic” ; set italic variant
 FONTSTYLE “normal” ; set normal variant
- -PICTURE (pic) - -PICTURE is for -* shape grouping; -* starting new line shapes; -* keeping the consistency of positions and line shapes at the left border. - -Shape grouping - - ; PICTURE [ LibreLogo_commands ]
 PICTURE [ FORWARD 100 CIRCLE 100 ] ; tree-like grouped shape
- -See also “Group” in LibreOffice Writer Help. - - TO tree location
   PENUP POSITION location HEADING 0 PENDOWN
   PICTURE [ FORWARD 100 CIRCLE 100 ] ; tree-like grouped shape
 END
 
 PICTURE [ tree [30, 50] tree [100, 50] ] ; grouped shapes in a grouped shape
- -Starting new line shapes - - PICTURE ; start a new line shape
 FORWARD 10 PICTURE FORWARD 10 ; two line shapes
- -Consistency at the left border - -Use picture to keep the consistency of positions and line shapes at the left border of Writer: - - PICTURE [ CIRCLE 20 POSITION [-100, 100] CIRCLE 20 ]
- -Loops - -REPEAT - - ; REPEAT number [ commands ]
 
 REPEAT 10 [ FORWARD 10 LEFT 45 CIRCLE 10 ] ; repeat 10 times
- - ; number is optional
 
 REPEAT [ POSITION ANY ] ; endless loop
- -REPCOUNT - -Loop variable (also in the FOR and WHILE loops). - - REPEAT 100 [ FORWARD REPCOUNT LEFT 90 ]
- -FOR IN - -Loop for the list elements: - - FOR i IN [1, 5, 7, 9, 11] [
   FORWARD i
   LEFT 90
 ]
- -Loop for the characters of a character sequence: - - FOR i IN “text” [
   LABEL i
   FORWARD 10
 ]
- -WHILE - - WHILE TRUE [ POSITION ANY ] ; endless loop
 WHILE REPCOUNT <= 10 [ FORWARD 50 LEFT 36 ] ; as REPEAT 10 [ ... ]
- -BREAK - -Stop the loop. - - REPEAT [ ; endless loop
   POSITION ANY
   IF REPCOUNT = 100 [ BREAK ]  ; equivalent of the REPEAT 100 [ ... ]
 ]
- -CONTINUE - -Jump into the next iteration of the loop. - - REPEAT 100 [
   POSITION ANY
   IF REPCOUNT % 2 <> 0 [ CONTINUE ]
   CIRCLE 10 ; draw circles on every 2nd positions
 ]
- -Conditions - -IF - - ; IF condition [ true block ]
 ; IF condition [ true block ] [ false block ]
 
 IF a < 10 [ PRINT “Small” ]
 IF a < 10 [ PRINT “Small” ] [ PRINT “Big” ]
- -AND, OR, NOT - -Logical operators. - - IF a < 10 AND NOT a < 5 [ PRINT “5, 6, 7, 8 or 9” ]
- -Subroutines - -TO, END - -New word (or procedure). - - TO triangle
   REPEAT [ FORWARD 100 RIGHT 120 ] FILL
 END
 
 REPEAT 10 [ triangle PENUP POSITION ANY PENDOWN ]
- -OUTPUT - -Return value of the function. - - TO randomletter
   OUTPUT RANDOM “qwertzuiopasdfghjklyxcvbnm”
 END
 
 PRINT randomletter + randomletter + randomletter ; print 3-letter random character sequence
- -STOP - -Return from the procedure. - - TO example number
   IF number < 0 [ STOP ]
   PRINT SQRT number ; print square root
 ]
 
 example 100
 example -1 ; without output and error
 example 25
- -Default variables - -ANY - -Default random value of colors, etc. - - PENCOLOR ANY ; random pen color
- -TRUE - -Logical value. - - WHILE TRUE [ POSITION ANY ] ; endless loop
 PRINT TRUE ; print true
- -FALSE - -Logical value. - - WHILE NOT FALSE [ POSITION ANY ] ; endless loop
 PRINT FALSE ; print false
- -PAGESIZE - - PRINT PAGESIZE ; print list of the page sizes in points, eg. [595.30, 841.89]
- -PI/π - - PRINT PI ; print 3.14159265359
- -Input/Output - -PRINT - - PRINT “text” ; print “text” in a dialog box
 PRINT 5 + 10 ; print 15
- -INPUT - - PRINT INPUT “Input value?” ; ask and print a string by a query dialog box
 PRINT FLOAT (INPUT “First number?”) + FLOAT (INPUT “Second number?”) ; simple calculator
- -SLEEP - - SLEEP 1000 ; wait for 1000 ms (1 sec)
- -GLOBAL - -Set global variables used in procedures. - - GLOBAL about
 about = “LibreLogo”
 
 TO example
   PRINT about
   GLOBAL about ; when we want to add a new value
   about = “new value for the global variable”
 END
 
 example
 PRINT about
- -Functions - -RANDOM - - PRINT RANDOM 100 ; random float number (0 <= x < 100)
 PRINT RANDOM “text” ; random letter of the “text”
 PRINT RANDOM [1, 2] ; random list element (1 or 2)
- -INT - - PRINT INT 3.8 ; print 3 (integer part of 3.8)
 PRINT INT RANDOM 100 ; random integer number (0 <= x < 100)
 PRINT INT “7” ; convert the string parameter to integer
- -FLOAT - - ; convert the string parameter to float number
 PRINT 2 * FLOAT “5.5” ; print 11.0
- -STR - - ; convert the number parameter to string
 PRINT “Result: ” + STR 5 ; print “Result: 5”
 PRINT 10 * STR 5 ; print 5555555555
- -SQRT - - PRINT SQRT 100 ; print 10, square root of 100
- -SIN - - PRINT SIN 90 * PI/180 ; print 1.0 (sinus of 90° in radians)
- -COS - - PRINT COS 0 * PI/180 ; print 1.0 (sinus of 0° in radians)
- -ROUND - - PRINT ROUND 3.8 ; print 4 (rounding 3.8)
 PRINT ROUND RANDOM 100 ; random integer number (0 <= x <= 100)
- -ABS - - PRINT ABS -10 ; print 10, absolute value of -10
- -COUNT - - PRINT COUNT “text” ; print 4, character count of “text”
 PRINT COUNT [1, 2, 3] ; print 3, size of the list
- -SET - - ; Convert list to Python set
 PRINT SET [4, 5, 6, 6] ; print {4, 5, 6}
 PRINT SET [4, 5, 6, 6] | SET [4, 1, 9] ; print {1, 4, 5, 6, 9}, union
 PRINT SET [4, 5, 6, 6] & SET [4, 1, 9] ; print {4}, intersection
 PRINT SET ([4, 5, 6, 6]) - SET [4, 1, 9] ; print {5, 6}, difference
 PRINT SET [4, 5, 6, 6] ^ SET [4, 1, 9] ; print {1, 5, 6, 9}, symmetric difference  
- -RANGE - - ; Python-like list generation
 PRINT RANGE 10 ; print [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
 PRINT RANGE 3 10 ; print [3, 4, 5, 6, 7, 8, 9]
 PRINT RANGE 3 10 3 ; print [3, 6, 9]
 
 FOR i in RANGE 10 50 10 [ ; loop for [10, 20, 30, 40]
   FORWARD i
   LEFT 90
 ]
- -LIST - - ; remove the repeating elements of a list using set and list conversion
 PRINT LIST (SET [1, 3, 5, 5, 2, 1]) ; print [1, 3, 5, 2]
- -TUPLE - -Conversion to Python tuple (non-modifiable list) - - PRINT TUPLE [4, 5]
- -SORTED - -It returns with a sorted list. - - PRINT SORTED [5, 1, 3, 4] ; print [1, 3, 4, 5]
- -SUB - -Substitue character sequences using regex (regular expression) patterns. - - PRINT SUB (“t”, “T”, “text”) ; print “Text”, replacing “t” with “T”
 PRINT SUB (“(.)”, “\\1\\1”, “text”) ; print “tteexxtt”, doubling every characters
- -SEARCH - -Search character sequences patterns using regex patterns. - - IF SEARCH (“\w”, word) [ PRINT “Letter in the word.” ]
- -FINDALL - -Find all character sequences in the input string matching the given regex pattern. - - PRINT FINDALL(“\w+”, “Dogs, cats.”) ; print [“Dogs”, “cats”], the list of the words.
- -MIN - - PRINT MIN [1, 2, 3] ; print 1, the lowest element of the list
- -MAX - - PRINT MAX [1, 2, 3] ; print 3, the greatest element of the list
- -Color constants - - PENCOLOR “SILVER” ; set by name
 PENCOLOR [1] ; set by identifiers
 PENCOLOR “~SILVER” ; random silver color
 
- -Identifier -Name - -0 -BLACK - -1 -SILVER - -2 -GRAY/GREY - -3 -WHITE - -4 -MAROON - -5 -RED - -6 -PURPLE - -7 -FUCHSIA/MAGENTA - -8 -GREEN - -9 -LIME - -10 -OLIVE - -11 -YELLOW - -12 -NAVY - -13 -BLUE - -14 -TEAL - -15 -AQUA - -16 -PINK - -17 -TOMATO - -18 -ORANGE - -19 -GOLD - -20 -VIOLET - -21 -SKYBLUE - -22 -CHOCOLATE - -23 -BROWN - -24 -INVISIBLE -
-
diff --git a/librelogo/help/en-US/LibreLogo/doc.txt b/librelogo/help/en-US/LibreLogo/doc.txt deleted file mode 100644 index db596f926808..000000000000 --- a/librelogo/help/en-US/LibreLogo/doc.txt +++ /dev/null @@ -1,787 +0,0 @@ -= LibreLogo = - -LibreLogo is a simple, native, Logo-like programming environment with turtle vector graphics for teaching of computing (programming and word processing), DTP and graphic design. See http://www.numbertext.org/logo/librelogo.pdf. - -== LibreLogo toolbar == - -The LibreLogo toolbar (View » Toolbars » Logo) contains turtle moving, program run and stop, home and clear screen and syntax highlighting/translating icons and an input bar (command line). - -== Turtle moving icons == - -They are equivalents of the Logo commands “FORWARD 10”, “BACK 10”, “LEFT 15”, “RIGHT 15”. -Clicking on one of the icons will also focus the turtle shape scrolling the page to its position. - -== Program run and start == - -Click on the icon “run” to execute the text of the Writer document as a LibreLogo program. -Click on the icon “stop” to stop the program execution. - -== Home == - -Click on the icon “home” to reset the position and settings of the turtle. - -== Clear screen == - -Click on the icon “clear screen” to remove the drawing objects of the document. - -== Command line == - -Hit Enter in the command line to execute its content. To stop the program use the icon “stop”. -Hold down the Enter to repeat the command line, for example, on the following command sequence: - - FORWARD 200 LEFT 89 - -To reset the command line click triple in it or press Ctrl-A to select the previous commands, and type the new commands. - -== Syntax highlighting/Translating == - -It expands and upper case Logo commands in the Writer document. Change the language of the document (Tools » Options » Language Settings » Languages » Western) and click on this icon to translate the Logo program to the selected language. - -== Program editing == - -LibreLogo drawings and programs use the same Writer document. The LibreLogo canvas is on the first page of the Writer document. You can insert a page break before the LibreLogo programs and set the zoom/font size for a comfortable two page layout for LibreLogo programming: left (first) page is the canvas, right (second) page is for the LibreLogo programs. - -= LibreLogo programming language = - -LibreLogo is a native, easily localisable, Logo-like programming language. It is back-compatible with the older Logo systems in the case of the simple Logo programs used in education, eg. - - TO triangle :size - REPEAT 3 [ - FORWARD :size - LEFT 120 - ] - END - - triangle 10 triangle 100 triangle 200 - -== Differences from the Logo programming language == - -=== List members are comma separated === - - POSITION [0, 0] - -=== Program blocks and lists === - -Program blocks and lists have got different syntax. - -Program blocks need space or new line at parenthesization: - - REPEAT 10 [ forward 10 left 36 ] - -Lists need close parenthesization: - - POSITION [0, 0] ; and not POSITION [ 0, 0 ] - -=== Function declarations === - -LibreLogo has not supported 1-line function declarations, yet. TO and END need new lines. - - TO polygon - FORWARD 1 RIGHT 1 - polygon ; recursion - END - - polygon - -== Other features of LibreLogo == - -=== Optional colon === - -The colon is optional before variable names. - - TO triangle size - REPEAT 3 [ FORWARD size LEFT 120 ] - END - -=== String notation === - -String notation supports also orthographical and Python syntax. - - PRINT "word ; original Logo syntax - PRINT “Arbitrary text.” ; orthography, Writer - PRINT 'Arbitrary text.' ; Python syntax - -=== Python list and string handling === - - PRINT “text”[2] ; print “x” - PRINT “text”[1:3] ; print “ex” - PRINT [1, 2, 3, 4][1] ; print 2 - PRINT [1, 2, 3, 4][1:3] ; print [2, 3] - -=== Python-like FOR loop === - - FOR i IN [1, 2] [ - PRINT i - ] - -=== Python-like variable declaration === - - x = 15 - PRINT x - -=== There are no extra query functions === - - PRINT FILLCOLOR - p = POSITION - PRINT p - REPEAT 10 [ POSITION ANY POSITION p ] - -=== Alternative parenthesization in function calls === - - TO star size color - FILLCOLOR color - REPEAT 5 [ LEFT 72 FORWARD size RIGHT 144 FORWARD size ] - FILL - END - - star 100 “red” - star (100, “green”) - star(100, “blue”) - -= LibreLogo commands = - -== Basic syntax == - -=== Case sensitivity === - -Commands, color constants are case insensitive: - - PRINT “Hello, World!” - print “Hello, World, again!” - -Variable names are case sensitive: - - a = 5 - A = 7 - PRINT a - PRINT A - -=== Program lines === - -Lines of a LibreLogo program are paragraphs in the LibreOffice Writer document. A program line can contain multiple commands: - - PRINT “Hello, World!” PRINT “LibreLogo” - -=== Comments === - -Lines or line parts are comments from a semicolon to the end of the line (paragraph): - - ; some comments - PRINT 5 * 5 ; some comments - -=== Break program lines to multiple paragraphs === - -It’s possible to break a program line for more paragraphs using the character tilde at the end of the line: - - PRINT “This is a very long ” + ~ - “warning message” - -== Turtle moving == - -=== FORWARD (fd) === - - FORWARD 10 ; move forward 10pt (1pt = 1/72 inch) - FORWARD 10pt ; see above - FORWARD 0.5in ; move forward 0.5 inch (1 inch = 2.54 cm) - FORWARD 1" ; see above - FD 1mm - FD 1cm - -=== BACK (bk) === - - BACK 10 ; move back 10pt - -=== LEFT (lt) === - - LEFT 90 ; turn counterclockwise 90 degrees - LEFT 90° ; see above - LT 3h ; see above (clock position) - LT any ; turn to a random position - -=== RIGHT (rt) === - - RIGHT 90 ; turn clockwise 90 degrees - -=== PENUP (pu) === - - PENUP ; turtle will move without drawing - -=== PENDOWN (pd) === - - PENDOWN ; turtle will move with drawing - -=== POSITION (pos) === - - POSITION [0, 0] ; turn and move to the top-left corner - POSITION PAGESIZE ; turn and move to the bottom-right corner - POSITION [PAGESIZE[0], 0] ; turn and move to the top-right corner - POSITION ANY ; turn and move to a random position - -=== HEADING (seth) === - - HEADING 0 ; turn north - HEADING 12h ; see above - HEADING ANY ; turn to a random position - -== Other turtle commands == - -=== HIDETURTLE (ht) === - - HIDETURTLE ; hide turtle (until the showturtle command) - -=== SHOWTURTLE (st) === - - SHOWTURTLE ; show turtle - -=== HOME === - - HOME ; reset initial turtle settings and position - -=== CLEARSCREEN (cs) === - - CLEARSCREEN ; remove drawing objects of the document - -=== FILL and CLOSE === - - FILL ; close and fill the actual line shape - CLOSE ; close the actual line shape - -== Pen settings == - -=== PENSIZE (ps) === - - PENSIZE 100 ; line width is 100 points - PENSIZE ANY ; equivalent of PENSIZE RANDOM 10 - -=== PENCOLOR/PENCOLOUR (pc) === - - PENCOLOR “red” ; set red pen color (by color name, see color constants) - PENCOLOR [255, 255, 0] ; set yellow color (RGB list) - PENCOLOR 0xffff00 ; set yellow color (hexa code) - PENCOLOR 0 ; set black color (0x000000) - PENCOLOR ANY ; random color - PENCOLOR [5] ; set red color (by color identifier, see color constants) - PENCOLOR “invisible” ; invisible pen color for shapes without visible outline - PENCOLOR “~red” ; set random red color - -=== PENJOINT/LINEJOINT === - - PENJOINT “rounded” ; rounded line joint (default) - PENJOINT “miter” ; sharp line joint - PENJOINT “bevel” ; bevel line joint - PENJOINT “none” ; without line joint - -=== PENSTYLE === - - PENSTYLE “solid” ; solid line (default) - PENSTYLE “dotted” ; dotted line - PENSTYLE “dashed” ; dashed line - - ; custom dot–dash pattern specified by a list with the following arguments: - ; – number of the neighbouring dots - ; – length of a dot - ; – number of the neighbouring dashes - ; – length of a dash - ; – distance of the dots/dashes - ; – type (optional): - ; 0 = dots are rectangles (default) - ; 2 = dots are squares (lengths and distances are relative to the pensize) - - PENSTYLE [3, 1mm, 2, 4mm, 2mm, 2] ; ...––...––...–– - -== Fill settings == - -=== FILLCOLOR/FILLCOLOUR (fc) === - - FILLCOLOR “blue” ; fill with blue color, see also PENCOLOR - FILLCOLOR “invisible” CIRCLE 10 ; unfilled circle - -=== FILLSTYLE === - - FILLSTYLE 0 ; fill without hatches (default) - FILLSTYLE 1 ; black single hatches (horizontal) - FILLSTYLE 2 ; black single hatches (45 degrees) - FILLSTYLE 3 ; black single hatches (-45 degrees) - FILLSTYLE 4 ; black single hatches (vertical) - FILLSTYLE 5 ; red crossed hatches (45 degrees) - FILLSTYLE 6 ; red crossed hatches (0 degrees) - FILLSTYLE 7 ; blue crossed hatches (45 degrees) - FILLSTYLE 8 ; blue crossed hatches (0 degrees) - FILLSTYLE 9 ; blue triple crossed - FILLSTYLE 10 ; black wide single hatches (45 degrees) - - ; custom hatches specified by a list with the following arguments: - ; – style (1 = single, 2 = double, 3 = triple hatching) - ; – color - ; – distance - ; – degree - - FILLSTYLE [2, “green”, 3pt, 15°] ; green crossed hatches (15 degrees) - -== Drawing objects == - -=== CIRCLE === - - CIRCLE 100 ; draw a circle shape (diameter = 100pt) - -=== ELLIPSE === - - ELLIPSE [50, 100] ; draw an ellipse with 50 and 100 diameters - ELLIPSE [50, 100, 2h, 12h] ; draw an elliptical sector (from 2h clock position to 12h) - ELLIPSE [50, 100, 2h, 12h, 2] ; draw an elliptical segment - ELLIPSE [50, 100, 2h, 12h, 3] ; draw an elliptical arc - -=== SQUARE === - - SQUARE 100 ; draw a square shape (size = 100pt) - -=== RECTANGLE === - - RECTANGLE [50, 100] ; draw a rectange shape (50×100pt) - RECTANGLE [50, 100, 50] ; draw a rectangle - -=== POINT === - - POINT ; draw a point with size and color of the pen - -=== LABEL === - - LABEL “text” ; print text in the turte position - LABEL 'text' ; see above - LABEL "text ; see above (only for single words) - -=== TEXT === - - CIRCLE 10 TEXT “text” ; set text of the actual drawing object - -== Font settings == - -=== FONTCOLOR/FONTCOLOUR === - - FONTCOLOR “green” ; set font color - -=== FONTFAMILY === - - FONTFAMILY “Linux Libertine G” ; set font (family) - FONTFAMILY “Linux Libertine G:smcp=1” ; set also font feature (small caps) - FONTFAMILY “Linux Libertine G:smcp=1&onum=1” ; small caps + old figures - -=== FONTSIZE === - - FONTSIZE 12 ; set 12pt - -=== FONTWEIGHT === - - FONTWEIGHT “bold” ; set bold font - FONTWEIGHT “normal” ; set normal weight - -=== FONTSTYLE === - - FONTSTYLE “italic” ; set italic variant - FONTSTYLE “normal” ; set normal variant - -== PICTURE (pic) == - -PICTURE is for -* shape grouping; -* starting new line shapes; -* keeping the consistency of positions and line shapes at the left border. - -=== Shape grouping === - - ; PICTURE [ LibreLogo_commands ] - PICTURE [ FORWARD 100 CIRCLE 100 ] ; tree-like grouped shape - -See also “Group” in LibreOffice Writer Help. - - TO tree location - PENUP POSITION location HEADING 0 PENDOWN - PICTURE [ FORWARD 100 CIRCLE 100 ] ; tree-like grouped shape - END - - PICTURE [ tree [30, 50] tree [100, 50] ] ; grouped shapes in a grouped shape - -=== Starting new line shapes === - - PICTURE ; start a new line shape - FORWARD 10 PICTURE FORWARD 10 ; two line shapes - -=== Consistency at the left border === - -Use picture to keep the consistency of positions and line shapes at the left border of Writer: - - PICTURE [ CIRCLE 20 POSITION [-100, 100] CIRCLE 20 ] - -== Loops == - -=== REPEAT === - - ; REPEAT number [ commands ] - - REPEAT 10 [ FORWARD 10 LEFT 45 CIRCLE 10 ] ; repeat 10 times - - ; number is optional - - REPEAT [ POSITION ANY ] ; endless loop - -=== REPCOUNT === - -Loop variable (also in the FOR and WHILE loops). - - REPEAT 100 [ FORWARD REPCOUNT LEFT 90 ] - -=== FOR IN === - -Loop for the list elements: - - FOR i IN [1, 5, 7, 9, 11] [ - FORWARD i - LEFT 90 - ] - -Loop for the characters of a character sequence: - - FOR i IN “text” [ - LABEL i - FORWARD 10 - ] - -=== WHILE === - - WHILE TRUE [ POSITION ANY ] ; endless loop - WHILE REPCOUNT <= 10 [ FORWARD 50 LEFT 36 ] ; as REPEAT 10 [ ... ] - -=== BREAK === - -Stop the loop. - - REPEAT [ ; endless loop - POSITION ANY - IF REPCOUNT = 100 [ BREAK ] ; equivalent of the REPEAT 100 [ ... ] - ] - -=== CONTINUE === - -Jump into the next iteration of the loop. - - REPEAT 100 [ - POSITION ANY - IF REPCOUNT % 2 <> 0 [ CONTINUE ] - CIRCLE 10 ; draw circles on every 2nd positions - ] - -== Conditions == - -=== IF === - - ; IF condition [ true block ] - ; IF condition [ true block ] [ false block ] - - IF a < 10 [ PRINT “Small” ] - IF a < 10 [ PRINT “Small” ] [ PRINT “Big” ] - -=== AND, OR, NOT === - -Logical operators. - - IF a < 10 AND NOT a < 5 [ PRINT “5, 6, 7, 8 or 9” ] - -== Subroutines == - -=== TO, END === - -New word (or procedure). - - TO triangle - REPEAT [ FORWARD 100 RIGHT 120 ] FILL - END - - REPEAT 10 [ triangle PENUP POSITION ANY PENDOWN ] - -=== OUTPUT === - -Return value of the function. - - TO randomletter - OUTPUT RANDOM “qwertzuiopasdfghjklyxcvbnm” - END - - PRINT randomletter + randomletter + randomletter ; print 3-letter random character sequence - -=== STOP === - -Return from the procedure. - - TO example number - IF number < 0 [ STOP ] - PRINT SQRT number ; print square root - ] - - example 100 - example -1 ; without output and error - example 25 - -== Default variables == - -=== ANY === - -Default random value of colors, etc. - - PENCOLOR ANY ; random pen color - -=== TRUE === - -Logical value. - - WHILE TRUE [ POSITION ANY ] ; endless loop - PRINT TRUE ; print true - -=== FALSE === - -Logical value. - - WHILE NOT FALSE [ POSITION ANY ] ; endless loop - PRINT FALSE ; print false - -=== PAGESIZE === - - PRINT PAGESIZE ; print list of the page sizes in points, eg. [595.30, 841.89] - -=== PI/π === - - PRINT PI ; print 3.14159265359 - -== Input/Output == - -=== PRINT === - - PRINT “text” ; print “text” in a dialog box - PRINT 5 + 10 ; print 15 - -=== INPUT === - - PRINT INPUT “Input value?” ; ask and print a string by a query dialog box - PRINT FLOAT (INPUT “First number?”) + FLOAT (INPUT “Second number?”) ; simple calculator - -== SLEEP == - - SLEEP 1000 ; wait for 1000 ms (1 sec) - -== GLOBAL == - -Set global variables used in procedures. - - GLOBAL about - about = “LibreLogo” - - TO example - PRINT about - GLOBAL about ; when we want to add a new value - about = “new value for the global variable” - END - - example - PRINT about - -== Functions == - -=== RANDOM === - - PRINT RANDOM 100 ; random float number (0 <= x < 100) - PRINT RANDOM “text” ; random letter of the “text” - PRINT RANDOM [1, 2] ; random list element (1 or 2) - -=== INT === - - PRINT INT 3.8 ; print 3 (integer part of 3.8) - PRINT INT RANDOM 100 ; random integer number (0 <= x < 100) - PRINT INT “7” ; convert the string parameter to integer - -=== FLOAT === - - ; convert the string parameter to float number - PRINT 2 * FLOAT “5.5” ; print 11.0 - -=== STR === - - ; convert the number parameter to string - PRINT “Result: ” + STR 5 ; print “Result: 5” - PRINT 10 * STR 5 ; print 5555555555 - -=== SQRT === - - PRINT SQRT 100 ; print 10, square root of 100 - -=== SIN === - - PRINT SIN 90 * PI/180 ; print 1.0 (sinus of 90° in radians) - -=== COS === - - PRINT COS 0 * PI/180 ; print 1.0 (sinus of 0° in radians) - -=== ROUND === - - PRINT ROUND 3.8 ; print 4 (rounding 3.8) - PRINT ROUND RANDOM 100 ; random integer number (0 <= x <= 100) - -=== ABS === - - PRINT ABS -10 ; print 10, absolute value of -10 - -=== COUNT === - - PRINT COUNT “text” ; print 4, character count of “text” - PRINT COUNT [1, 2, 3] ; print 3, size of the list - -=== SET === - - ; Convert list to Python set - PRINT SET [4, 5, 6, 6] ; print {4, 5, 6} - PRINT SET [4, 5, 6, 6] | SET [4, 1, 9] ; print {1, 4, 5, 6, 9}, union - PRINT SET [4, 5, 6, 6] & SET [4, 1, 9] ; print {4}, intersection - PRINT SET ([4, 5, 6, 6]) - SET [4, 1, 9] ; print {5, 6}, difference - PRINT SET [4, 5, 6, 6] ^ SET [4, 1, 9] ; print {1, 5, 6, 9}, symmetric difference - -=== RANGE === - - ; Python-like list generation - PRINT RANGE 10 ; print [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - PRINT RANGE 3 10 ; print [3, 4, 5, 6, 7, 8, 9] - PRINT RANGE 3 10 3 ; print [3, 6, 9] - - FOR i in RANGE 10 50 10 [ ; loop for [10, 20, 30, 40] - FORWARD i - LEFT 90 - ] - -=== LIST === - - ; remove the repeating elements of a list using set and list conversion - PRINT LIST (SET [1, 3, 5, 5, 2, 1]) ; print [1, 3, 5, 2] - -=== TUPLE === - -Conversion to Python tuple (non-modifiable list) - - PRINT TUPLE [4, 5] - -=== SORTED === - -It returns with a sorted list. - - PRINT SORTED [5, 1, 3, 4] ; print [1, 3, 4, 5] - -=== SUB === - -Substitue character sequences using regex (regular expression) patterns. - - PRINT SUB (“t”, “T”, “text”) ; print “Text”, replacing “t” with “T” - PRINT SUB (“(.)”, “\\1\\1”, “text”) ; print “tteexxtt”, doubling every characters - -=== SEARCH === - -Search character sequences patterns using regex patterns. - - IF SEARCH (“\w”, word) [ PRINT “Letter in the word.” ] - -=== FINDALL === - -Find all character sequences in the input string matching the given regex pattern. - - PRINT FINDALL(“\w+”, “Dogs, cats.”) ; print [“Dogs”, “cats”], the list of the words. - -=== MIN === - - PRINT MIN [1, 2, 3] ; print 1, the lowest element of the list - -=== MAX === - - PRINT MAX [1, 2, 3] ; print 3, the greatest element of the list - -== Color constants == - - PENCOLOR “SILVER” ; set by name - PENCOLOR [1] ; set by identifiers - PENCOLOR “~SILVER” ; random silver color - -{|class="wikitable" -|Identifier -|Name -|- -|0 -|style="color: white; background-color: #000000;"|BLACK -|- -|1 -|style="color: black; background-color: #c0c0c0;"|SILVER -|- -|2 -|style="color: white; background-color: #808080;"|GRAY/GREY -|- -|3 -|style="color: black; background-color: #ffffff;"|WHITE -|- -|4 -|style="color: white; background-color: #800000;"|MAROON -|- -|5 -|style="color: white; background-color: #ff0000;"|RED -|- -|6 -|style="color: white; background-color: #800080;"|PURPLE -|- -|7 -|style="color: black; background-color: #f000f0;"|FUCHSIA/MAGENTA -|- -|8 -|style="color: white; background-color: #008000;"|GREEN -|- -|9 -|style="color: black; background-color: #00ff00;"|LIME -|- -|10 -|style="color: white; background-color: #808000;"|OLIVE -|- -|11 -|style="color: black; background-color: #ffff00;"|YELLOW -|- -|12 -|style="color: white; background-color: #000080;"|NAVY -|- -|13 -|style="color: white; background-color: #0000f0;"|BLUE -|- -|14 -|style="color: white; background-color: #008080;"|TEAL -|- -|15 -|style="color: black; background-color: #00ffff;"|AQUA -|- -|16 -|style="color: black; background-color: #ffc0cb;"|PINK -|- -|17 -|style="color: black; background-color: #ff6347;"|TOMATO -|- -|18 -|style="color: black; background-color: #ffa500;"|ORANGE -|- -|19 -|style="color: black; background-color: #ffd700;"|GOLD -|- -|20 -|style="color: black; background-color: #9400d3;"|VIOLET -|- -|21 -|style="color: black; background-color: #87ceeb;"|SKYBLUE -|- -|22 -|style="color: black; background-color: #d2691e;"|CHOCOLATE -|- -|23 -|style="color: black; background-color: #a52a2a;"|BROWN -|- -|24 -|style="color: black;"|INVISIBLE -|} - diff --git a/librelogo/help/en-US/LibreLogo/gendoc.sh b/librelogo/help/en-US/LibreLogo/gendoc.sh deleted file mode 100755 index c07c62d3d82e..000000000000 --- a/librelogo/help/en-US/LibreLogo/gendoc.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -cat doc.txt | awk 'BEGIN{system("cat head")}/^ /{code = code $0 "
";next}{if (code != ""){print "" gensub(" ", "\\ ", "g", code) "";code=""}}/^=+/{l=length($1);print ""substr($0, l+2, length($0)-l*2-2)"";next}/^[{][|]/{print "";next}/^[|]}/{print "
";next}/^[|]-/{print "";next}/^[|]/{print ""gensub("^.*[|]","","g")"";next}{print "" $0 "" }END{print ""}' >LibreLogo.xhp - diff --git a/librelogo/help/en-US/LibreLogo/head b/librelogo/help/en-US/LibreLogo/head deleted file mode 100644 index e0783a4ae971..000000000000 --- a/librelogo/help/en-US/LibreLogo/head +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - -LibreLogo -Logo -Turtle graphics - - diff --git a/librelogo/help/en-US/help.tree b/librelogo/help/en-US/help.tree deleted file mode 100644 index 6bed2ffa1d2e..000000000000 --- a/librelogo/help/en-US/help.tree +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - LibreLogo - - - diff --git a/librelogo/icons/lc_arrowshapes.circular-arrow.png b/librelogo/icons/lc_arrowshapes.circular-arrow.png deleted file mode 100644 index b7a5a9258ca7..000000000000 Binary files a/librelogo/icons/lc_arrowshapes.circular-arrow.png and /dev/null differ diff --git a/librelogo/icons/lc_arrowshapes.circular-leftarrow.png b/librelogo/icons/lc_arrowshapes.circular-leftarrow.png deleted file mode 100644 index ad2197838ca7..000000000000 Binary files a/librelogo/icons/lc_arrowshapes.circular-leftarrow.png and /dev/null differ diff --git a/librelogo/icons/lc_arrowshapes.down-arrow.png b/librelogo/icons/lc_arrowshapes.down-arrow.png deleted file mode 100644 index d3b81b9f6446..000000000000 Binary files a/librelogo/icons/lc_arrowshapes.down-arrow.png and /dev/null differ diff --git a/librelogo/icons/lc_arrowshapes.up-arrow.png b/librelogo/icons/lc_arrowshapes.up-arrow.png deleted file mode 100644 index 6ae84abe8376..000000000000 Binary files a/librelogo/icons/lc_arrowshapes.up-arrow.png and /dev/null differ diff --git a/librelogo/icons/lc_basicstop.png b/librelogo/icons/lc_basicstop.png deleted file mode 100644 index ab9bddb4a98b..000000000000 Binary files a/librelogo/icons/lc_basicstop.png and /dev/null differ diff --git a/librelogo/icons/lc_editglossary.png b/librelogo/icons/lc_editglossary.png deleted file mode 100644 index fcba68f1feb5..000000000000 Binary files a/librelogo/icons/lc_editglossary.png and /dev/null differ diff --git a/librelogo/icons/lc_navigationbarleft.png b/librelogo/icons/lc_navigationbarleft.png deleted file mode 100644 index 7e69c8045fbe..000000000000 Binary files a/librelogo/icons/lc_navigationbarleft.png and /dev/null differ diff --git a/librelogo/icons/lc_newdoc.png b/librelogo/icons/lc_newdoc.png deleted file mode 100644 index 8e18798acdb2..000000000000 Binary files a/librelogo/icons/lc_newdoc.png and /dev/null differ diff --git a/librelogo/icons/lc_runbasic.png b/librelogo/icons/lc_runbasic.png deleted file mode 100644 index da2d9d97badf..000000000000 Binary files a/librelogo/icons/lc_runbasic.png and /dev/null differ diff --git a/librelogo/icons/sc_arrowshapes.circular-arrow.png b/librelogo/icons/sc_arrowshapes.circular-arrow.png deleted file mode 100644 index 35a5e9719607..000000000000 Binary files a/librelogo/icons/sc_arrowshapes.circular-arrow.png and /dev/null differ diff --git a/librelogo/icons/sc_arrowshapes.circular-leftarrow.png b/librelogo/icons/sc_arrowshapes.circular-leftarrow.png deleted file mode 100644 index 62eeee65fba4..000000000000 Binary files a/librelogo/icons/sc_arrowshapes.circular-leftarrow.png and /dev/null differ diff --git a/librelogo/icons/sc_arrowshapes.down-arrow.png b/librelogo/icons/sc_arrowshapes.down-arrow.png deleted file mode 100644 index 7290cae2f1c4..000000000000 Binary files a/librelogo/icons/sc_arrowshapes.down-arrow.png and /dev/null differ diff --git a/librelogo/icons/sc_arrowshapes.up-arrow.png b/librelogo/icons/sc_arrowshapes.up-arrow.png deleted file mode 100644 index 5f9bcc197f81..000000000000 Binary files a/librelogo/icons/sc_arrowshapes.up-arrow.png and /dev/null differ diff --git a/librelogo/icons/sc_basicstop.png b/librelogo/icons/sc_basicstop.png deleted file mode 100644 index 1c6ff922a786..000000000000 Binary files a/librelogo/icons/sc_basicstop.png and /dev/null differ diff --git a/librelogo/icons/sc_editglossary.png b/librelogo/icons/sc_editglossary.png deleted file mode 100644 index 4e14c031a4ae..000000000000 Binary files a/librelogo/icons/sc_editglossary.png and /dev/null differ diff --git a/librelogo/icons/sc_navigationbarleft.png b/librelogo/icons/sc_navigationbarleft.png deleted file mode 100644 index e544a7581f33..000000000000 Binary files a/librelogo/icons/sc_navigationbarleft.png and /dev/null differ diff --git a/librelogo/icons/sc_newdoc.png b/librelogo/icons/sc_newdoc.png deleted file mode 100644 index e914775a2693..000000000000 Binary files a/librelogo/icons/sc_newdoc.png and /dev/null differ diff --git a/librelogo/icons/sc_runbasic.png b/librelogo/icons/sc_runbasic.png deleted file mode 100644 index 8dd695c1e767..000000000000 Binary files a/librelogo/icons/sc_runbasic.png and /dev/null differ diff --git a/librelogo/make.py b/librelogo/make.py deleted file mode 100644 index 0d877edadf62..000000000000 --- a/librelogo/make.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- encoding: UTF-8 -*- -import sys, os, zipfile - -distname = 'librelogo-0.2.oxt' -z = zipfile.ZipFile(distname, mode='w', compression = zipfile.ZIP_DEFLATED) - -for i in ["LibreLogo/LibreLogo.py", "pythonpath/en.properties", "pythonpath/hu.properties", \ - "META-INF/manifest.xml", "description.xml", "Addons.xcu", "README", \ - "Office/UI/WriterWindowState.xcu", "Office/UI/StartModuleWindowState.xcu", \ - "help/en-US/LibreLogo/LibreLogo.xhp", "help/en-US/help.tree", "pythonpath/librelogodummy_path.py", \ - "description-en.txt", "description-hu.txt", "LibreLogoDummy.py" ] + \ -"""icons/lc_arrowshapes.circular-arrow.png -icons/lc_arrowshapes.circular-leftarrow.png -icons/lc_arrowshapes.down-arrow.png -icons/lc_arrowshapes.up-arrow.png -icons/lc_basicstop.png -icons/lc_editglossary.png -icons/lc_navigationbarleft.png -icons/lc_newdoc.png -icons/lc_runbasic.png -icons/sc_arrowshapes.circular-arrow.png -icons/sc_arrowshapes.circular-leftarrow.png -icons/sc_arrowshapes.down-arrow.png -icons/sc_arrowshapes.up-arrow.png -icons/sc_basicstop.png -icons/sc_editglossary.png -icons/sc_navigationbarleft.png -icons/sc_newdoc.png -icons/sc_runbasic.png""".split("\n"): - z.writestr(i, open(i, "r").read()) diff --git a/librelogo/prj/build.lst b/librelogo/prj/build.lst new file mode 100644 index 000000000000..d280a4a42d12 --- /dev/null +++ b/librelogo/prj/build.lst @@ -0,0 +1,2 @@ +librelogo librelogo : TRANSLATIONS:translations offapi officecfg comphelper unotools l10ntools cppu tools cppuhelper sal javaunohelper officecfg DESKTOP:xmlhelp DESKTOP:helpcompiler NULL +librelogo librelogo\prj nmake - all librelogo_prj NULL diff --git a/librelogo/prj/d.lst b/librelogo/prj/d.lst new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/librelogo/pythonpath/en.properties b/librelogo/pythonpath/en.properties deleted file mode 100644 index f9a0d0b87ee6..000000000000 --- a/librelogo/pythonpath/en.properties +++ /dev/null @@ -1,151 +0,0 @@ -# turtle graphics - -FORWARD=forward|fd -BACKWARD=back|bk -TURNLEFT=left|turnleft|lt -TURNRIGHT=right|turnright|rt -PENUP=penup|pu -PENDOWN=pendown|pd -HOME=home -POINT=point -CIRCLE=circle -ELLIPSE=ellipse -SQUARE=square -RECTANGLE=rectangle -LABEL=label -PENCOLOR=pencolor|pencolour|linecolor|pc -ANY=any -PENWIDTH=pensize|penwidth|linewidth|ps -PENSTYLE=penstyle|linestyle -PENJOINT=penjoint|linejoint -NONE=none -BEVEL=bevel -MITER=miter -ROUNDED=round -SOLID=solid -DASH=dashed -DOTTED=dotted -CLOSE=close -FILL=fill -FILLCOLOR=fillcolor|fillcolour|fc -FILLSTYLE=fillstyle -FONTCOLOR=fontcolor|textcolor|textcolour -FONTHEIGHT=fontsize|textsize|textheight -FONTWEIGHT=fontweight -FONTSTYLE=fontstyle -BOLD=bold -ITALIC=italic -UPRIGHT=upright|normal -NORMAL=normal -FONTFAMILY=fontfamily -CLEARSCREEN=clearscreen|cs -TEXT=text -HIDETURTLE=hideturtle|ht|hideme -SHOWTURTLE=showturtle|st|showme -POSITION=position|pos|setpos -HEADING=heading|setheading|seth -PAGESIZE=pagesize -GROUP=picture|pic - -# control structures - -TO=to -END=end -STOP=stop -REPEAT=repeat|forever -REPCOUNT=repcount -BREAK=break -CONTINUE=continue -WHILE=while -FOR=for -IN=in -IF=if -OUTPUT=output -LEFTSTRING=\u201c|\u2018 -RIGHTSTRING=\u201d|\u2019 -TRUE=true -FALSE=false -NOT=not -AND=and -OR=or -INPUT=input -PRINT=print -SLEEP=sleep -GLOBAL=global - -# functions -RANDOM=random -INT=int -FLOAT=float -STR=str -SQRT=sqrt -SIN=sin -COS=cos -ROUND=round -ABS=abs -COUNT=count -SET=set -RANGE=range -LIST=list -TUPLE=tuple -SORTED=sorted -RESUB=sub -RESEARCH=search -REFINDALL=findall -MIN=min -MAX=max - -PI=pi|\u03c0 - -# measurement -DECIMAL=. -DEG=\u00b0 -HOUR=h -MM=mm -CM=cm -PT=pt -INCH=in|" - -# color codes - -INVISIBLE=invisible -BLACK=black -SILVER=silver -GRAY=gray|grey -WHITE=white -MAROON=maroon -RED=red -PURPLE=purple -FUCHSIA=fuchsia|magenta -GREEN=green -LIME=lime -OLIVE=olive -YELLOW=yellow -NAVY=navy -BLUE=blue -TEAL=teal -AQUA=aqua|cyan -PINK=pink -TOMATO=tomato -ORANGE=orange -GOLD=gold -VIOLET=violet -SKYBLUE=skyblue -CHOCOLATE=chocolate -BROWN=brown - -# messages - -LIBRELOGO=LibreLogo -ERROR=Error (in line %s) -ERR_ZERODIVISION=Division by zero. -ERR_NAME=Unknown name: \u2018%s\u201d. -ERR_ARGUMENTS=%s takes %s arguments (%s given). -ERR_BLOCK=Error (extra or missing spaces at brackets?) -ERR_KEY=Unknown element: %s -ERR_INDEX=Index out of range. - -ERR_STOP=Program terminated: -ERR_MAXRECURSION=maximum recursion depth (%d) exceeded. -ERR_MEMORY=not enough memory. -ERR_NOTAPROGRAM=Do you want to run this text document? diff --git a/librelogo/pythonpath/hu.properties b/librelogo/pythonpath/hu.properties deleted file mode 100644 index 36408b732e48..000000000000 --- a/librelogo/pythonpath/hu.properties +++ /dev/null @@ -1,151 +0,0 @@ -# turtle graphics - -FORWARD=el\u0151re|e -BACKWARD=h\u00e1tra|h -TURNLEFT=balra|b -TURNRIGHT=jobbra|j -PENUP=tollatfel|tf -PENDOWN=tollatle|tl -HOME=haza -POINT=pont -CIRCLE=k\u00f6r -ELLIPSE=ellipszis -SQUARE=n\u00e9gyzet -RECTANGLE=t\u00e9glalap -LABEL=c\u00edmke -PENCOLOR=tollsz\u00edn|tollsz\u00edn!|tsz!?|vonalsz\u00edn -ANY=tetsz\u0151leges|tetsz -PENWIDTH=tollvastags\u00e1g|tollvastags\u00e1g!|tv!?|vonalvastags\u00e1g -PENSTYLE=tollst\u00edlus|vonalst\u00edlus -PENJOINT=tollsarok|vonalsarok -NONE=nincs -BEVEL=tompa -ROUNDED=kerek -MITER=hegyes -SOLID=folyamatos -DASH=szaggatott -DOTTED=pontozott -CLOSE=z\u00e1r -FILL=t\u00f6lt -FILLCOLOR=t\u00f6lt\u0151sz\u00edn|t\u00f6lt\u0151sz\u00edn!|tlsz!? -FILLSTYLE=t\u00f6lt\u0151st\u00edlus -FONTCOLOR=bet\u0171sz\u00edn -FONTHEIGHT=bet\u0171m\u00e9ret -FONTWEIGHT=bet\u0171vastags\u00e1g -FONTSTYLE=bet\u0171st\u00edlus -BOLD=f\u00e9lk\u00f6v\u00e9r|k\u00f6v\u00e9r|vastag -ITALIC=kurz\u00edv|d\u0151lt -UPRIGHT=\u00e1ll\u00f3|norm\u00e1l -NORMAL=norm\u00e1l -FONTFAMILY=bet\u0171csal\u00e1d -CLEARSCREEN=t\u00f6r\u00f6lk\u00e9perny\u0151|t\u00f6r\u00f6lk\u00e9p|t\u00f6r\u00f6lrajzlap|tr -TEXT=sz\u00f6veg -HIDETURTLE=l\u00e1thatatlan|elrejttekn\u0151c|rejttek|elrejt -SHOWTURTLE=l\u00e1that\u00f3 -POSITION=hely|hely!|poz\u00edci\u00f3|xy! -HEADING=ir\u00e1ny|ir\u00e1ny! -PAGESIZE=oldalm\u00e9ret -GROUP=k\u00e9p - -# control structures - -TO=ez|elj\u00e1r\u00e1s|elj|tanuld -END=v\u00e9ge -STOP=stop|visszat\u00e9r -OUTPUT=eredm\u00e9ny -REPEAT=ism\u00e9t|ism|ism\u00e9tl\u00e9s|v\u00e9gtelenszer|vszer -REPCOUNT=h\u00e1nyadik -BREAK=kil\u00e9p -CONTINUE=\u00fajra -WHILE=am\u00edg -FOR=fut -IN=-ban|-ben -IF=ha -LEFTSTRING=\u201e -RIGHTSTRING=\u201d -TRUE=igaz -FALSE=hamis -NOT=nem -AND=\u00e9s -OR=vagy -INPUT=be -PRINT=ki|ki\u00edr -SLEEP=v\u00e1r|v\u00e1rj -GLOBAL=glob\u00e1lis|glob\u00e1lisv\u00e1ltoz\u00f3|globv\u00e1l - -# functions -RANDOM=v\u00e9letlen|v\u00e9letlensz\u00e1m|vsz\u00e1m|kiv\u00e1laszt -INT=eg\u00e9szsz\u00e1m|eg\u00e9sz -FLOAT=t\u00f6rtsz\u00e1m|t\u00f6rt -STR=karakterl\u00e1nc|l\u00e1nc -SQRT=gy\u00f6k -SIN=sin -COS=cos -ROUND=kerek|kerek\u00edt\u00e9s -ABS=abszol\u00fat\u00e9rt\u00e9k|absz? -COUNT=darab|db|elemsz\u00e1m -SET=halmaz -RANGE=sor -LIST=lista -TUPLE=fix -SORTED=rendez -RESUB=cser\u00e9l -RESEARCH=keres -REFINDALL=tal\u00e1l -MIN=min -MAX=max - -PI=pi|\u03c0 - -# measurement -DECIMAL=, -DEG=\u00b0 -HOUR=\u00f3|h -MM=mm -CM=cm -PT=pt -INCH=in|" - -# color constants - -INVISIBLE=l\u00e1thatatlan -BLACK=fekete -SILVER=vil\u00e1gossz\u00fcrke|ez\u00fcst -GRAY=sz\u00fcrke -WHITE=feh\u00e9r -MAROON=s\u00f6t\u00e9tbarna -RED=piros|v\u00f6r\u00f6s -PURPLE=lila -FUCHSIA=b\u00edbor|cikl\u00e1men -GREEN=z\u00f6ld -LIME=vil\u00e1gosz\u00f6ld -OLIVE=olajz\u00f6ld -YELLOW=s\u00e1rga -NAVY=s\u00f6t\u00e9tk\u00e9k -BLUE=k\u00e9k -TEAL=k\u00e9kesz\u00f6ld -AQUA=ci\u00e1nk\u00e9k|ci\u00e1n -PINK=r\u00f3zsasz\u00edn -TOMATO=vil\u00e1gospiros -ORANGE=narancss\u00e1rga|narancs -GOLD=aranys\u00e1rga|arany -VIOLET=ibolyak\u00e9k|ibolya|viola -SKYBLUE=\u00e9gsz\u00ednk\u00e9k|vil\u00e1gosk\u00e9k -CHOCOLATE=vil\u00e1gosbarna -BROWN=barna - -# messages - -LIBRELOGO=LibreLogo -ERROR=Hiba (%s. sor) -ERR_ZERODIVISION=Oszt\u00e1s null\u00e1val. -ERR_NAME=Ismeretlen n\u00e9v: \u201e%s\u201d. -ERR_ARGUMENTS=%s: %s adatot v\u00e1r, de %s lett megadva. -ERR_BLOCK=Hiba (hi\u00e1nyz\u00f3 vagy felesleges sz\u00f3k\u00f6z a kapcsos z\u00e1r\u00f3jeln\u00e9l?) -ERR_KEY=Ismeretlen elem: %s -ERR_INDEX=Nem l\u00e9tez\u0151 elemre hivatkoz\u00e1s. - -ERR_STOP=A fut\u00e1s le\u00e1ll\u00edtva: -ERR_MAXRECURSION=el\u00e9rve az \u00fajrah\u00edv\u00e1si korl\u00e1t (%d). -ERR_MEMORY=nincs el\u00e9g mem\u00f3ria. -ERR_NOTAPROGRAM=Futtatni akarja ezt a sz\u00f6veges dokumentumot? diff --git a/librelogo/pythonpath/librelogodummy_path.py b/librelogo/pythonpath/librelogodummy_path.py deleted file mode 100644 index f600a162b1cf..000000000000 --- a/librelogo/pythonpath/librelogodummy_path.py +++ /dev/null @@ -1,3 +0,0 @@ -import uno, re, sys, os, traceback -def get_path(): - return os.path.join(os.path.dirname(sys.modules[__name__].__file__), __name__ + ".py") diff --git a/librelogo/source/ChangeLog b/librelogo/source/ChangeLog new file mode 100644 index 000000000000..17f19a88a998 --- /dev/null +++ b/librelogo/source/ChangeLog @@ -0,0 +1,82 @@ +2012-11-06 László Németh: + * uppercase/translation icon: + - expands and uppercase Logo commands (fd -> FORWARD) + - translation between supported languages (commands, decimal sign, for/in order) + * new icon for clear screen + * add English manual (see LibreLogo/Logo/Turtle graphics in Help) + +2012-10-25 László Németh: + * fix positioning to the faulty program line + * program cache depends from the (modified) language of the document, too + +2012-10-21 László Németh: + * speed up command line + * add multiline tooltip to the command line (it works well from LibO 3.6.2) + * random color constants: ~color, eg. '~orange', '~green' etc. + * handle modulo operator + * ask before the compilation of long documents (avoid freezings) + * add compilation cache to the multiline programs + * better help window caption in the command line + +2012-06-27 László Németh: + * fix __string__ (use localized decimal sign) + * fix repcount in loops with inner picture block + * handle reopened documents + * modified argument list of custom dashed penstyle + * fix warning messages at maximum recursion depth and memory + * add hatching styles (fillstyle num or + fillstyle [line count(max 3), color, distance, degree] + * add localized set(), range(), sorted() + * fix turtle selection at program start + * modified turtle colors + * fix showturtle + * fix LineStyle_SOLID and LineStyle_DASHED + * add repcount to the infinite loop + * add logical expression and better list support to the simple LibreLogo expression parser + * add string size limit for Print() + * support "pic" without block: new shape + * use localized __string__ for STR instead of str + * add min, max, and regex functions: sub, search, findall + * fix double round in localizations + * more stable dotted lines in the PDF export (implemented as arrays of dot-headed arrows) + * circles with dotted lines + * working pos and pagesize indices in expressions + +2012-05-17 László Németh: + * fix opt. suffix syntax of for+in (eg. with Finnish :ssa, Hungarian -ban) + * add dashed outline of turtle to show "pen up" state + * fix initial turtle focus for OpenOffice.org and older LibreOffice versions + * parsing simple (with 0 or 1 argument) user functions in complex expressions + * add localized "global" + * add localized operator "in" for logical expressions + * parsing user functions with 2 or more arguments in simple numerical expressions + * function heading supports coordinates + * function position supports drawing + * function pensize supports argument any + * set SizeProtect feature of turtle shape + * replace random while repcount variable with iterator + * fix repcount checking in conditions of "while" loops + * add repcount support to "for x in y" loops + * fix OUTPUT and STOP for lines with multiple commands + * fix = -> == conversion in logical expressions in OUTPUT + * fix multiple document support using CreationDate instead of Title + * better OpenOffice.org 3.2 compatibility (optional usage of feature Visible) + +2012-05-08 László Németh: + * picture [] handles left hanging shapes better + * function random works on lists or list-convertable objects (string, tuple, dict, set), too + * faster "label" (remove unnecessary shape search) + * document-level turtle states + * clean name spaces + * localization of "pi" (localizations support greek letter pi as alternative) + * localized "float" + * int & float support localized decimal signs and measurements (float '10,5cm') + * print, label, text support localized decimal sign + +2012-05-02 László Németh: + * fix slow drawing of new line shapes (unnecessary shape search) + * "circle" and "square" are synonyms of ellipse and rectangle, eg. + square num = rectangle [num, num] + +2012-04-27 László Németh: + * Initial release diff --git a/librelogo/source/LibreLogo/LibreLogo.py b/librelogo/source/LibreLogo/LibreLogo.py new file mode 100644 index 000000000000..9a45b2b20caf --- /dev/null +++ b/librelogo/source/LibreLogo/LibreLogo.py @@ -0,0 +1,1407 @@ +# -*- encoding: UTF-8 -*- +# -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +import sys, os, uno, unohelper +import re, random, traceback, itertools +import threading, time as __time__ + +ctx = uno.getComponentContext() +__lngpath__ = re.sub("[\w_.]*$", "", ctx.ServiceManager.createInstanceWithContext("org.openoffice.LibreLogo.LibreLogoDummy", ctx).get_path()) +__translang__ = "cz|de|dk|en_US|es|fr|hu|it|nl|no|pl|pt|ru|se|sl" # FIXME supported languages for language guessing, expand this list, according to the localizations +__lng__ = {} +__docs__ = {} +__prevcode__ = None +__prevlang__ = None +__prevcompiledcode__ = None +__thread__ = None +__lock__ = threading.Lock() +__halt__ = False +__compiled__ = "" +__group__ = 0 +__groupstack__ = [] +__grouplefthang__ = 0 +__comp__ = {} +__strings__ = [] +__colors__ = {} +__COLORS__ = ['BLACK', 0x000000], ['SILVER', 0xc0c0c0], ['GRAY', 0x808080], \ + ['WHITE', 0xffffff], ['MAROON', 0x800000], ['RED', 0xff0000], \ + ['PURPLE', 0x800080], ['FUCHSIA', 0xff00ff], ['GREEN', 0x008000], \ + ['LIME', 0x00ff00], ['OLIVE', 0x808000], ['YELLOW', 0xffff00], \ + ['NAVY', 0x000080], ['BLUE', 0x0000ff], ['TEAL', 0x008080], \ + ['AQUA', 0x00ffff], ['PINK', 0xffc0cb], ['TOMATO', 0xff6347], \ + ['ORANGE', 0xffa500], ['GOLD', 0xffd700], ['VIOLET', 0x9400d3], \ + ['SKYBLUE', 0x87ceeb], ['CHOCOLATE', 0xd2691e], ['BROWN', 0xa52a2a], \ + ['INVISIBLE', 0xff000000] +__SLEEP_SLICE_IN_MILLISECONDS__ = 500 +__PT_TO_TWIP__ = 20 +__MM_TO_PT__ = 1/(25.4/72) +__MM10_TO_TWIP__ = 1/(2540.0/72/20) # 0.01 mm to twentieth point +__FILLCOLOR__ = 0x8000ff00 +__LINEWIDTH__ = 0.5 * __PT_TO_TWIP__ +__ENCODED_STRING__ = "_s_%s___" +__DECODE_STRING_REGEX__ = "_s_([0-9]+)___" +__LINEBREAK__ = "#_@L_i_N_e@_#" +__TURTLE__ = "turtle" +__ACTUAL__ = "actual" +__BASEFONTFAMILY__ = "Linux Biolinum G" +__LineStyle_DOTTED__ = 2 + +class __Doc__: + def __init__(self, doc): + self.doc = doc + try: + self.drawpage = doc.DrawPage # Writer + except: + self.drawpage = doc.DrawPages.getByIndex(0) # Draw, Impress + self.shapecache = {} + self.zoomvalue = 0 + self.initialize() + + def initialize(self): + self.pen = 1 + self.pencolor = 0 + self.pensize = __LINEWIDTH__ + self.linestyle = __LineStyle_SOLID__ + self.linejoint = __ROUNDED__ + self.oldlc = 0 + self.oldlw = 0 + self.oldls = __LineStyle_SOLID__ + self.oldlj = __ROUNDED__ + self.continuous = True + self.areacolor = __FILLCOLOR__ + self.hatch = None + self.textcolor = 0 + self.fontfamily = __BASEFONTFAMILY__ + self.fontheight = 12 + self.fontweight = 100 + self.fontstyle = 0 + +from math import pi, sin, cos, asin, sqrt + +from com.sun.star.awt import Point as __Point__ +from com.sun.star.drawing import LineDash as __LineDash__ +from com.sun.star.drawing import Hatch as __Hatch__ +from com.sun.star.drawing import PolyPolygonBezierCoords as __Bezier__ +from com.sun.star.text.TextContentAnchorType import AT_PAGE as __AT_PAGE__ +from com.sun.star.text.WrapTextMode import THROUGHT as __THROUGHT__ +from com.sun.star.drawing.LineJoint import NONE as __Joint_NONE__ +from com.sun.star.drawing.LineJoint import BEVEL as __BEVEL__ +from com.sun.star.drawing.LineJoint import MITER as __MITER__ +from com.sun.star.drawing.LineJoint import ROUND as __ROUNDED__ +from com.sun.star.drawing.LineStyle import SOLID as __LineStyle_SOLID__ +from com.sun.star.drawing.LineStyle import DASH as __LineStyle_DASHED__ +from com.sun.star.drawing.DashStyle import RECT as __DashStyle_RECT__ +from com.sun.star.drawing.DashStyle import ROUND as __DashStyle_ROUND__ +from com.sun.star.drawing.DashStyle import ROUNDRELATIVE as __DashStyle_ROUNDRELATIVE__ +from com.sun.star.drawing.CircleKind import FULL as __FULL__ +from com.sun.star.drawing.CircleKind import SECTION as __SECTION__ +from com.sun.star.drawing.CircleKind import CUT as __CUT__ +from com.sun.star.drawing.CircleKind import ARC as __ARC__ +from com.sun.star.awt.FontSlant import NONE as __Slant_NONE__ +from com.sun.star.awt.FontSlant import ITALIC as __Slant_ITALIC__ +from com.sun.star.awt import Size as __Size__ +from com.sun.star.awt import WindowDescriptor as __WinDesc__ +from com.sun.star.awt.WindowClass import MODALTOP as __MODALTOP__ +from com.sun.star.awt.VclWindowPeerAttribute import OK as __OK__ +from com.sun.star.awt.VclWindowPeerAttribute import YES_NO_CANCEL as __YES_NO_CANCEL__ # OK_CANCEL, YES_NO, RETRY_CANCEL, DEF_OK, DEF_CANCEL, DEF_RETRY, DEF_YES, DEF_NO +from com.sun.star.awt.PushButtonType import OK as __Button_OK__ +from com.sun.star.awt.PushButtonType import CANCEL as __Button_CANCEL__ +from com.sun.star.util.MeasureUnit import APPFONT as __APPFONT__ +from com.sun.star.beans import PropertyValue as __property__ +from com.sun.star.lang import Locale + +def __getprop__(name, value): + p, p.Name, p.Value = __property__(), name, value + return p + +def __l12n__(lng): + try: + return __lng__[lng] + except: + try: + __lng__[lng] = dict([[i.split("=")[0].strip(), i.split("=")[1].strip().decode("unicode-escape")] for i in open(__lngpath__ + "LibreLogo_" + lng + ".properties", 'r').readlines() if "=" in i]) + return __lng__[lng] + except: + return None + +# dot for dotted line (implemented as an array of dot-headed arrows, because PostScript dot isn't supported by Writer) +__bezierdot__ = __Bezier__() +__dots__ = [] +for i in range(32): + __dots__ += [__Point__(round(sin(360.0/32 * i * pi/180.0) * 1000), round(cos(360.0/32 * i * pi/180) * 1000))] +__bezierdot__.Coordinates = (tuple(__dots__),) +__bezierdot__.Flags = ((0,) * 32,) + +def __getdocument__(): + global __docs__, _ + doc = XSCRIPTCONTEXT.getDocument() + try: + _ = __docs__[doc.Title] + _.doc.Title # Is existing instance (not the garbage of the previous instance of a reopened document or a new "Untitled 1")? + except: + _ = __Doc__(doc) + __docs__[doc.Title] = _ + +# input function, result: input string or 0 +def Input(s): + try: + ctx = uno.getComponentContext() + smgr = ctx.ServiceManager + text = "" + + # dialog + d = smgr.createInstanceWithContext("com.sun.star.awt.UnoControlDialogModel", ctx) + ps = _.doc.CurrentController.Frame.ContainerWindow.getPosSize() + lo = _.doc.CurrentController.Frame.ContainerWindow.convertSizeToLogic(__Size__(ps.Width, ps.Height), __APPFONT__) + d.PositionX, d.PositionY, d.Width, d.Height = lo.Width/2 - 75, lo.Height/2 - 25, 150, 50 + + # label + l = d.createInstance("com.sun.star.awt.UnoControlFixedTextModel" ) + + if type(s) == list: + text = s[1] + s = s[0] + l.PositionX, l.PositionY, l.Width, l.Height, l.Name, l.TabIndex, l.Label = 5, 4, 140, 14, "l1", 2, s + + # textbox or combobox + e = d.createInstance("com.sun.star.awt.UnoControlEditModel") + e.PositionX, e.PositionY, e.Width, e.Height, e.Name, e.TabIndex = 5, 14, 140, 12, "e1", 0 + + # buttons + b = d.createInstance( "com.sun.star.awt.UnoControlButtonModel" ) + b.PositionX, b.PositionY, b.Width, b.Height, b.Name, b.TabIndex, b.PushButtonType, b.DefaultButton = 55, 32, 45, 14, "b1", 1, __Button_OK__, True + b2 = d.createInstance( "com.sun.star.awt.UnoControlButtonModel" ) + b2.PositionX, b2.PositionY, b2.Width, b2.Height, b2.Name, b2.TabIndex, b2.PushButtonType = 100, 32, 45, 14, "b2", 1, __Button_CANCEL__ + + # insert the control models into the dialog model + d.insertByName( "l1", l) + d.insertByName( "b1", b) + d.insertByName( "b2", b2) + d.insertByName( "e1", e) + + # create the dialog control and set the model + controlContainer = smgr.createInstanceWithContext("com.sun.star.awt.UnoControlDialog", ctx) + controlContainer.setModel(d) + + # create a peer + toolkit = smgr.createInstanceWithContext("com.sun.star.awt.ExtToolkit", ctx) + controlContainer.setVisible(False) + controlContainer.createPeer(toolkit, None) + + # execute it + inputtext = controlContainer.execute() + if inputtext: + inputtext = e.Text + + # dispose the dialog + controlContainer.dispose() + return inputtext + except Exception, e: + __trace__() + +def __string__(s, decimal = None): # convert decimal sign, localized BOOL and SET + if not decimal: + decimal = _.decimal + if decimal == ',' and type(s) == float: + return str(s).replace(".", ",") + if type(s) in [list, tuple, dict, set]: + __strings__ = [] + s = re.sub("(?u)(['\"])(([^'\"]|\\['\"])*)(? "for x in y" + exception += ['IN'] + text = re.sub(ur"(?ui)\b((?:%s) +:?\w+) +([^\n]+)(?:%s) +(?=[[] |[[]\n)" % (lang['FOR'], in1), "\\1 %s \\2 " % in2, text) + text = re.sub(ur"(?ui)(:?\b\w+|[[][^[\n]*])\b(?:%s)\b" % in1, "%s \\1" % in2, text) + elif in1[0] != '-' and in2[0] == '-': # "for x in y" -> "for x y-in" + exception += ['IN'] + text = re.sub(ur"(?ui)(?<=\n)((?:%s)\b +:?\w+) +(?:%s) +([^\n]+?) +(?=[[] |[[]\n)" % (lang['FOR'], in1), "\\1 \\2%s " % in2, text) + text = re.sub(ur"(?ui)(?", line ' + message = traceback.format_exc() + l = re.findall(TRACEPATTERN + '[0-9]+', message) + if len(l) > 0 and not "SystemExit" in message: + line = len(re.findall(__LINEBREAK__, ''.join(self.code.split("\n")[:int(l[-1][len(TRACEPATTERN):])]))) + 1 + caption = __l12n__(_.lng)['LIBRELOGO'] + if __prevcode__ and "\n" in __prevcode__: + __gotoline__(line) + caption = __l12n__(_.lng)['ERROR'] % line + parent = _.doc.CurrentController.Frame.ContainerWindow + if "maximum recursion" in message: + MessageBox(parent, __l12n__(_.lng)['ERR_STOP'] + " " + __l12n__(_.lng)['ERR_MAXRECURSION'] % sys.getrecursionlimit(), __l12n__(_.lng)['LIBRELOGO']) + elif "cannot initialize memory" in message or "Couldn't instantiate" in message: + MessageBox(parent, __l12n__(_.lng)['ERR_STOP'] + " " + __l12n__(_.lng)['ERR_MEMORY'], __l12n__(_.lng)['LIBRELOGO']) + elif "ZeroDivisionError" in message: + MessageBox(parent, __l12n__(_.lng)['ERR_ZERODIVISION'], caption, "errorbox") + elif "IndexError" in message: + MessageBox(parent, __l12n__(_.lng)['ERR_INDEX'], caption, "errorbox") + elif "KeyError" in message: + MessageBox(parent, __l12n__(_.lng)['ERR_KEY'] % eval(re.search("KeyError: ([^\n]*)", message).group(1)), caption, "errorbox") + elif "NameError" in message: + if "__repeat__" in message: + MessageBox(parent, __l12n__(_.lng)['ERR_ARGUMENTS'] % (__locname__('REPEAT'), 1, 0), caption, "errorbox") + else: + MessageBox(parent, __l12n__(_.lng)['ERR_NAME'] % \ + to_unicode(re.search("(?<=name ')[\w_]*(?=')", message).group(0)), caption, "errorbox") + elif "TypeError" in message and "argument" in message and "given" in message: + r = re.search("([\w_]*)[(][)][^\n]* (\w+) arguments? [(](\d+)", message) # XXX later: handle 'no arguments' + plural + MessageBox(parent, __l12n__(_.lng)['ERR_ARGUMENTS'] % (__locname__(r.group(1)), r.group(2), r.group(3)), caption, "errorbox") + else: + origline = __compiled__.split("\n")[line-1] + if not "com.sun.star" in message and not "__repeat__" in message and not "*)" in message and ("[" in origline or "]" in origline): + MessageBox(parent, __l12n__(_.lng)['ERR_BLOCK'], caption, "errorbox") + else: + MessageBox(parent, __l12n__(_.lng)['ERROR'] %line, __l12n__(_.lng)['LIBRELOGO'], "errorbox") + __trace__() + except: + pass + with __lock__: + __thread__ = None + + +def __encodestring__(m): + __strings__.append(re.sub("\\[^\\]", "", m.group(2))) + return __ENCODED_STRING__ % (len(__strings__) - 1) + +def __decodestring__(m): + return "u'%s'" % __strings__[int(m.group(1))] + +def __decodestring2__(m): + return __l12n__(_.lng)['LEFTSTRING'][0] + __strings__[int(m.group(1))] + __l12n__(_.lng)['RIGHTSTRING'][0] + +def __initialize__(): + global __halt__, __thread__ + __getdocument__() + _.zoomvalue = _.doc.CurrentController.getViewSettings().ZoomValue + shape = __getshape__(__TURTLE__) + if not shape: + shape = _.doc.createInstance( "com.sun.star.drawing.PolyPolygonShape" ) + shape.AnchorType = __AT_PAGE__ + shape.TextWrap = __THROUGHT__ + shape.Opaque = True + _.drawpage.add(shape) + shape.PolyPolygon = ((__Point__(-60, 0), __Point__(0, -100), __Point__(60, 0)), (__Point__(0, 0), __Point__(0, 100)), \ + (__Point__(-250, 0),), (__Point__(0, 250),), (__Point__(250, 0),), (__Point__(0, -250),), # single points for wider selection + (__Point__(0, 0),)) # last point for position handling + _.shapecache[__TURTLE__] = shape + shape.Name = __TURTLE__ + _.initialize() + turtlehome() + _.doc.CurrentController.select(shape) + shape.LineJoint = __MITER__ + shape.Shadow = True + shape.FillColor, transparence = __splitcolor__(_.areacolor) + shape.FillTransparence = min(95, transparence) + shape.ShadowColor, shape.ShadowTransparence, shape.ShadowXDistance, shape.ShadowYDistance = (0, 20, 0, 0) +# shape.ShadowColor, shape.ShadowTransparence, shape.ShadowXDistance, shape.ShadowYDistance = (0, max(20, 100 - transparence), 0, 0) + shape.LineColor, shape.LineTransparence = __splitcolor__(_.pencolor) + shape.LineWidth = min(_.pensize, (1 + _.pen * 2) * __PT_TO_TWIP__) + shape.SizeProtect = True + +def pagesize(n = -1): + if n == -1: + ps = _.doc.CurrentController.getViewCursor().PageStyleName + page = _.doc.StyleFamilies.getByName("PageStyles").getByName(ps) + return [page.Width * __MM10_TO_TWIP__ / __PT_TO_TWIP__, page.Height * __MM10_TO_TWIP__ / __PT_TO_TWIP__] + return None + +def turtlehome(): + turtle = __getshape__(__TURTLE__) + if turtle: + ps = _.doc.CurrentController.getViewCursor().PageStyleName + page = _.doc.StyleFamilies.getByName("PageStyles").getByName(ps) + turtle.setPosition(__Point__((page.Width - turtle.BoundRect.Width)/2, (page.Height - turtle.BoundRect.Height)/2)) + turtle.LineStyle = __LineStyle_SOLID__ + turtle.LineJoint = __MITER__ + turtle.LineWidth = min(_.pensize, (1 + _.pen * 2) * __PT_TO_TWIP__) + turtle.LineColor, none = __splitcolor__(_.pencolor) + turtle.LineTransparence = 25 + turtle.RotateAngle = 0 + turtle.ZOrder = 1000 + +def __pen__(n): + _.pen = n + turtle = __getshape__(__TURTLE__) + if turtle: + if n: + turtle.LineStyle = __LineStyle_SOLID__ + turtle.LineWidth = min(_.pensize, 3 * __PT_TO_TWIP__) + else: + turtle.LineStyle = __LineStyle_DASHED__ + turtle.LineDash = __LineDash__(__DashStyle_RECT__, 0, 0, 1, __PT_TO_TWIP__, __PT_TO_TWIP__) + turtle.LineWidth = min(_.pensize, __PT_TO_TWIP__) + + +def __visible__(shape, visible = -1): # for OOo 3.2 compatibility + try: + if visible == -1: + return shape.Visible + shape.Visible = visible + except: + return True + +def hideturtle(): + turtle = __getshape__(__TURTLE__) + if turtle: + __visible__(turtle, False) + turtle.LineTransparence, turtle.FillTransparence = 100, 100 # for saved files + __dispatcher__(".uno:Escape") + +def showturtle(): + turtle = __getshape__(__TURTLE__) + if turtle: + if not turtle.Parent: + _.drawpage.add(turtle) + pencolor(_.pencolor) + fillcolor(_.areacolor) + pensize(_.pensize/__PT_TO_TWIP__) + __visible__(turtle, True) + _.doc.CurrentController.select(__getshape__(__TURTLE__)) + else: + __initialize__() + +def left(arg=None): + if __thread__: + return None + __initialize__() + turtle = uno.getComponentContext().ServiceManager.createInstance('com.sun.star.drawing.ShapeCollection') + turtle.add(__getshape__(__TURTLE__)) + _.doc.CurrentController.select(turtle) +# _.doc.CurrentController.select(__getshape__(__TURTLE__)) # it works from LibreOffice 3.5 + rotate(__TURTLE__, 1500) + return None + +def right(arg=None): + if __thread__: + return None + __initialize__() + turtle = uno.getComponentContext().ServiceManager.createInstance('com.sun.star.drawing.ShapeCollection') + turtle.add(__getshape__(__TURTLE__)) + _.doc.CurrentController.select(turtle) + rotate(__TURTLE__, -1500) + return None + +def goforward(arg=None): + if __thread__: + return None + __initialize__() + turtle = uno.getComponentContext().ServiceManager.createInstance('com.sun.star.drawing.ShapeCollection') + turtle.add(__getshape__(__TURTLE__)) + _.doc.CurrentController.select(turtle) + forward(10) + return None + +def gobackward(arg=None): + if __thread__: + return None + __initialize__() + turtle = uno.getComponentContext().ServiceManager.createInstance('com.sun.star.drawing.ShapeCollection') + turtle.add(__getshape__(__TURTLE__)) + _.doc.CurrentController.select(turtle) + backward(10) + return None + +def commandline(arg=None, arg2=None): + run(arg, arg2) + +def __setlang__(): + global _ + loc = _.doc.CurrentController.getViewCursor().CharLocale + _.lng = loc.Language + '_' + loc.Country + if not __l12n__(_.lng): + _.lng = loc.Language + if not __l12n__(_.lng): + _.lng = "en_US" + +def run(arg=None, arg2 = -1): + global _, __thread__, __halt__, _, __prevcode__, __prevlang__, __prevcompiledcode__ + if __thread__: + return None + with __lock__: + __thread__ = 1 + try: + __initialize__() + __setlang__() + if arg2 == -1: + arg2 = _.doc.getText().getString() + if len(arg2) > 20000: + if MessageBox(_.doc.CurrentController.Frame.ContainerWindow, __l12n__(_.lng)['ERR_NOTAPROGRAM'], __l12n__(_.lng)['LIBRELOGO'], "querybox", __YES_NO_CANCEL__) <> 2: + with __lock__: + __thread__ = None + return None + __gotoline__(1) + if __prevcode__ and __prevcode__ == arg2 and __prevlang__ == _.lng: + __thread__ = LogoProgram(__prevcompiledcode__) + else: + __prevcode__ = arg2 + __prevlang__ = _.lng + __prevcompiledcode__ = __compil__(arg2) + __thread__ = LogoProgram(__prevcompiledcode__) + __halt__ = False + turtle = uno.getComponentContext().ServiceManager.createInstance('com.sun.star.drawing.ShapeCollection') + turtle.add(__getshape__(__TURTLE__)) + _.doc.CurrentController.select(turtle) + __thread__.start() + except Exception as e: + __thread__ = None + __trace__() + return None + +def stop(arg=None): + global __halt__ + with __lock__: + __halt__ = True + return None + +def home(arg=None): + if __thread__: + return None + __getdocument__() + turtle = __getshape__(__TURTLE__) + if turtle: + __removeshape__(__TURTLE__) + _.drawpage.remove(turtle) + __initialize__() + __dispatcher__(".uno:Escape") + if not __halt__: + return None + _.pencolor = 0 + _.pensize = __LINEWIDTH__ + _.areacolor = __FILLCOLOR__ + pen = 1 + __removeshape__(__ACTUAL__) + +def clearscreen(arg=None): + __getdocument__() + turtle = __getshape__(__TURTLE__) + if not turtle: + __initialize__() + if not __halt__: + return + __cs__(False) + __dispatcher__(".uno:Escape") + +def __checkhalt__(): + global __thread__, __halt__ + if __halt__: + with __lock__: + __thread__ = None + sys.exit() + +def __cs__(select = True): + turtle = __getshape__(__TURTLE__) + if turtle: + __visible__(turtle, False) + if _.doc.CurrentController.select(_.drawpage) and \ + _.doc.CurrentController.getSelection().ImplementationName == "com.sun.star.drawing.SvxShapeCollection": + __dispatcher__(".uno:Delete") + if turtle: + __visible__(turtle, True) + if select: + _.doc.CurrentController.select(_.drawpage) + +def __dispatcher__(s, properties = ()): + ctx = XSCRIPTCONTEXT.getComponentContext() + d = ctx.ServiceManager.createInstanceWithContext("com.sun.star.frame.DispatchHelper", ctx) + d.executeDispatch(_.doc.CurrentController.Frame, s, "", 0, properties) + +def __getshape__(shapename): + try: + if _.shapecache[shapename].Parent: + return _.shapecache[shapename] + _.shapecache.pop(shapename) + except: + pass + return None + +def __angle__(deg): + if deg == u'any': + return random.random() * 36000 + return deg * 100 + +def turnleft(deg): + rotate(__TURTLE__, __angle__(deg)) + +def turnright(deg): + rotate(__TURTLE__, -__angle__(deg)) + +def heading(deg = -1, go = False): + turtle = __getshape__(__TURTLE__) + if deg == -1: + return turtle.RotateAngle / 100 + else: + if deg == u'any': + turtle.RotateAngle = random.random() * 36000 + elif type(deg) == list: + pos = turtle.getPosition() + px, py = pos.X + turtle.BoundRect.Width / 2.0, pos.Y + turtle.BoundRect.Height / 2.0 + dx = px * __MM10_TO_TWIP__ - deg[0] * __PT_TO_TWIP__ + dy = deg[1] * __PT_TO_TWIP__ - py * __MM10_TO_TWIP__ + n = sqrt(dx**2 + dy**2) + if dy > 0 and n > 0: + turtle.RotateAngle = a = -(180 + asin(dx / n) / (pi/180)) * 100 + 72000 # +720 for max(angle, preciseAngle) of __go__() + elif n > 0: + turtle.RotateAngle = a = asin(dx / n) / (pi/180) * 100 + 72000 + if go and n > 0: + __go__(__TURTLE__, -n, False, a) + else: + turtle.RotateAngle = deg * 100 + +def rotate(shapename, deg): + shape = __getshape__(shapename) + if shape: + shape.RotateAngle = shape.RotateAngle + deg + +def forward(n): + if type(n) == list: + pos = position() + position([pos[0] + n[0], pos[1] + n[1]]) + else: + __go__(__TURTLE__, -n * __PT_TO_TWIP__) + +def backward(n): + if type(n) == list: + forward([-n[0], -n[1]]) + turnright(180) + else: + __go__(__TURTLE__, n * __PT_TO_TWIP__) + +def __dots__(n, pos, dx, dy, r = 0): # dots for dotted polyline or circle + k = abs(int(1.0 * n / max(10, _.pensize) / 2.0)) + dots = [] + px, py = pos.X, pos.Y + for i in range(k + 1): + if k > 0: + if r: + px, py = pos.X + sin(360.0/k * i * pi/180.0) * r, pos.Y + cos(360.0/k * i * pi/180) * r + else: + px, py = pos.X + round(i * dx/k), pos.Y + round(i * dy/k) + dots += [(__Point__(px, py),__Point__(px + 10, py + 10))] + return dots + +def __draw__(d): + shape = _.doc.createInstance( "com.sun.star.drawing." + d) + shape.AnchorType = __AT_PAGE__ + shape.TextWrap = __THROUGHT__ + __visible__(shape, False) + while __zoom__(): # temporary fix program halt with continuous zoom + while __zoom__(): + __time__.sleep(0.2) + __time__.sleep(0.2) + _.drawpage.add(shape) + if __group__: + __group__.add(shape) + return shape + +def __zoom__(): + z = _.doc.CurrentController.getViewSettings().ZoomValue + if z <> _.zoomvalue: + _.zoomvalue = z + return True + return False + +def __lefthang__(shape): + global __grouplefthang__ + if __group__: + p = shape.getPosition() + if p.X < __grouplefthang__: + __grouplefthang__ = p.X + +def __go__(shapename, n, dot = False, preciseAngle = -1): + turtle = __getshape__(shapename) + turtlepos = None + if shapename == __TURTLE__: + try: + turtlepos = turtle.PolyPolygon[-1][-1] + except: + pass + pos = turtle.getPosition() + dx = n * sin((pi/180)*(max(turtle.RotateAngle, preciseAngle)/100)) + dy = n * cos((pi/180)*(max(turtle.RotateAngle, preciseAngle)/100)) + turtle.setPosition(__Point__(pos.X + dx / __MM10_TO_TWIP__, pos.Y + dy / __MM10_TO_TWIP__)) + if (_.pencolor <> _.oldlc or _.pensize <> _.oldlw or _.linestyle <> _.oldls or _.linejoint <> _.oldlj): + __removeshape__(__ACTUAL__) + shape = None + else: + shape = __getshape__(__ACTUAL__) + _.oldlw = _.pensize + _.oldlc = _.pencolor + _.oldls = _.linestyle + _.oldlj = _.linejoint + if shape and not _.pen and not dot: + _.continuous = False + return + c, c2 = __Point__(pos.X + turtle.BoundRect.Width / 2.0, pos.Y + turtle.BoundRect.Height / 2.0), __Point__(round(dx), round(dy)) + if shape and "LineShape" in shape.ShapeType: + if _.continuous or dot: + last = shape.PolyPolygon[-1][-1] + if not (turtlepos and (abs(last.X - turtlepos.X) > 100 or abs(last.Y - turtlepos.Y) > 100) and + (not __group__ or (shape.getPosition().X > 0 and turtle.getPosition().X > 0))): # picture [ ] keeps hanging shapes + if dot or _.linestyle == __LineStyle_DOTTED__: + shape.PolyPolygon = tuple( list(shape.PolyPolygon) + __dots__(n, turtlepos, dx, dy)) + else: + last.X = last.X + c2.X + last.Y = last.Y + c2.Y + shape.PolyPolygon = tuple( list(shape.PolyPolygon[:-1]) + [tuple( list(shape.PolyPolygon[-1]) + [last])]) + __lefthang__(shape) + return + elif turtlepos: + shape.PolyPolygon = tuple( list(shape.PolyPolygon) + [(turtlepos, __Point__(turtlepos.X + c2.X, turtlepos.Y + c2.Y))]) + _.continuous = True + __lefthang__(shape) + return + if not _.pen and not dot: + return + shape = __draw__("PolyLineShape") + shape.RotateAngle = 0 + shape.PolyPolygon = tuple([tuple([__Point__(0, 0)])]) + shape.setPosition(c) + last = shape.PolyPolygon[-1][-1] + last2 = __Point__(last.X + c2.X, last.Y + c2.Y) + shape.LineStyle, shape.LineDash = __linestyle__(_.linestyle) + shape.LineJoint = _.linejoint + if dot or _.linestyle == __LineStyle_DOTTED__: + shape.PolyPolygon = tuple( list(shape.PolyPolygon) + __dots__(n, last, c2.X, c2.Y)) + shape.LineStart = __bezierdot__ + shape.LineStartCenter = True + shape.LineStartWidth = _.pensize / __MM10_TO_TWIP__ + shape.LineWidth = 0 + else: + shape.PolyPolygon = tuple([tuple( list(shape.PolyPolygon[-1]) + [last2])]) + shape.LineWidth = _.pensize / __MM10_TO_TWIP__ + shape.LineColor, shape.LineTransparence = __splitcolor__(_.pencolor) + __visible__(shape, True) + shape.Name = __ACTUAL__ + _.shapecache[__ACTUAL__] = shape + _.oldlw = _.pensize + _.oldlc = _.pencolor + _.oldls = _.linestyle + _.oldlj = _.linejoint + _.continuous = True + __lefthang__(shape) + +def __fillit__(filled = True): + oldshape = __getshape__(__ACTUAL__) + if oldshape.LineStartCenter: + __removeshape__(__ACTUAL__) # FIXME close dotted polyline + return + if oldshape and "LineShape" in oldshape.ShapeType: + shape = __draw__("PolyPolygonShape") + shape.PolyPolygon = oldshape.PolyPolygon + shape.setPosition(oldshape.getPosition()) + shape.LineStyle, shape.LineDash = __linestyle__(_.linestyle) + shape.LineJoint = _.linejoint + if _.hatch: + shape.FillBackground = True + shape.FillHatch = _.hatch + shape.FillStyle = 3 + else: + shape.FillStyle = int(filled) + shape.LineWidth = _.pensize / __MM10_TO_TWIP__ + shape.LineColor, shape.LineTransparence = __splitcolor__(_.pencolor) + shape.FillColor, shape.FillTransparence = __splitcolor__(_.areacolor) + shape.setString(oldshape.getString()) + oldshape.Name = "" + shape.Name = __ACTUAL__ + _.shapecache[__ACTUAL__] = shape + if __group__: + __group__.remove(oldshape) + __visible__(shape, True) + _.drawpage.remove(oldshape) + elif oldshape and "PolyPolygon" in oldshape.ShapeType: + oldshape.LineStyle = int(_.pen) + oldshape.LineJoint = _.linejoint + if _.hatch: + oldshape.FillBackground = True + oldshape.FillHatch = _.hatch + oldshape.FillStyle = 3 + else: + oldshape.FillStyle = int(filled) + oldshape.LineWidth = _.pensize / __MM10_TO_TWIP__ + oldshape.LineColor, oldshape.LineTransparence = __splitcolor__(_.pencolor) + oldshape.FillColor, oldshape.FillTransparence = __splitcolor__(_.areacolor) + +def point(): + oldpen, _.pen = _.pen, 1 + oldstyle, _.linestyle = _.linestyle, __LineStyle_DOTTED__ + __go__(__TURTLE__, 0, True) + _.pen, _.linestyle = oldpen, oldstyle + +def __boxshape__(shapetype, l): + if type(l) <> type([]): # default for circle and square + l = [l, l] + turtle = __getshape__(__TURTLE__) + shape = __draw__(shapetype + "Shape") + if _.hatch: + shape.FillBackground = True + shape.FillHatch = _.hatch + shape.FillStyle = 3 + else: + shape.FillStyle = 1 + pos = turtle.getPosition() + pos.X = pos.X - (l[0] * __PT_TO_TWIP__ / __MM10_TO_TWIP__ / 2) + turtle.BoundRect.Width / 2.0 + pos.Y = pos.Y - (l[1] * __PT_TO_TWIP__ / __MM10_TO_TWIP__ / 2) + turtle.BoundRect.Height / 2.0 + shape.setPosition(pos) + shape.setSize(__Size__(l[0] * __PT_TO_TWIP__ / __MM10_TO_TWIP__, l[1] * __PT_TO_TWIP__ / __MM10_TO_TWIP__)) + shape.LineStyle, shape.LineDash = __linestyle__(_.linestyle) + shape.LineWidth = _.pensize / __MM10_TO_TWIP__ + shape.LineJoint = _.linejoint + shape.LineColor, shape.LineTransparence = __splitcolor__(_.pencolor) + shape.FillColor, shape.FillTransparence = __splitcolor__(_.areacolor) + shape.RotateAngle = turtle.RotateAngle + if shapetype == "Rectangle" and len(l) > 2: + shape.CornerRadius = l[2] * __PT_TO_TWIP__ + elif shapetype == "Ellipse" and len(l) > 2: + try: + shape.CircleKind = __SECTION__ + shape.CircleStartAngle = (-l[3] - 270) * 100 + shape.CircleEndAngle = (-l[2] - 270) * 100 + shape.CircleKind = [__FULL__, __SECTION__, __CUT__, __ARC__][l[4]] + except: + pass + __visible__(shape, True) + __removeshape__(__ACTUAL__) + _.shapecache[__ACTUAL__] = shape + __lefthang__(shape) + +def ellipse(l): + if _.linestyle == __LineStyle_DOTTED__: + __removeshape__(__ACTUAL__) + point() + shape = __getshape__(__ACTUAL__) + shape.PolyPolygon = tuple(__dots__(l * pi * __PT_TO_TWIP__, shape.PolyPolygon[0][0], 0, 0, l/2 * __PT_TO_TWIP__)) + else: + __boxshape__("Ellipse", l) + +def rectangle(l): + if _.linestyle == __LineStyle_DOTTED__: + __removeshape__(__ACTUAL__) + point() + shape = __getshape__(__ACTUAL__) + shape.PolyPolygon = tuple(__dots__(l * pi * __PT_TO_TWIP__, shape.PolyPolygon[0][0], 0, 0, l/2 * __PT_TO_TWIP__)) + else: + __boxshape__("Rectangle", l) + +def label(st): + turtle = __getshape__(__TURTLE__) + shape = __draw__("TextShape") + shape.RotateAngle = turtle.RotateAngle + pos = turtle.getPosition() + pos.X = pos.X + turtle.BoundRect.Width / 2.0 + pos.Y = pos.Y + turtle.BoundRect.Height / 2.0 + shape.setSize(__Size__(1, 1)) + shape.TextAutoGrowWidth = True + text(shape, st) + shape.setPosition(__Point__(pos.X - shape.BoundRect.Width/2, pos.Y - shape.BoundRect.Height/2)) + __visible__(shape, True) + __lefthang__(shape) + +def text(shape, st): + if shape: + shape.setString(__string__(st, _.decimal)) + c = shape.createTextCursor() + c.gotoStart(False) + c.gotoEnd(True) + c.CharColor, none = __splitcolor__(_.textcolor) + c.CharHeight = _.fontheight + c.CharWeight = __fontweight__(_.fontweight) + c.CharPosture = __fontstyle__(_.fontstyle) + c.CharFontName = _.fontfamily + +def sleep(t): + for i in range(t/__SLEEP_SLICE_IN_MILLISECONDS__): + __checkhalt__() + __time__.sleep(0.5) + __checkhalt__() + __time__.sleep(t%__SLEEP_SLICE_IN_MILLISECONDS__/1000.0) + +def __removeshape__(shapename): + try: + _.shapecache.pop(shapename).Name = "" + except: + pass + +def __fontweight__(w): + if type(w) == int: + return w + elif re.match(__l12n__(_.lng)['BOLD'], w, flags = re.I): + return 150 + elif re.match(__l12n__(_.lng)['NORMAL'], w, flags = re.I): + return 100 + return 100 + +def __fontstyle__(w): + if type(w) == int: + return w + elif re.match(__l12n__(_.lng)['ITALIC'], w, flags = re.I): + return __Slant_ITALIC__ + elif re.match(__l12n__(_.lng)['UPRIGHT'], w, flags = re.I): + return __Slant_NONE__ + return __Slant_NONE__ + +def __color__(c): + if type(c) in [int, float, long]: + return c + if type(c) == unicode: + if c == u'any': +# return __COLORS__[int(random.random() * 24)][1] + return int(random.random() * 2**31) # max. 50% transparency + if c[0:1] == '~': + c = __componentcolor__(__colors__[_.lng][c[1:].lower()]) + for i in range(3): + c[i] = max(min(c[i] + int(random.random() * 64) - 32, 255), 0) + return __color__(c) + return __colors__[_.lng][c.lower()] + if type(c) == list: + if len(c) == 1: + return __COLORS__[int(c[0])][1] + if len(c) == 3: + return (int(c[0])%256 << 16) + (int(c[1])%256 << 8) + int(c[2])%256 + return (int(c[3])%256 << 24) + (int(c[0])%256 << 16) + (int(c[1])%256 << 8) + int(c[2])%256 + +def __linestyle__(s): + if _.pen == 0: + return 0, __LineDash__() + if _.linestyle == __LineStyle_DASHED__: + return _.linestyle, __LineDash__(__DashStyle_RECT__, 0, 0, 1, 100, 100) + elif _.linestyle == __LineStyle_DOTTED__: + return __LineStyle_DASHED__, __LineDash__(__DashStyle_RECT__, 1, 1, 0, 0, 100000) + elif type(s) == list: + return __LineStyle_DASHED__, __LineDash__((s[5:6] or [0])[0], s[0], s[1] * __PT_TO_TWIP__, s[2], s[3] * __PT_TO_TWIP__, s[4] * __PT_TO_TWIP__) + return s, __LineDash__() + +def fillstyle(s): + if type(s) == list: + color, null = __splitcolor__(__color__(s[1])) + _.hatch = __Hatch__(s[0] - 1, color, s[2] * __PT_TO_TWIP__, s[3] * 10) + elif s == 0: + _.hatch = None + elif s <= 10: # using hatching styles of Writer + fillstyle([[1, 0, 5, 0], [1, 0, 5, 45], [1, 0, 5, -45], [1, 0, 5, 90], [2, [127, 0, 0], 5, 45], [2, [127, 0, 0], 5, 0], [2, [0, 0, 127], 5, 45], [2, [0, 0, 127], 5, 0], [3, [0, 0, 127], 5, 0], [1, 0, 25, 45]][s-1]) + +def __splitcolor__(c): + """Split color constants to RGB (3-byte) + transparency (%)""" + return int(c) & 0xffffff, (int(c) >> 24) / (255.0/100) + +def __componentcolor__(c): + a = [ (c & 0xff0000) >> 16, (c & 0xff00) >> 8, c & 0xff ] + if c > 2**24: + a.append((c & 0xff000000) >> 24) + return a + +def pencolor(n = -1): + if n != -1: + _.pencolor = __color__(n) + turtle = __getshape__(__TURTLE__) + if turtle and __visible__(turtle): + turtle.LineColor, turtle.LineTransparence = __splitcolor__(_.pencolor) + else: + return __componentcolor__(_.pencolor) + +def pensize(n = -1): + if n != -1: + if n == 'any': + _.pensize = random.random() * 10 * __PT_TO_TWIP__ + else: + _.pensize = n * __PT_TO_TWIP__ + turtle = __getshape__(__TURTLE__) + if turtle and __visible__(turtle): + turtle.LineWidth = min(_.pensize, (1 + _.pen * 2) * __PT_TO_TWIP__) + return _.pensize / __PT_TO_TWIP__ + +def penstyle(n = -1): + if n == -1: + try: + return __locname__(_.linestyle.value) + except: + return __locname__('DOTTED') + if type(n) == list and len(n) >= 5: + _.linestyle = n + elif re.match(__l12n__(_.lng)['SOLID'], n, flags = re.I): + _.linestyle = __LineStyle_SOLID__ + elif re.match(__l12n__(_.lng)['DASH'], n, flags = re.I): + _.linestyle = __LineStyle_DASHED__ + elif re.match(__l12n__(_.lng)['DOTTED'], n, flags = re.I): + _.linestyle = __LineStyle_DOTTED__ + +def penjoint(n = -1): + if n == -1: + return __locname__(_.linejoint.value) + if re.match(__l12n__(_.lng)['NONE'], n, flags = re.I): + _.linejoint = __Joint_NONE__ + elif re.match(__l12n__(_.lng)['BEVEL'], n, flags = re.I): + _.linejoint = __BEVEL__ + elif re.match(__l12n__(_.lng)['MITER'], n, flags = re.I): + _.linejoint = __MITER__ + elif re.match(__l12n__(_.lng)['ROUNDED'], n, flags = re.I): + _.linejoint = __ROUNDED__ + +def fillcolor(n = -1): + if n != -1: + _.areacolor = __color__(n) + turtle = __getshape__(__TURTLE__) + if turtle and __visible__(turtle): + turtle.FillColor, transparence = __splitcolor__(_.areacolor) + turtle.FillTransparence = min(95, transparence) + else: + return __componentcolor__(_.areacolor) + +def fontcolor(n = -1): + if n != -1: + _.textcolor = __color__(n) + else: + return __componentcolor__(_.textcolor) + +def position(n = -1): + turtle = __getshape__(__TURTLE__) + if turtle: + if n != -1: + if n == 'any': + ps = pagesize() + heading([random.random() * ps[0], random.random() * ps[1]], True) + else: + heading(n, True) + else: + pos = turtle.getPosition() + 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__(): + global __group__, __grouplefthang__, __groupstack__ + __removeshape__(__ACTUAL__) + __groupstack__.append(__group__) + __groupstack__.append(__grouplefthang__) + __group__ = uno.getComponentContext().ServiceManager.createInstance('com.sun.star.drawing.ShapeCollection') + __grouplefthang__ = 0 + +def __groupend__(): + global __group__, __grouplefthang__, __groupstack__ + g = 0 + if __group__.getCount() > 1: + if __grouplefthang__ < 0: + for i in range(__group__.Count): + s = __group__.getByIndex(i) + p = s.getPosition() + p.X = p.X + -__grouplefthang__ + s.setPosition(p) + g = _.drawpage.group(__group__) + p = g.getPosition() + p.X = p.X + __grouplefthang__ + g.setPosition(p) + else: + g = _.drawpage.group(__group__) + g.TextWrap = __THROUGHT__ + elif __group__.getCount() == 1: + g = __group__.getByIndex(0) + __grouplefthang__ = min(__groupstack__.pop(), __grouplefthang__) + __group__ = __groupstack__.pop() + if __group__ and g: + __group__.add(g) + __removeshape__(__ACTUAL__) + +def __int__(x): # handle eg. int("10cm") + if type(x) == str or type(x) == unicode: + x = __float__(x) + return int(x) + +def __float__(x): # handle eg. float("10,5cm") + if type(x) == str or type(x) == unicode: + for i in __comp__[_.lng]: + x = re.sub(u"(?iu)" + i[0], i[1], x) + x = eval(x) + return float(x) + +def __loadlang__(lang, a): + global comp, __colors__ + __colors__[lang] = {} + for i in __COLORS__: + for j in a[i[0]].split("|"): + __colors__[lang][j] = i[1] + + repcount = a['REPCOUNT'].split('|')[0] + loopi = itertools.count() + loop = lambda r: "%(i)s = 1\n%(orig)s%(j)s = %(i)s\n%(i)s += 1\n" % \ + { "i": repcount + str(loopi.next()), "j": repcount, "orig": re.sub( ur"(?ui)(?])=(?!=)", "==", r.group(0))], # = -> ==, XXX x = y = 1? + [ur"(?<=\n)(for\b :?\w+) ([^\n]+)(?<=\w|]|}|\))(?=-|:)(?:%s)\b" % a['IN'], "\\1 in \\2"], # "for x y-in" -> "for x in y" + [ur"(:?\b\w+|[[][^[\n]*])\b(?:%s)\b" % a['IN'], "in \\1"], # "x y-in" -> "x in y" + [ur"(? /1.0, but not with // + [ur"\b([0-9]+([,.][0-9]+)?)(%s)\b" % a['HOUR'], "\\1*30"], # 12h = 12*30° + [ur"(?<=\d)(%s)" % a['DEG'], ""], # 1° -> 1 + [ur"(? (1 + sqrt(x)) + [ur"(?<=[-*/=+,]) ?\n\)(\w+)\(", "\\1()"], # read attributes, eg. x = fillcolor + [ur"(?<=return) ?\n\)(\w+)\(", "\\1()"], # return + user function + [ur"(?<=(?:Print|label)\() ?\n\)(\w+)\(", "\\1()\n"] # Print/label + user function + ] + +def __concatenation__(r): # keep line positions with extra line breaks + s = re.subn("~[ \t]*\n", " ", r.group(0)) + return s[0] + "\n" * s[1] + +def __compil__(s): + global _, comp, __strings__, __compiled__ + try: + loc = _.doc.CurrentController.getViewCursor().CharLocale + try: + _.lng = loc.Language + '_' + loc.Country + __loadlang__(_.lng, __l12n__(_.lng)) + except: + __trace__() + _.lng = loc.Language + __loadlang__(_.lng, __l12n__(_.lng)) + except: + __trace__() + _.lng = 'en' + if not _.lng in __comp__: + __loadlang__(_.lng, __l12n__(_.lng)) + + _.decimal = __l12n__(_.lng)['DECIMAL'] + names = {} + + rmsp = re.compile(r"[ ]*([=+*/]|==|<=|>=|<>|!=|-[ ]+)[ ]*") + chsp = re.compile(r"[ \t]+") + chch = re.compile(r"(?u)(? 0: + globs = "global %s" % ", ".join(subnames) + # search user functions (function calls with two or more arguments need explicite Python parentheses) + functions += [ re.findall("(?u)\w+",i[0])[0] for i in re.findall(ur"""(?iu)(?<=__def__ )([^\n]*)\n # beginning of a procedure + (?:[^\n]*(? 0: + s = re.sub(ur"(?]|//|==|<=|>=|<>|!=)[ ]*|[ ]*-[ ]+|-|[ ]*[*][*][ ]*) # operators, eg. "**", " - ", "-", "- " + \[*([-+]|\([ ]?)* # minus sign, parenthesis + ((%(functions)s)\b[ ]*\(*)*([0-9]+([.,][0-9]+)?|:?\w+(?:[.]\w+[\(]?[\)]?)?)]* + ([ ]?\))*)* + [\)]*){,%(repeat)s} + ) +""" + chargsp = re.compile(r"(? + + + + + + + + \ No newline at end of file diff --git a/librelogo/source/README b/librelogo/source/README new file mode 100644 index 000000000000..ffe5ea0a1611 --- /dev/null +++ b/librelogo/source/README @@ -0,0 +1,43 @@ +LibreOffice Logo 0.2 RC2 + +License: GNU LGPL & GPL, MPL + +Home page: http://www.numbertext.org/logo + +(c) László Németh (nemeth at numbertextdotorg) + +FSF.hu Foundation, http://www.fsf.hu + +Icons copyright: OpenOffice.org/LibreOffice + +Introduction +============ + +LibreLogo is a Logo-like programming language with interactive vectorgraphics for education and DTP + +- presentation: http://www.numbertext.org/logo/librelogo.pdf +- basic Logo syntax for back compability with educational Logo systems +- interactive vectorgraphics in LibreOffice Writer +- native commands (easily translatable) +- Python data structures (list, tuple, set, dictionary) and other Python features + +Usage +===== + +See Logo in LibreOffice Help and http://www.numbertext.org/logo for documentation. + +Translation +=========== + +create your_language_id.lng in LibreOffice/ based on en.lng. + +Compilation: + +python make.py + +Development +=========== + +LibreLogo uses the PyUNO scripting framework, so Addons.xcu URLs depend from the +full name of the package. Modify them according to the package name with the +version number. diff --git a/librelogo/source/description-en-US.txt b/librelogo/source/description-en-US.txt new file mode 100644 index 000000000000..6e9566518da8 --- /dev/null +++ b/librelogo/source/description-en-US.txt @@ -0,0 +1 @@ +Programming language and environment for education, graphic design and desktop publishing. Usage: View→Toolbars→Logo toolbar in Writer. See Logo in LibreOffice Help. diff --git a/librelogo/source/description.xml b/librelogo/source/description.xml new file mode 100644 index 000000000000..6711d7806ccb --- /dev/null +++ b/librelogo/source/description.xml @@ -0,0 +1,20 @@ + + + + + LibreLogo + + + + László Németh + Németh László + + + + + + + + diff --git a/librelogo/source/help/en-US/LibreLogo.xhp b/librelogo/source/help/en-US/LibreLogo.xhp new file mode 100644 index 000000000000..7d6539d53da7 --- /dev/null +++ b/librelogo/source/help/en-US/LibreLogo.xhp @@ -0,0 +1,388 @@ + + + + + + + + + +LibreLogo +Logo +Turtle graphics + + +LibreLogo +LibreLogo is a simple, native, Logo-like programming environment with turtle vector graphics for teaching of computing (programming and word processing), DTP and graphic design. See http://www.numbertext.org/logo/librelogo.pdf. +LibreLogo toolbar +The LibreLogo toolbar (View » Toolbars » Logo) contains turtle moving, program run and stop, home and clear screen and syntax highlighting/translating icons and an input bar (command line). +Turtle moving icons +They are equivalents of the Logo commands “FORWARD 10”, “BACK 10”, “LEFT 15”, “RIGHT 15”. Clicking on one of the icons will also focus the turtle shape scrolling the page to its position. +Program run and start +Click on the icon “run” to execute the text of the Writer document as a LibreLogo program. +Click on the icon “stop” to stop the program execution. +Home +Click on the icon “home” to reset the position and settings of the turtle. +Clear screen +Click on the icon “clear screen” to remove the drawing objects of the document. +Command line +Hit Enter in the command line to execute its content. To stop the program use the icon “stop”. +Hold down the Enter to repeat the command line, for example, on the following command sequence: + FORWARD 200 LEFT 89
+To reset the command line click triple in it or press Ctrl-A to select the previous commands, and type the new commands. +Syntax highlighting/Translating +It expands and upper case Logo commands in the Writer document. Change the language of the document (Tools » Options » Language Settings » Languages » Western) and click on this icon to translate the Logo program to the selected language. +Program editing +LibreLogo drawings and programs use the same Writer document. The LibreLogo canvas is on the first page of the Writer document. You can insert a page break before the LibreLogo programs and set the zoom/font size for a comfortable two page layout for LibreLogo programming: left (first) page is the canvas, right (second) page is for the LibreLogo programs. +LibreLogo programming language +LibreLogo is a native, easily localisable, Logo-like programming language. It is back-compatible with the older Logo systems in the case of the simple Logo programs used in education, eg. + TO triangle :size
 REPEAT 3 [
   FORWARD :size
   LEFT 120
 ]
 END
 
 triangle 10 triangle 100 triangle 200
+Differences from the Logo programming language + + + List members are comma separated: POSITION [0, 0] + + + Program blocks and lists are different + + + + + Program blocks need space or new line at parenthesization: REPEAT 10 [ forward 10 left 36 ] + + + Lists need close parenthesization: POSITION [0, 0], and not POSITION [ 0, 0 ] + + + + + 1-line function declarations have not supported yet (TO and END need new lines). + + +Other features of LibreLogo + + + The colon is optional before the variables (like in the Berkeley Logo) +  TO triangle size
   REPEAT 3 [ FORWARD size LEFT 120 ]
 END
+
+ + String notation supports also orthographical and Python syntax: +  PRINT "word" ; original Logo syntax
 PRINT “Arbitrary text.” ; orthography, Writer
 PRINT 'Arbitrary text.' ; Python syntax
+
+ + Python list and string handling +  PRINT “text”[2] ; print “x”
 PRINT “text”[1:3] ; print “ex”
+
+ + Python-like FOR loop + + + Python-like variable declaration: +  x = 15
 PRINT x
+
+ + There are no extra query functions: +  PRINT FILLCOLOR
 p = POSITION
 PRINT p
 REPEAT 10 [ POSITION ANY POSITION p ]
+
+ + Alternative parenthesization in function calls +  TO star size color
 FILLCOLOR color
 REPEAT 5 [ LEFT 72 FORWARD size RIGHT 144 FORWARD size ]
 FILL
 END
 
 star 100 “red”
 star (100, “green”)
 star(100, “blue”)
+
+
+LibreLogo commands +Basic syntax +Case sensitivity +Commands, color constants are case insensitive: + PRINT “Hello, World!”
 print “Hello, World, again!”
+Variable names are case sensitive: + a = 5
 A = 7
 PRINT a
 PRINT A
+Program lines +Lines of a LibreLogo program are paragraphs in the LibreOffice Writer document. A program line can contain multiple commands: + PRINT “Hello, World!” PRINT “LibreLogo”
+Comments +Lines or line parts are comments from a semicolon to the end of the line (paragraph): + ; some comments
 PRINT 5 * 5 ; some comments
+Break program lines to multiple paragraphs +It’s possible to break a program line for more paragraphs using the character tilde at the end of the line: + PRINT “This is a very long ” + ~
       “warning message”
+Turtle moving +FORWARD (fd) + FORWARD 10 ; move forward 10pt (1pt = 1/72 inch)
 FORWARD 10pt ; see above
 FORWARD 0.5in ; move forward 0.5 inch (1 inch = 2.54 cm)
 FORWARD 1" ; see above
 FD 1mm
 FD 1cm
+BACK (bk) + BACK 10 ; move back 10pt
+LEFT (lt) + LEFT 90 ; turn counterclockwise 90 degrees
 LEFT 90° ; see above
 LT 3h ; see above (clock position)
 LT any ; turn to a random position
+RIGHT (rt) + RIGHT 90 ; turn clockwise 90 degrees
+PENUP (pu) + PENUP ; turtle will move without drawing
+PENDOWN (pd) + PENDOWN ; turtle will move with drawing
+POSITION (pos) + POSITION [0, 0] ; turn and move to the top-left corner
 POSITION PAGESIZE ; turn and move to the bottom-right corner
 POSITION [PAGESIZE[0], 0] ; turn and move to the top-right corner
 POSITION ANY ; turn and move to a random position
+HEADING (seth) + HEADING 0 ; turn north
 HEADING 12h ; see above
 HEADING ANY ; turn to a random position
+Other turtle commands +HIDETURTLE (ht) + HIDETURTLE ; hide turtle (until the showturtle command)
+SHOWTURTLE (st) + SHOWTURTLE ; show turtle
+HOME + HOME ; reset initial turtle settings and position
+CLEARSCREEN (cs) + CLEARSCREEN ; remove drawing objects of the document
+FILL and CLOSE + FILL ; close and fill the actual line shape
 CLOSE ; close the actual line shape
+Pen settings +PENSIZE (ps) + PENSIZE 100 ; line width is 100 points
 PENSIZE ANY ; equivalent of PENSIZE RANDOM 10
+PENCOLOR/PENCOLOUR (pc) + PENCOLOR “red” ; set red pen color (by color name, see color constants)
 PENCOLOR [255, 255, 0] ; set yellow color (RGB list)
 PENCOLOR 0xffff00 ; set yellow color (hexa code)
 PENCOLOR 0 ; set black color (0x000000)
 PENCOLOR ANY ; random color
 PENCOLOR [5] ; set red color (by color identifier, see color constants)
 PENCOLOR “invisible” ; invisible pen color for shapes without visible outline
 PENCOLOR “~red” ; set random red color
+PENJOINT/LINEJOINT + PENJOINT “rounded” ; rounded line joint (default)
 PENJOINT “miter” ; sharp line joint
 PENJOINT “bevel” ; bevel line joint
 PENJOINT “none” ; without line joint
+PENSTYLE + PENSTYLE “solid” ; solid line (default)
 PENSTYLE “dotted” ; dotted line
 PENSTYLE “dashed” ; dashed line
 
 ; custom dot–dash pattern specified by a list with the following arguments:
 ; – number of the neighbouring dots
 ; – length of a dot
 ; – number of the neighbouring dashes
 ; – length of a dash
 ; – distance of the dots/dashes
 ; – type (optional):
 ;   0 = dots are rectangles (default)
 ;   2 = dots are squares (lengths and distances are relative to the pensize)
 
 PENSTYLE [3, 1mm, 2, 4mm, 2mm, 2] ; ...––...––...––
+Fill settings +FILLCOLOR/FILLCOLOUR (fc) + FILLCOLOR “blue” ; fill with blue color, see also PENCOLOR
 FILLCOLOR “invisible” CIRCLE 10 ; unfilled circle
+FILLSTYLE + FILLSTYLE 0 ; fill without hatches (default)
 FILLSTYLE 1 ; black single hatches (horizontal)
 FILLSTYLE 2 ; black single hatches (45 degrees)
 FILLSTYLE 3 ; black single hatches (-45 degrees)
 FILLSTYLE 4 ; black single hatches (vertical)
 FILLSTYLE 5 ; red crossed hatches (45 degrees)
 FILLSTYLE 6 ; red crossed hatches (0 degrees)
 FILLSTYLE 7 ; blue crossed hatches (45 degrees)
 FILLSTYLE 8 ; blue crossed hatches (0 degrees)
 FILLSTYLE 9 ; blue triple crossed
 FILLSTYLE 10 ; black wide single hatches (45 degrees)
 
 ; custom hatches specified by a list with the following arguments:
 ; – style (1 = single, 2 = double, 3 = triple hatching)
 ; – color
 ; – distance
 ; – degree
 
 FILLSTYLE [2, “green”, 3pt, 15°] ; green crossed hatches (15 degrees)
+Drawing objects +CIRCLE + CIRCLE 100 ; draw a circle shape (diameter = 100pt)
+ELLIPSE + ELLIPSE [50, 100] ; draw an ellipse with 50 and 100 diameters
 ELLIPSE [50, 100, 2h, 12h] ; draw an elliptical sector (from 2h clock position to 12h)
 ELLIPSE [50, 100, 2h, 12h, 2]  ; draw an elliptical segment
 ELLIPSE [50, 100, 2h, 12h, 3]  ; draw an elliptical arc
+SQUARE + SQUARE 100 ; draw a square shape (size = 100pt)
+RECTANGLE + RECTANGLE [50, 100] ; draw a rectange shape (50×100pt)
 RECTANGLE [50, 100, 50] ; draw a rectangle 
+POINT + POINT ; draw a point with size and color of the pen
+LABEL + LABEL “text” ; print text in the turte position
 LABEL 'text' ; see above
 LABEL "text ; see above (only for single words)
+TEXT + CIRCLE 10 TEXT “text” ; set text of the actual drawing object
+Font settings +FONTCOLOR/FONTCOLOUR + FONTCOLOR “green” ; set font color
+FONTFAMILY + FONTFAMILY “Linux Libertine G” ; set font (family)
 FONTFAMILY “Linux Libertine G:smcp=1” ; set also font feature (small caps)
 FONTFAMILY “Linux Libertine G:smcp=1&onum=1” ; small caps + old figures
+FONTSIZE + FONTSIZE 12 ; set 12pt
+FONTWEIGHT + FONTWEIGHT “bold” ; set bold font
 FONTWEIGHT “normal” ; set normal weight
+FONTSTYLE + FONTSTYLE “italic” ; set italic variant
 FONTSTYLE “normal” ; set normal variant
+PICTURE (pic) +PICTURE is for + + + shape grouping; + + + starting new line shapes; + + + keeping the consistency of positions and line shapes at the left border. + + +Shape grouping + ; PICTURE [ LibreLogo_commands ]
 PICTURE [ FORWARD 100 CIRCLE 100 ] ; tree-like grouped shape
+See also “Group” in LibreOffice Writer Help. + TO tree location
   PENUP POSITION location HEADING 0 PENDOWN
   PICTURE [ FORWARD 100 CIRCLE 100 ] ; tree-like grouped shape
 END
 
 PICTURE [ tree [30, 50] tree [100, 50] ] ; grouped shapes in a grouped shape
+Starting new line shapes + PICTURE ; start a new line shape
 FORWARD 10 PICTURE FORWARD 10 ; two line shapes
+Consistency at the left border +Use picture to keep the consistency of positions and line shapes at the left border of Writer: + PICTURE [ CIRCLE 20 POSITION [-100, 100] CIRCLE 20 ]
+Loops +REPEAT + ; REPEAT number [ commands ]
 
 REPEAT 10 [ FORWARD 10 LEFT 45 CIRCLE 10 ] ; repeat 10 times
+ ; number is optional
 
 REPEAT [ POSITION ANY ] ; endless loop
+REPCOUNT +Loop variable (also in the FOR and WHILE loops). + REPEAT 100 [ FORWARD REPCOUNT LEFT 90 ]
+FOR IN +Loop for the list elements: + FOR i IN [1, 5, 7, 9, 11] [
   FORWARD i
   LEFT 90
 ]
+Loop for the characters of a character sequence: + FOR i IN “text” [
   LABEL i
   FORWARD 10
 ]
+WHILE + WHILE TRUE [ POSITION ANY ] ; endless loop
 WHILE REPCOUNT <= 10 [ FORWARD 50 LEFT 36 ] ; as REPEAT 10 [ ... ]
+BREAK +Stop the loop. + REPEAT [ ; endless loop
   POSITION ANY
   IF REPCOUNT = 100 [ BREAK ]  ; equivalent of the REPEAT 100 [ ... ]
 ]
+CONTINUE +Jump into the next iteration of the loop. + REPEAT 100 [
   POSITION ANY
   IF REPCOUNT % 2 <> 0 [ CONTINUE ]
   CIRCLE 10 ; draw circles on every 2nd positions
 ]
+Conditions +IF + ; IF condition [ true block ]
 ; IF condition [ true block ] [ false block ]
 
 IF a < 10 [ PRINT “Small” ]
 IF a < 10 [ PRINT “Small” ] [ PRINT “Big” ]
+AND, OR, NOT +Logical operators. + IF a < 10 AND NOT a < 5 [ PRINT “5, 6, 7, 8 or 9” ]
+Subroutines +TO, END +New word (or procedure). + TO triangle
   REPEAT [ FORWARD 100 RIGHT 120 ] FILL
 END
 
 REPEAT 10 [ triangle PENUP POSITION ANY PENDOWN ]
+OUTPUT +Return value of the function. + TO randomletter
   OUTPUT RANDOM “qwertzuiopasdfghjklyxcvbnm”
 END
 
 PRINT randomletter + randomletter + randomletter ; print 3-letter random character sequence
+STOP +Return from the procedure. + TO example number
   IF number < 0 [ STOP ]
   PRINT SQRT number ; print square root
 ]
 
 example 100
 example -1 ; without output and error
 example 25
+Default variables +ANY +Default random value of colors, etc. + PENCOLOR ANY ; random pen color
+TRUE +Logical value. + WHILE TRUE [ POSITION ANY ] ; endless loop
 PRINT TRUE ; print true
+FALSE +Logical value. + WHILE NOT FALSE [ POSITION ANY ] ; endless loop
 PRINT FALSE ; print false
+PAGESIZE + PRINT PAGESIZE ; print list of the page sizes in points, eg. [595.30, 841.89]
+PI/π + PRINT PI ; print 3.14159265359
+Input/Output +PRINT + PRINT “text” ; print “text” in a dialog box
 PRINT 5 + 10 ; print 15
+INPUT + PRINT INPUT “Input value?” ; ask and print a string by a query dialog box
 PRINT FLOAT (INPUT “First number?”) + FLOAT (INPUT “Second number?”) ; simple calculator
+SLEEP + SLEEP 1000 ; wait for 1000 ms (1 sec)
+GLOBAL +Set global variables used in procedures. + GLOBAL about
 about = “LibreLogo”
 
 TO example
   PRINT about
   GLOBAL about ; when we want to add a new value
   about = “new value for the global variable”
 END
 
 example
 PRINT about
+Functions +RANDOM + PRINT RANDOM 100 ; random float number (0 <= x < 100)
 PRINT RANDOM “text” ; random letter of the “text”
 PRINT RANDOM [1, 2] ; random list element (1 or 2)
+INT + PRINT INT 3.8 ; print 3 (integer part of 3.8)
 PRINT INT RANDOM 100 ; random integer number (0 <= x < 100)
 PRINT INT “7” ; convert the string parameter to integer
+FLOAT + ; convert the string parameter to float number
 PRINT 2 * FLOAT “5.5” ; print 11.0
+STR + ; convert the number parameter to string
 PRINT “Result: ” + STR 5 ; print “Result: 5”
 PRINT 10 * STR 5 ; print 5555555555
+SQRT + PRINT SQRT 100 ; print 10, square root of 100
+SIN + PRINT SIN 90 * PI/180 ; print 1.0 (sinus of 90° in radians)
+COS + PRINT COS 0 * PI/180 ; print 1.0 (sinus of 0° in radians)
+ROUND + PRINT ROUND 3.8 ; print 4 (rounding 3.8)
 PRINT ROUND RANDOM 100 ; random integer number (0 <= x <= 100)
+ABS + PRINT ABS -10 ; print 10, absolute value of -10
+COUNT + PRINT COUNT “text” ; print 4, character count of “text”
 PRINT COUNT [1, 2, 3] ; print 3, size of the list
+SET + ; Convert list to Python set
 PRINT SET [4, 5, 6, 6] ; print {4, 5, 6}
 PRINT SET [4, 5, 6, 6] | SET [4, 1, 9] ; print {1, 4, 5, 6, 9}, union
 PRINT SET [4, 5, 6, 6] & SET [4, 1, 9] ; print {4}, intersection
 PRINT SET ([4, 5, 6, 6]) - SET [4, 1, 9] ; print {5, 6}, difference
 PRINT SET [4, 5, 6, 6] ^ SET [4, 1, 9] ; print {1, 5, 6, 9}, symmetric difference  
+RANGE + ; Python-like list generation
 PRINT RANGE 10 ; print [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
 PRINT RANGE 3 10 ; print [3, 4, 5, 6, 7, 8, 9]
 PRINT RANGE 3 10 3 ; print [3, 6, 9]
 
 FOR i in RANGE 10 50 10 [ ; loop for [10, 20, 30, 40]
   FORWARD i
   LEFT 90
 ]
+LIST + ; remove the repeating elements of a list using set and list conversion
 PRINT LIST (SET [1, 3, 5, 5, 2, 1]) ; print [1, 3, 5, 2]
+TUPLE +Conversion to Python tuple (non-modifiable list) + PRINT TUPLE [4, 5]
+SORTED +It returns with a sorted list. + PRINT SORTED [5, 1, 3, 4] ; print [1, 3, 4, 5]
+SUB +Substitue character sequences using regex (regular expression) patterns. + PRINT SUB (“t”, “T”, “text”) ; print “Text”, replacing “t” with “T”
 PRINT SUB (“(.)”, “\\1\\1”, “text”) ; print “tteexxtt”, doubling every characters
+SEARCH +Search character sequences patterns using regex patterns. + IF SEARCH (“\w”, word) [ PRINT “Letter in the word.” ]
+FINDALL +Find all character sequences in the input string matching the given regex pattern. + PRINT FINDALL(“\w+”, “Dogs, cats.”) ; print [“Dogs”, “cats”], the list of the words.
+MIN + PRINT MIN [1, 2, 3] ; print 1, the lowest element of the list
+MAX + PRINT MAX [1, 2, 3] ; print 3, the greatest element of the list
+Color constants + PENCOLOR “SILVER” ; set by name
 PENCOLOR [1] ; set by identifiers
 PENCOLOR “~SILVER” ; random silver color
 
+ +Identifier +Name + +0 +BLACK + +1 +SILVER + +2 +GRAY/GREY + +3 +WHITE + +4 +MAROON + +5 +RED + +6 +PURPLE + +7 +FUCHSIA/MAGENTA + +8 +GREEN + +9 +LIME + +10 +OLIVE + +11 +YELLOW + +12 +NAVY + +13 +BLUE + +14 +TEAL + +15 +AQUA + +16 +PINK + +17 +TOMATO + +18 +ORANGE + +19 +GOLD + +20 +VIOLET + +21 +SKYBLUE + +22 +CHOCOLATE + +23 +BROWN + +24 +INVISIBLE +
+
diff --git a/librelogo/source/help/en-US/help.tree b/librelogo/source/help/en-US/help.tree new file mode 100644 index 000000000000..10d79ef2958a --- /dev/null +++ b/librelogo/source/help/en-US/help.tree @@ -0,0 +1,18 @@ + + + + + + + + LibreLogo + + + diff --git a/librelogo/source/help/en-US/tree_strings.xhp b/librelogo/source/help/en-US/tree_strings.xhp new file mode 100644 index 000000000000..b56e4ffe200c --- /dev/null +++ b/librelogo/source/help/en-US/tree_strings.xhp @@ -0,0 +1,29 @@ + + + + + + + + Note to translators: + /mediawiki/help/treestrings.xhp + + + + + This file contains extra strings for the contents (*.tree) files. No indexing! + + File: help.tree + <help_section application="swriter" id="02" title="LibreLogo"> + <node id="0225" title="LibreLogo"> + + + + diff --git a/librelogo/source/icons/lc_arrowshapes.circular-arrow.png b/librelogo/source/icons/lc_arrowshapes.circular-arrow.png new file mode 100644 index 000000000000..b7a5a9258ca7 Binary files /dev/null and b/librelogo/source/icons/lc_arrowshapes.circular-arrow.png differ diff --git a/librelogo/source/icons/lc_arrowshapes.circular-leftarrow.png b/librelogo/source/icons/lc_arrowshapes.circular-leftarrow.png new file mode 100644 index 000000000000..ad2197838ca7 Binary files /dev/null and b/librelogo/source/icons/lc_arrowshapes.circular-leftarrow.png differ diff --git a/librelogo/source/icons/lc_arrowshapes.down-arrow.png b/librelogo/source/icons/lc_arrowshapes.down-arrow.png new file mode 100644 index 000000000000..d3b81b9f6446 Binary files /dev/null and b/librelogo/source/icons/lc_arrowshapes.down-arrow.png differ diff --git a/librelogo/source/icons/lc_arrowshapes.up-arrow.png b/librelogo/source/icons/lc_arrowshapes.up-arrow.png new file mode 100644 index 000000000000..6ae84abe8376 Binary files /dev/null and b/librelogo/source/icons/lc_arrowshapes.up-arrow.png differ diff --git a/librelogo/source/icons/lc_basicstop.png b/librelogo/source/icons/lc_basicstop.png new file mode 100644 index 000000000000..ab9bddb4a98b Binary files /dev/null and b/librelogo/source/icons/lc_basicstop.png differ diff --git a/librelogo/source/icons/lc_editglossary.png b/librelogo/source/icons/lc_editglossary.png new file mode 100644 index 000000000000..fcba68f1feb5 Binary files /dev/null and b/librelogo/source/icons/lc_editglossary.png differ diff --git a/librelogo/source/icons/lc_navigationbarleft.png b/librelogo/source/icons/lc_navigationbarleft.png new file mode 100644 index 000000000000..7e69c8045fbe Binary files /dev/null and b/librelogo/source/icons/lc_navigationbarleft.png differ diff --git a/librelogo/source/icons/lc_newdoc.png b/librelogo/source/icons/lc_newdoc.png new file mode 100644 index 000000000000..8e18798acdb2 Binary files /dev/null and b/librelogo/source/icons/lc_newdoc.png differ diff --git a/librelogo/source/icons/lc_runbasic.png b/librelogo/source/icons/lc_runbasic.png new file mode 100644 index 000000000000..da2d9d97badf Binary files /dev/null and b/librelogo/source/icons/lc_runbasic.png differ diff --git a/librelogo/source/icons/sc_arrowshapes.circular-arrow.png b/librelogo/source/icons/sc_arrowshapes.circular-arrow.png new file mode 100644 index 000000000000..35a5e9719607 Binary files /dev/null and b/librelogo/source/icons/sc_arrowshapes.circular-arrow.png differ diff --git a/librelogo/source/icons/sc_arrowshapes.circular-leftarrow.png b/librelogo/source/icons/sc_arrowshapes.circular-leftarrow.png new file mode 100644 index 000000000000..62eeee65fba4 Binary files /dev/null and b/librelogo/source/icons/sc_arrowshapes.circular-leftarrow.png differ diff --git a/librelogo/source/icons/sc_arrowshapes.down-arrow.png b/librelogo/source/icons/sc_arrowshapes.down-arrow.png new file mode 100644 index 000000000000..7290cae2f1c4 Binary files /dev/null and b/librelogo/source/icons/sc_arrowshapes.down-arrow.png differ diff --git a/librelogo/source/icons/sc_arrowshapes.up-arrow.png b/librelogo/source/icons/sc_arrowshapes.up-arrow.png new file mode 100644 index 000000000000..5f9bcc197f81 Binary files /dev/null and b/librelogo/source/icons/sc_arrowshapes.up-arrow.png differ diff --git a/librelogo/source/icons/sc_basicstop.png b/librelogo/source/icons/sc_basicstop.png new file mode 100644 index 000000000000..1c6ff922a786 Binary files /dev/null and b/librelogo/source/icons/sc_basicstop.png differ diff --git a/librelogo/source/icons/sc_editglossary.png b/librelogo/source/icons/sc_editglossary.png new file mode 100644 index 000000000000..4e14c031a4ae Binary files /dev/null and b/librelogo/source/icons/sc_editglossary.png differ diff --git a/librelogo/source/icons/sc_navigationbarleft.png b/librelogo/source/icons/sc_navigationbarleft.png new file mode 100644 index 000000000000..e544a7581f33 Binary files /dev/null and b/librelogo/source/icons/sc_navigationbarleft.png differ diff --git a/librelogo/source/icons/sc_newdoc.png b/librelogo/source/icons/sc_newdoc.png new file mode 100644 index 000000000000..e914775a2693 Binary files /dev/null and b/librelogo/source/icons/sc_newdoc.png differ diff --git a/librelogo/source/icons/sc_runbasic.png b/librelogo/source/icons/sc_runbasic.png new file mode 100644 index 000000000000..8dd695c1e767 Binary files /dev/null and b/librelogo/source/icons/sc_runbasic.png differ diff --git a/librelogo/source/pythonpath/LibreLogo_en_US.properties b/librelogo/source/pythonpath/LibreLogo_en_US.properties new file mode 100644 index 000000000000..f9a0d0b87ee6 --- /dev/null +++ b/librelogo/source/pythonpath/LibreLogo_en_US.properties @@ -0,0 +1,151 @@ +# turtle graphics + +FORWARD=forward|fd +BACKWARD=back|bk +TURNLEFT=left|turnleft|lt +TURNRIGHT=right|turnright|rt +PENUP=penup|pu +PENDOWN=pendown|pd +HOME=home +POINT=point +CIRCLE=circle +ELLIPSE=ellipse +SQUARE=square +RECTANGLE=rectangle +LABEL=label +PENCOLOR=pencolor|pencolour|linecolor|pc +ANY=any +PENWIDTH=pensize|penwidth|linewidth|ps +PENSTYLE=penstyle|linestyle +PENJOINT=penjoint|linejoint +NONE=none +BEVEL=bevel +MITER=miter +ROUNDED=round +SOLID=solid +DASH=dashed +DOTTED=dotted +CLOSE=close +FILL=fill +FILLCOLOR=fillcolor|fillcolour|fc +FILLSTYLE=fillstyle +FONTCOLOR=fontcolor|textcolor|textcolour +FONTHEIGHT=fontsize|textsize|textheight +FONTWEIGHT=fontweight +FONTSTYLE=fontstyle +BOLD=bold +ITALIC=italic +UPRIGHT=upright|normal +NORMAL=normal +FONTFAMILY=fontfamily +CLEARSCREEN=clearscreen|cs +TEXT=text +HIDETURTLE=hideturtle|ht|hideme +SHOWTURTLE=showturtle|st|showme +POSITION=position|pos|setpos +HEADING=heading|setheading|seth +PAGESIZE=pagesize +GROUP=picture|pic + +# control structures + +TO=to +END=end +STOP=stop +REPEAT=repeat|forever +REPCOUNT=repcount +BREAK=break +CONTINUE=continue +WHILE=while +FOR=for +IN=in +IF=if +OUTPUT=output +LEFTSTRING=\u201c|\u2018 +RIGHTSTRING=\u201d|\u2019 +TRUE=true +FALSE=false +NOT=not +AND=and +OR=or +INPUT=input +PRINT=print +SLEEP=sleep +GLOBAL=global + +# functions +RANDOM=random +INT=int +FLOAT=float +STR=str +SQRT=sqrt +SIN=sin +COS=cos +ROUND=round +ABS=abs +COUNT=count +SET=set +RANGE=range +LIST=list +TUPLE=tuple +SORTED=sorted +RESUB=sub +RESEARCH=search +REFINDALL=findall +MIN=min +MAX=max + +PI=pi|\u03c0 + +# measurement +DECIMAL=. +DEG=\u00b0 +HOUR=h +MM=mm +CM=cm +PT=pt +INCH=in|" + +# color codes + +INVISIBLE=invisible +BLACK=black +SILVER=silver +GRAY=gray|grey +WHITE=white +MAROON=maroon +RED=red +PURPLE=purple +FUCHSIA=fuchsia|magenta +GREEN=green +LIME=lime +OLIVE=olive +YELLOW=yellow +NAVY=navy +BLUE=blue +TEAL=teal +AQUA=aqua|cyan +PINK=pink +TOMATO=tomato +ORANGE=orange +GOLD=gold +VIOLET=violet +SKYBLUE=skyblue +CHOCOLATE=chocolate +BROWN=brown + +# messages + +LIBRELOGO=LibreLogo +ERROR=Error (in line %s) +ERR_ZERODIVISION=Division by zero. +ERR_NAME=Unknown name: \u2018%s\u201d. +ERR_ARGUMENTS=%s takes %s arguments (%s given). +ERR_BLOCK=Error (extra or missing spaces at brackets?) +ERR_KEY=Unknown element: %s +ERR_INDEX=Index out of range. + +ERR_STOP=Program terminated: +ERR_MAXRECURSION=maximum recursion depth (%d) exceeded. +ERR_MEMORY=not enough memory. +ERR_NOTAPROGRAM=Do you want to run this text document? diff --git a/librelogo/source/pythonpath/librelogodummy_path.py b/librelogo/source/pythonpath/librelogodummy_path.py new file mode 100644 index 000000000000..f600a162b1cf --- /dev/null +++ b/librelogo/source/pythonpath/librelogodummy_path.py @@ -0,0 +1,3 @@ +import uno, re, sys, os, traceback +def get_path(): + return os.path.join(os.path.dirname(sys.modules[__name__].__file__), __name__ + ".py") diff --git a/librelogo/source/registry/data/org/openoffice/Office/Addons.xcu b/librelogo/source/registry/data/org/openoffice/Office/Addons.xcu new file mode 100644 index 000000000000..3ad52bbc0eb9 --- /dev/null +++ b/librelogo/source/registry/data/org/openoffice/Office/Addons.xcu @@ -0,0 +1,286 @@ + + + + + + + + com.sun.star.text.TextDocument + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$goforward?language=Python&location=user:uno_packages + + + Forward + + + _self + + + + + com.sun.star.text.TextDocument + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$gobackward?language=Python&location=user:uno_packages + + + Back + + + _self + + + + + com.sun.star.text.TextDocument + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$left?language=Python&location=user:uno_packages + + + Left + + + _self + + + + + com.sun.star.text.TextDocument + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$right?language=Python&location=user:uno_packages + + + Right + + + _self + + + + + com.sun.star.text.TextDocument + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$run?language=Python&location=user:uno_packages + + + Start (the program in the Writer document) + + + _self + + + + + com.sun.star.text.TextDocument + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$stop?language=Python&location=user:uno_packages + + + Stop + + + _self + + + + + com.sun.star.text.TextDocument + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$home?language=Python&location=user:uno_packages + + + Home + + + _self + + + + + com.sun.star.text.TextDocument + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$clearscreen?language=Python&location=user:uno_packages + + + Clear screen + + + _self + + + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$commandline?language=Python&location=user:uno_packages + + + FORWARD (fd), BACK (bk), LEFT (lt), RIGHT (rt) • fd 72, bk 1cm + 1in + 1", lt 90, rt 1.5h +REPEAT num [ commands ], REPCOUNT • repeat 100 [ fd repcount lt 91 ] +PENUP (pu), PENDOWN (pd), FILL, CLOSE, HOME, CLEARSCREEN (cs), PENSIZE (ps 5) +PENCOLOR (pc), FILLCOLOR (fc) • pc “red”, pc 0xff0000, fc [255, 0, 0], fc any +POSITION (pos), HEADING (seth) • pos [0, 0], pos pagesize, seth 60, seth [0, 0] +CIRCLE, ELLIPSE, BOX, RECTANGLE • circle 10 ellipse [5, 9] box 10 rectangle [5, 2] +LABEL, TEXT, PRINT • label “Some text”, circle 200 text “center of the actual shape” +FONTFAMILY “Font” FONTSIZE 9 FONTCOLOR “red” FONTWEIGHT “bold” +TO name arguments ... END, TO name arguments, OUTPUT return_value, END +RANDOM, SQRT, INT, COUNT, ABS, SIN, COS, INPUT • ps random 100, print count “string” +PICTURE (pic) [ ... ] • group different shapes: pic [ fd 100 circle 50 ] + + + _self + + + com.sun.star.text.TextDocument + + + Editfield + + + 300 + + + + + com.sun.star.text.TextDocument + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$__translate__?language=Python&location=user:uno_packages + + + Uppercase commands, also translate them to the language of the document + + + _self + + + + + + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$goforward?language=Python&location=user:uno_packages + + + + %origin%/icons/sc_arrowshapes.up-arrow.png + + + %origin%/icons/lc_arrowshapes.up-arrow.png + + + + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$gobackward?language=Python&location=user:uno_packages + + + + %origin%/icons/sc_arrowshapes.down-arrow.png + + + %origin%/icons/lc_arrowshapes.down-arrow.png + + + + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$left?language=Python&location=user:uno_packages + + + + %origin%/icons/sc_arrowshapes.circular-leftarrow.png + + + %origin%/icons/lc_arrowshapes.circular-leftarrow.png + + + + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$right?language=Python&location=user:uno_packages + + + + %origin%/icons/sc_arrowshapes.circular-arrow.png + + + %origin%/icons/lc_arrowshapes.circular-arrow.png + + + + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$run?language=Python&location=user:uno_packages + + + + %origin%/icons/sc_runbasic.png + + + %origin%/icons/lc_runbasic.png + + + + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$stop?language=Python&location=user:uno_packages + + + + %origin%/icons/sc_basicstop.png + + + %origin%/icons/lc_basicstop.png + + + + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$home?language=Python&location=user:uno_packages + + + + %origin%/icons/sc_navigationbarleft.png + + + %origin%/icons/lc_navigationbarleft.png + + + + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$clearscreen?language=Python&location=user:uno_packages + + + + %origin%/icons/sc_newdoc.png + + + %origin%/icons/lc_newdoc.png + + + + + + vnd.sun.star.script:librelogo-0.2.oxt|LibreLogo|LibreLogo.py$__translate__?language=Python&location=user:uno_packages + + + + %origin%/icons/sc_editglossary.png + + + %origin%/icons/lc_editglossary.png + + + + + + + + diff --git a/librelogo/source/registry/data/org/openoffice/Office/UI/StartModuleWindowState.xcu b/librelogo/source/registry/data/org/openoffice/Office/UI/StartModuleWindowState.xcu new file mode 100644 index 000000000000..4fb8fd9ae34f --- /dev/null +++ b/librelogo/source/registry/data/org/openoffice/Office/UI/StartModuleWindowState.xcu @@ -0,0 +1,18 @@ + + + + + + + Logo + + + false + + + false + + + + + diff --git a/librelogo/source/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu b/librelogo/source/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu new file mode 100644 index 000000000000..3a37baaac011 --- /dev/null +++ b/librelogo/source/registry/data/org/openoffice/Office/UI/WriterWindowState.xcu @@ -0,0 +1,18 @@ + + + + + + + Logo + + + false + + + false + + + + + -- cgit