[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - 2 commits - scripting/examples scripting/Package_ScriptsPython.mk scripting/source
Tor Lillqvist
tml at collabora.com
Tue Apr 3 14:36:43 UTC 2018
scripting/Package_ScriptsPython.mk | 1 +
scripting/examples/python/SetCellColor.py | 15 +++++++++++++++
scripting/source/protocolhandler/scripthandler.cxx | 10 ++++++----
3 files changed, 22 insertions(+), 4 deletions(-)
New commits:
commit dfd437bef970478f1683be2abf7e0ad55f3cf5ab
Author: Tor Lillqvist <tml at collabora.com>
Date: Thu Jan 18 18:27:50 2018 +0200
Add another sample Python script
Change-Id: I542a8b36a097d8961dc76fdcc3d25a3d7b6eb526
Reviewed-on: https://gerrit.libreoffice.org/51966
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Tor Lillqvist <tml at collabora.com>
(cherry picked from commit aa27a25d152ab70f60fedcea3bd4cd99d68103a0)
Reviewed-on: https://gerrit.libreoffice.org/52090
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>
Reviewed-on: https://gerrit.libreoffice.org/52313
diff --git a/scripting/Package_ScriptsPython.mk b/scripting/Package_ScriptsPython.mk
index 1d0de559bd20..8cc8a85472ff 100644
--- a/scripting/Package_ScriptsPython.mk
+++ b/scripting/Package_ScriptsPython.mk
@@ -12,6 +12,7 @@ $(eval $(call gb_Package_Package,scripting_ScriptsPython,$(SRCDIR)/scripting/exa
$(eval $(call gb_Package_add_files_with_dir,scripting_ScriptsPython,$(LIBO_SHARE_FOLDER)/Scripts,\
python/Capitalise.py \
python/HelloWorld.py \
+ python/SetCellColor.py \
python/pythonSamples/TableSample.py \
))
diff --git a/scripting/examples/python/SetCellColor.py b/scripting/examples/python/SetCellColor.py
new file mode 100644
index 000000000000..743a6daa948b
--- /dev/null
+++ b/scripting/examples/python/SetCellColor.py
@@ -0,0 +1,15 @@
+def SetCellColor(x, y, color):
+ """Sets the background of the cell at (x,y) (zero-based column and row
+ indices, for example (2,3) == C4) on the first sheet and
+ returns the contents of the cell as a string.
+ """
+ #get the doc from the scripting context which is made available to all scripts
+ desktop = XSCRIPTCONTEXT.getDesktop()
+ model = desktop.getCurrentComponent()
+ #check whether there's already an opened document
+ if not hasattr(model, "Sheets"):
+ return ""
+ sheet = model.Sheets.Sheet1
+ cell = sheet.getCellByPosition(x, y)
+ cell.CellBackColor = color
+ return cell.String
commit 02ebdf3146d582f7b6c9e3b91d7c2baab4a5fadd
Author: Tor Lillqvist <tml at collabora.com>
Date: Fri Jan 12 14:16:51 2018 +0200
Filter out "SynchronMode" too
Change-Id: I2c5111ee34929b9740796f5e1f08b3a8a58218e4
Reviewed-on: https://gerrit.libreoffice.org/51964
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Tor Lillqvist <tml at collabora.com>
(cherry picked from commit 2147cbf6204ebca8fb5a306ad5d81215b1175ac2)
Reviewed-on: https://gerrit.libreoffice.org/52089
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>
Reviewed-on: https://gerrit.libreoffice.org/52312
diff --git a/scripting/source/protocolhandler/scripthandler.cxx b/scripting/source/protocolhandler/scripthandler.cxx
index cf125b3ac84d..6aaa2055bd90 100644
--- a/scripting/source/protocolhandler/scripthandler.cxx
+++ b/scripting/source/protocolhandler/scripthandler.cxx
@@ -186,10 +186,12 @@ void SAL_CALL ScriptProtocolHandler::dispatchWithNotification(
int argCount = 0;
for ( int index = 0; index < lArgs.getLength(); index++ )
{
- // Sometimes we get a propertyval with name = "Referer"
- // this is not an argument to be passed to script, so
- // ignore.
- if ( lArgs[ index ].Name != "Referer" ||
+ // Sometimes we get a propertyval with name = "Referer" or "SynchronMode". These
+ // are not actual arguments to be passed to script, but flags describing the
+ // call, so ignore. Who thought that passing such "meta-arguments" mixed in with
+ // real arguments was a good idea?
+ if ( (lArgs[ index ].Name != "Referer" &&
+ lArgs[ index ].Name != "SynchronMode") ||
lArgs[ index ].Name.isEmpty() ) //TODO:???
{
inArgs.realloc( ++argCount );
More information about the Libreoffice-commits
mailing list