Skip to content

Commit 202832c

Browse files
committed
Adding new shortcut functiojn
1 parent f69f65a commit 202832c

File tree

6 files changed

+37
-5
lines changed

6 files changed

+37
-5
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ Combine the power of clojure with all the LibreOffice calc features!!!
44

55
ClojureCalc is a wrapper for clojure 1.6 on libre office and possibly open office.
66

7-
To install use [ClojureCalc.oxt](https://github.com/beothorn/ClojureCalc/releases/download/1.0.0/ClojureCalc.oxt)
7+
To install use [ClojureCalc.oxt](https://github.com/beothorn/ClojureCalc/releases/download/1.1.0/ClojureCalc.oxt)
88

99
Usage
1010
====================
1111

12+
=c( string with a clojure function, without wrapping parenthesis )
1213
=clj( string with a clojure expression )
1314
=cljcol( cell range to convert to a clojure collection )
1415

1516
Note: Three single quotes are replaced by a double quote
1617

17-
![screenshot](http://i.imgur.com/93UZ7qq.png "Really cool example")
18+
![screenshot](http://i.imgur.com/ePwRK5O.png "Really cool example")
1819

1920
Examples
2021
====================

registry/data/org/openoffice/Office/CalcAddins.xcu

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,31 @@
2929
</node>
3030
</node>
3131
</node>
32+
<node oor:name="c" oor:op="replace">
33+
<prop oor:name="DisplayName">
34+
<value xml:lang="en">c</value>
35+
</prop>
36+
<prop oor:name="Description">
37+
Evaluates a clojure expression, automatically wraps the expression with parenthesis
38+
<value/>
39+
</prop>
40+
<prop oor:name="Category">
41+
<value>Add-In</value>
42+
</prop>
43+
<prop oor:name="CompatibilityName">
44+
<value/>
45+
</prop>
46+
<node oor:name="Parameters">
47+
<node oor:name="exp" oor:op="replace">
48+
<prop oor:name="DisplayName">
49+
<value xml:lang="en">A clojure expression to be evaluated, ''' (three single quotes) are replaced by a double quote </value>
50+
</prop>
51+
<prop oor:name="Description">
52+
<value/>
53+
</prop>
54+
</node>
55+
</node>
56+
</node>
3257
<node oor:name="cljcol" oor:op="replace">
3358
<prop oor:name="DisplayName">
3459
<value xml:lang="en">cljcol</value>

src/com/github/beothorn/clojurecalc/ClojureCalcImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ public String clj(String exp)
7878
return ClojureInterpreter.runClojure(exp);
7979
}
8080

81+
public String c(String exp)
82+
{
83+
if(exp.trim().equals("")) return "";
84+
return ClojureInterpreter.runClojure("("+exp+")");
85+
}
86+
8187
public String cljcol(String[][] cells){
8288
return ClojureInterpreter.toClojureCollection(cells);
8389
}

src/com/github/beothorn/clojurecalc/ClojureInterpreter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ private static String getLine(final String[] line) {
3333
}
3434

3535
public static String runClojure(String clojureExpression){
36-
if(clojureExpression.equals("")) return "";
36+
if(clojureExpression.trim().equals("")) return "";
3737
String exp = clojureExpression.replaceAll("'''", "\"");
3838
String result;
3939
ClassLoader previous = Thread.currentThread().getContextClassLoader();

src/com/github/beothorn/clojurecalc/XClojureCalc.idl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module com { module github { module beothorn { module clojurecalc {
2121
[optional] interface ::com::sun::star::lang::XLocalizable;
2222

2323
string clj([in] string exp);
24-
24+
string c([in] string exp);
2525
string cljcol([in] sequence< sequence< string > > cells);
2626
};
2727
}; }; }; };

src/description.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--Created with Apache OpenOffice API plug-in for NetBeans Version 2.0.6.000205-->
33
<description xmlns="http://openoffice.org/extensions/description/2006" xmlns:xlink="http://www.w3.org/1999/xlink">
4-
<version value="1.0.0"/>
4+
<version value="1.1.0"/>
55
<identifier value="com.github.beothorn.clojurecalc.ClojureCalc"/>
66
</description>

0 commit comments

Comments
 (0)