*String Operations in Calc and Advanced Utilities*
In this post I will deal with some advanced requirements for OOo, which
will ease the writing of powerful external applications for Calc.
1. awk/gawk scripting
2. C++ : need for OOoin/ OOoout (similar to cin/cout, wcin/wcout) and
OOoiostream library
*AWK/GAWK*
OOo Calc has unfortunately a very limited support for string operations.
As detailed in issue 66590
(http://qa.openoffice.org/issues/show_bug.cgi?id=66590), there is no
easy way to work with strings in Calc.
Should advanced string functions be implemented in Calc?
While some may argue that this is the ultimate solution, powerful
alternatives do exist.
It is not always necessary to reinvent the wheel. We may sometimes need
a square wheel, but most often the time proven round wheel is far
better. There is fortunately an open source program that greatly eases
the work with strings.
Gawk (awk) is available both for Unix and Windows (see project gnuwin32
on sourceforge.net). Also, the structure of spreadsheets (rows and
cells) seems particularly suitable for use in gawk. For the full
description of this issue, see
http://qa.openoffice.org/issues/show_bug.cgi?id=66816 .
What I really want is an easy way to run gawk scripts in calc, i.e.:
- Calc should open a bidirectional pipeline to gawk (gawk supports this)
as described in issue 66816
- (advanced: Calc should recognize the shebang line (e.g. #!gawk
-parameters...), and use the correct program, in this case gawk, for the
particular script)
*C++ libraries*
Sometimes we may need a more advanced programing language to solve a
problem. C++ is a good choice in such cases (I do not know java and I
know many who do not know java, either, but still use C++, and I do not
know if java supports pointers and template classes).
However, writing a program which would open a pipeline to Calc is not
trivial. What I really miss is a library that copies the cin/cout
(wcin/wcout) functionality, i.e. an abstraction layer to such a pipeline.
Instead of writing complex code, one would just use
1. OOoin >> 'some variable' // read from OOo
2. OOoout << 'something' // write to OOo
3. #include OOostreams // a library needed to have such functionality
(will need some ?code in OOo?, too, to have this functionality)
That's it. Not complex plugin architecture.
NOTE:
- OOoin should provide access to the currently selected content in Calc
(or other OOo applications)
- OOoout should either overwrite existing selected content or,
alternatively, write to new spreadsheer (writer document)
- how to run:
-- the binary should be compiled in advance
-- open the document (sheet), select content -> some menu item: Run
external program -> select binary -> execute it
*OTHER Programs*
This is not limited to awk/gawk and C++. Actually, there are numerous
other potentially useful languages/utilities that should be supported,
too. While I think that gawk offers pretty fast benefit for string
operations and C++ is a must, others will find utility in many more
programs. So, one could extend this concept in the future to other programs.
ADVANTAGES
============
- there are countless awk/gawk scripts (no need to rewrite everything)
- it is possible to write in a very short time (minutes) a gawk script
to solve a particular problem
- C++ is more powerful, but accessibility to the OOo data stream is
difficult (I have written a number of utilities that copy to/from the
clipboard, BUT this is obviously NOT portable)
-- OOoin/OOoout is more beatiful and simple -> NO need to learn OOo
plugin architecture
- easy creation of powerful plugins by a wide user base
-- everybody knowing some C++ could easily write his own utility
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]