[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice
From: Sebastian Sauer <mail () dipe ! org>
Date: 2006-11-15 14:51:36
Message-ID: 1163602296.784256.20423.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 605139 by sebsauer:
dox++
M +4 -4 kspread/plugins/scripting/ScriptingFunction.cpp
M +7 -1 kspread/plugins/scripting/ScriptingFunction.h
M +1 -1 kspread/plugins/scripting/ScriptingModule.cpp
M +4 -1 kspread/plugins/scripting/ScriptingModule.h
M +1 -1 kspread/plugins/scripting/ScriptingPart.cpp
M +2 -0 kspread/plugins/scripting/ScriptingPart.h
M +50 -9 kspread/plugins/scripting/readme.dox
M +8 -5 kspread/plugins/scripting/scripts/functions.py
M +1 -1 libs/kross/core/guiclient.cpp
--- trunk/koffice/kspread/plugins/scripting/ScriptingFunction.cpp #605138:605139
@@ -50,7 +50,7 @@
Q_ASSERT(extra && extra->function);
ScriptingFunctionImpl* funcimpl = static_cast< ScriptingFunctionImpl* >( \
extra->function );
-kDebug() << "ScriptingFunctionImpl::callback \
###########################################" << endl; + kDebug() << \
"ScriptingFunctionImpl::callback" << endl;
if( ! funcimpl->m_function) {
kDebug() << QString("ScriptingFunctionImpl::callback \
ScriptingFunction instance is NULL.") << endl; @@ -141,14 +141,14 @@
: QObject(parent)
, d(new Private())
{
- kDebug() << "..................ScriptingFunction::ScriptingFunction" << endl;
+ kDebug() << "ScriptingFunction::ScriptingFunction" << endl;
d->funcElement = d->document.createElement("Function");
d->helpElement = d->document.createElement("Help");
}
ScriptingFunction::~ScriptingFunction()
{
- kDebug() << "..................ScriptingFunction::~ScriptingFunction" << endl;
+ kDebug() << "ScriptingFunction::~ScriptingFunction" << endl;
delete d;
}
@@ -186,7 +186,7 @@
bool ScriptingFunction::registerFunction()
{
- kDebug() << "..................ScriptingFunction::registerFunction" << endl;
+ kDebug() << "ScriptingFunction::registerFunction" << endl;
if( d->name.isEmpty() ) {
kWarning() << "ScriptingFunction::registerFunction() name is empty!" << \
endl;
--- trunk/koffice/kspread/plugins/scripting/ScriptingFunction.h #605138:605139
@@ -26,7 +26,11 @@
/**
* The ScriptingFunction class provides access to the KSpread::Function
- * functionality to deal with formula functions.
+ * functionality to deal with formula functions that are written in
+ * a scripting language like Python or Ruby.
+ *
+ * For an example how to use scripted formula functions see;
+ * \see http://websvn.kde.org/trunk/koffice/kspread/plugins/scripting/scripts/functions.py?&view=markup
*/
class ScriptingFunction : public QObject
{
@@ -65,7 +69,9 @@
void called(QVariantList args);
private:
+ /// \internal d-pointer class.
class Private;
+ /// \internal d-pointer instance.
Private* const d;
};
--- trunk/koffice/kspread/plugins/scripting/ScriptingModule.cpp #605138:605139
@@ -65,7 +65,7 @@
ScriptingModule::~ScriptingModule()
{
- kDebug() << "...................ScriptingModule::~ScriptingModule()" << endl;
+ kDebug() << "ScriptingModule::~ScriptingModule()" << endl;
delete d;
}
--- trunk/koffice/kspread/plugins/scripting/ScriptingModule.h #605138:605139
@@ -115,13 +115,16 @@
*/
QString toXML();
- bool openUrl(const QString& url);
+ //do we need them anyway or is it enough to use KoDocument here?!
+ bool openUrl(const QString& url);
bool saveUrl(const QString& url);
bool importUrl(const QString& url);
bool exportUrl(const QString& url);
private:
+ /// \internal d-pointer class.
class Private;
+ /// \internal d-pointer instance.
Private* const d;
};
--- trunk/koffice/kspread/plugins/scripting/ScriptingPart.cpp #605138:605139
@@ -126,7 +126,7 @@
ScriptingPart::~ScriptingPart()
{
- kDebug() << "..................ScriptingPart::~ScriptingPart()" << endl;
+ kDebug() << "ScriptingPart::~ScriptingPart()" << endl;
delete d;
}
--- trunk/koffice/kspread/plugins/scripting/ScriptingPart.h #605138:605139
@@ -38,7 +38,9 @@
virtual ~ScriptingPart();
private:
+ /// \internal d-pointer class.
class Private;
+ /// \internal d-pointer instance.
Private* const d;
};
--- trunk/koffice/kspread/plugins/scripting/readme.dox #605138:605139
@@ -10,6 +10,9 @@
* to integrate scripting into KSpread.
* The \a ScriptingModule class enables access to the KSpread
* functionality from within the scripting backends.
+* The \a ScriptingFunction class provides access to the KSpread::Function
+* functionality to deal with formula functions that are written in
+* a scripting language like Python or Ruby.
*
* \see http://www.koffice.org/kspread
* \see http://kross.dipe.org
@@ -18,18 +21,56 @@
*
* @section Examples
*
-* Python example to uppercase a sheetname;
+* Python example to write content of a sheet to stdout;
* @code
-* # Import the KSpread module.
-* import KSpread
-* # Print a list of avaible sheets.
-* print KSpread.sheetNames()
-* # Get the current sheet.
-* sheet = KSpread.currentSheet()
-* # Change the name of the current sheet to uppercase.
-* sheet.setSheetName( str( sheet.name() ).upper() )
+* #!/usr/bin/env kross
+* # The OpenDocument Spreadsheet file that we like to read.
+* filename = "/home/kde4/invoicetemplate.ods"
+* # Import Kross and fetch the KSpread module.
+* import Kross
+* kspread = Kross.module("kspread")
+* # Try to open the file.
+* if not kspread.openUrl(filename):
+* raise "Failed to open the file \"%s\"." % filename
+* # Get the sheet we like to print to stdout.
+* sheet = kspread.sheetByName( kspread.sheetNames()[0] )
+* # Iterate now through all cells on the sheet.
+* for row in range(sheet.maxRow()):
+* # Put the content of the row into the record-list.
+* record = []
+* for col in range(sheet.maxColumn(), 0, -1):
+* value = sheet.text(col, row)
+* if value or len(record) > 0:
+* record.insert(0,value)
+* # If the record has at least one cell print it.
+* if len(record) > 0:
+* print record
* @endcode
*
+* Python example to read template, set content and write new file;
+* @code
+* #!/usr/bin/env kross
+* # The OpenDocument Spreadsheet file that we like to read from.
+* templatefile = "/home/kde4/invoicetemplate.ods"
+* # The OpenDocument Spreadsheet file that we like to write to.
+* savefile = "/home/kde4/invoice.ods"
+* # Import Kross and fetch the KSpread module.
+* import Kross
+* kspread = Kross.module("kspread")
+* # Try to open the file.
+* if not kspread.openUrl(templatefile):
+* raise "Failed to open the file \"%s\"." % templatefile
+* # Get the sheet we like to manipulate.
+* sheet = kspread.sheetByName( kspread.sheetNames()[0] )
+* # Set the content of some cells.
+* sheet.setText(0,7,"Joe User")
+* sheet.setText(0,8,"Userstreet. 1")
+* sheet.setText(0,9,"Testcasecity")
+* # Finally write the new OpenDocument Spreadsheet file.
+* if not kspread.saveUrl(savefile):
+* raise "Failed to save the file \"%s\"." % savefile
+* @endcode
+*
***************************************************************************
*
* @section Legal
--- trunk/koffice/kspread/plugins/scripting/scripts/functions.py #605138:605139
@@ -24,9 +24,14 @@
Dual-licensed under LGPL v2+higher and the BSD license.
"""
-class Setup:
+class Functions:
+ """ The Functions class adds some KSpread formula functions on
+ the fly and provides them to KSpread. """
def __init__(self, scriptaction):
+ """ Some initial work like the import of the Kross and KSpread functionality
+ and test functions are added to demonstrate the usage. """
+
import os, sys
try:
@@ -52,7 +57,7 @@
self.addTestFunctions()
def addTestFunctions(self):
- print "1 ========================================================"
+ """ This method adds a new scripted formula function to KSpread. """
functest1 = self.kspread.function("SCRIPT_TEST1")
functest1.minparam = 1
@@ -72,6 +77,4 @@
functest1.registerFunction()
- print "2 ========================================================"
-
-Setup( self )
+Functions( self )
--- trunk/koffice/libs/kross/core/guiclient.cpp #605138:605139
@@ -90,7 +90,7 @@
GUIClient::~GUIClient()
{
- krossdebug("..........................GUIClient::~GUIClient()");
+ krossdebug("GUIClient::~GUIClient()");
delete d;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic