[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice/kword/plugins/scripting
From: Sebastian Sauer <mail () dipe ! org>
Date: 2007-03-11 18:53:04
Message-ID: 1173639184.211261.12425.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 641548 by sebsauer:
* added Tool class to deal with KoTool related functionality.
* added sample_toolactions.py sample script that demonstrates the usage.
M +1 -0 CMakeLists.txt
M +3 -40 Module.cpp
M +4 -5 Module.h
A Tool.h [License: LGPL (v2+)]
M +1 -0 scripts/CMakeLists.txt
A scripts/sample_toolactions.py
M +6 -0 scripts/scripts.rc
--- trunk/koffice/kword/plugins/scripting/CMakeLists.txt #641547:641548
@@ -18,6 +18,7 @@
Style.h
TextDocument.h TextFrame.h TextList.h TextTable.h
Frame.h FrameSet.h
+ Tool.h
Variable.h
)
--- trunk/koffice/kword/plugins/scripting/Module.cpp #641547:641548
@@ -23,26 +23,18 @@
#include "PageLayout.h"
#include "FrameSet.h"
#include "Style.h"
+#include "Tool.h"
// qt
#include <QPointer>
-//#include <QApplication>
// kde
#include <kdebug.h>
-//#include <kmainwindow.h>
-// koffice
-//#include <KoMainWindow.h>
-//#include <KoApplicationAdaptor.h>
-//#include <KoDocumentAdaptor.h>
-#include <KoToolProxy.h>
-#include <KoTextSelectionHandler.h>
// kword
#include <KWDocument.h>
#include <KWView.h>
#include <KWPage.h>
#include <KWFrameSet.h>
#include <KWFrame.h>
-#include <KWCanvas.h>
extern "C"
{
@@ -266,38 +258,9 @@
return new Style(this, s);
}
-QObject* Module::activeCursor()
+QObject* Module::tool()
{
- KWView* v = dynamic_cast< KWView* >( view() );
- KWCanvas* c = v ? v->kwcanvas() : 0;
- KoToolProxy* t = c ? c->toolProxy() : 0;
- KoToolSelection* s = t ? t->selection() : 0;
- KoTextSelectionHandler* h = dynamic_cast< KoTextSelectionHandler* >(s);
- if( ! h ) {
- kDebug() << "Scripting::Module::currentCursor() Failed to determinate the \
active selection" << endl;
- return 0;
- }
- return new TextCursor(this, h->caret());
+ return new Tool(this);
}
-bool Module::setActiveCursor(QObject* cursor)
-{
- TextCursor* textcursor = dynamic_cast< TextCursor* >(cursor);
- if( ! textcursor ) {
- kDebug() << "Scripting::Module::setActiveCursor() Invalid TextCursor \
argument passed" << endl;
- return false;
- }
- KWView* v = dynamic_cast< KWView* >( view() );
- KWCanvas* c = v ? v->kwcanvas() : 0;
- KoCanvasResourceProvider* r = c ? c->resourceProvider() : 0;
- if( ! r ) {
- kDebug() << "Scripting::Module::setActiveCursor() Failed to determinate the \
active selection" << endl;
- return false;
- }
- QVariant variant;
- variant.setValue( (QObject*) &textcursor->cursor() );
- r->setResource(KWord::CurrentTextCursor, variant);
- return true;
-}
-
#include "Module.moc"
--- trunk/koffice/kword/plugins/scripting/Module.h #641547:641548
@@ -180,12 +180,11 @@
/** Add and return a new paragraph \a Style object. */
QObject* addParagraphStyle(const QString& name);
- /***** Active *****/
+ /***** Active selection *****/
- /** Return the active/current \a TextCursor object. */
- QObject* activeCursor();
- /** Set the active/current \a TextCursor object. */
- bool setActiveCursor(QObject* cursor);
+ /** Return a \a Tool object that provides access to functionality
+ like handling for example current/active selections. */
+ QObject* tool();
private:
/// \internal d-pointer class.
--- trunk/koffice/kword/plugins/scripting/scripts/CMakeLists.txt #641547:641548
@@ -10,6 +10,7 @@
sample_doctree.rb
sample_cursor.rb
sample_actions.py
+ sample_toolactions.py
sample_progressbar.py
sample_text.py
sample_lists_html.py
--- trunk/koffice/kword/plugins/scripting/scripts/scripts.rc #641547:641548
@@ -79,6 +79,12 @@
interpreter="python"
file="extensions/sample_actions.py" />
<script
+ name="pysampletoolactions"
+ text="Tool Actions..."
+ comment="Python script that demonstrates usage of tool actions"
+ interpreter="python"
+ file="extensions/sample_toolactions.py" />
+ <script
name="pysampleprogressbar"
text="Progressbar"
comment="Python script that demonstrates how to use the progressbar"
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic