[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: 2006-12-30 22:56:08
Message-ID: 1167519368.043009.28618.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 618050 by sebsauer:
* made Frames a first-row-citizen meaning we provide a list of frames now too.
* allow the FrameSet to be fetched from the Frame.
* fix z-index in sample_shapes.py.
* use the TextRunAround and TextRunAround enums
M +33 -2 Frame.h
M +2 -2 FrameSet.h
M +39 -4 Module.cpp
M +12 -5 Module.h
M +7 -5 scripts/sample_shapes.py
M +3 -2 scripts/sample_text.py
--- trunk/koffice/kword/plugins/scripting/Frame.h #618049:618050
@@ -36,15 +36,46 @@
class Frame : public QObject
{
Q_OBJECT
+ Q_ENUMS(TextRunAround)
+ Q_ENUMS(FrameBehavior)
public:
- Frame(QObject* parent, KWFrame* frame) : QObject(parent), m_frame(frame) \
{} + Frame(QObject* parentFrameSet, KWFrame* frame) : \
QObject(parentFrameSet), m_frame(frame) {} virtual ~Frame() {}
+ enum TextRunAround {
+ NoRunAround = KWord::NoRunAround, ///< The text will be completely \
avoiding the frame by keeping the horizontal space that this frame occupies blank. + \
RunAround = KWord::RunAround, ///< The text will run around the outline of the frame \
+ RunThrough = KWord::RunThrough ///< The text will completely ignore \
the frame and layout as if it was not there + };
+
+ enum FrameBehavior {
+ AutoExtendFrameBehavior = KWord::AutoExtendFrameBehavior, ///< Make \
the frame bigger to fit the contents + AutoCreateNewFrameBehavior = \
KWord::AutoCreateNewFrameBehavior, ///< Create a new frame on the next page + \
IgnoreContentFrameBehavior = KWord::IgnoreContentFrameBehavior ///< Ignore the \
content and clip it + };
+
public Q_SLOTS:
- /** Return the Id of this shape, indentifying the type of shape by the \
id of the factory. */ + /** Return the Id of this shape, identifying the \
type of shape by the id of the factory. */
QString shapeId() const { return m_frame->shape()->shapeId(); }
+ /** Return the parent \a FrameSet object this \a Frame object is child \
of. */ + QObject* frameSet() { return parent(); }
+ /** This property what should happen when the frame is full. */
+ int frameBehavior() const { return m_frame->frameBehavior(); }
+ /** Set what should happen when the frame is full. */
+ void setFrameBehavior(int framebehavior) { m_frame->setFrameBehavior( \
(KWord::FrameBehavior) framebehavior ); } +
+ /** Return the text runaround property for this frame. This property \
specifies + how text from another textframe will behave when this frame \
intersects with it. */ + int textRunAround() const { return \
m_frame->textRunAround(); } + /** Set the text runaround property for this \
frame. */ + void setTextRunAround(int textrunaround) { return \
m_frame->setTextRunAround( (KWord::TextRunAround) textrunaround ); } + /** \
Return the space between this frames edge and the text when that text runs around \
this frame. */ + double runAroundDistance() const { return \
m_frame->runAroundDistance(); } + /** Set the space between this frames \
edge and the text when that text runs around this frame. */ + void \
setRunAroundDistance(double runarounddistance) { \
m_frame->setRunAroundDistance(runarounddistance); } +
/** Request a repaint to be queued. */
void repaint() const { m_frame->shape()->repaint(); }
--- trunk/koffice/kword/plugins/scripting/FrameSet.h #618049:618050
@@ -68,7 +68,7 @@
/** Return the \a Frame object with index \p frameNr or NULL if there \
exists no \a Frame with such a index. */ QObject* frame(int frameNr) {
if( frameNr >= 0 && frameNr < m_frameset->frames().count() )
- return new Frame(parent(), m_frameset->frames().at(frameNr));
+ return new Frame(this, m_frameset->frames().at(frameNr));
return 0;
}
@@ -82,7 +82,7 @@
}
KoShape *shape = factory->createDefaultShape();
Q_ASSERT(shape);
- shape->setZIndex( 1 + m_frameset->frameCount() );
+ shape->setZIndex( 100 + m_frameset->frameCount() );
KWFrame* frame = 0;
KWTextFrameSet* textframeset = dynamic_cast<KWTextFrameSet*>( \
(KWFrameSet*)m_frameset ); if( textframeset )
--- trunk/koffice/kword/plugins/scripting/Module.cpp #618049:618050
@@ -34,6 +34,7 @@
#include <KWView.h>
#include <KWPage.h>
#include <KWFrameSet.h>
+#include <KWFrame.h>
extern "C"
{
@@ -138,7 +139,7 @@
return new FrameSet(this, frameset);
}
-QObject* Module::addTextFrameSet(const QString& name)
+QObject* Module::addTextFrameSet(const QString& framesetname)
{
KWord::TextFrameSetType type = KWord::OtherTextFrameSet;
/*
@@ -155,20 +156,54 @@
*/
KWTextFrameSet* frameset = new KWTextFrameSet(type);
- frameset->setName(name);
+ frameset->setName(framesetname);
frameset->setAllowLayout(false);
doc()->addFrameSet(frameset);
return new FrameSet(this, frameset);
}
-QObject* Module::addFrameSet(const QString& name)
+QObject* Module::addFrameSet(const QString& framesetname)
{
KWFrameSet* frameset = new KWFrameSet();
- frameset->setName(name);
+ frameset->setName(framesetname);
doc()->addFrameSet(frameset);
return new FrameSet(this, frameset);
}
+int Module::frameCount()
+{
+ int count = 0;
+ foreach(KWFrameSet* set, doc()->frameSets())
+ count += set->frames().count();
+ return count;
+}
+
+QObject* Module::frame(int frameNr)
+{
+ if(frameNr >= 0) {
+ int idx = 0;
+ foreach(KWFrameSet* set, doc()->frameSets()) {
+ const int c = set->frames().count();
+ if(frameNr < idx + c)
+ return new Frame(new FrameSet(this, set), set->frames().at(idx));
+ idx += c;
+ }
+ }
+ return 0;
+}
+
+QObject* Module::addTextFrame(const QString& framesetname)
+{
+ FrameSet* set = dynamic_cast< FrameSet* >( addTextFrameSet(framesetname) );
+ return set ? set->addTextFrame() : 0;
+}
+
+QObject* Module::addFrame(const QString& framesetname, const QString& shapeId)
+{
+ FrameSet* set = dynamic_cast< FrameSet* >( addFrameSet(framesetname) );
+ return set ? set->addFrame(shapeId) : 0;
+}
+
QObject* Module::standardPageLayout()
{
return new PageLayout(this, KoPageLayout::standardLayout());
--- trunk/koffice/kword/plugins/scripting/Module.h #618049:618050
@@ -79,16 +79,23 @@
/** Return the amount of framesets this document holds. */
int frameSetCount();
- /** Return a list of all the framesets this document holds. */
+ /** Return the \a FrameSet object identified by the index frameSetNr. */
QObject* frameSet(int frameSetNr);
+ /** Add and return a new \a FrameSet object for text handled with \a \
TextDocument . */ + QObject* addTextFrameSet(const QString& framesetname);
+ /** Add and return a new \a FrameSet object. */
+ QObject* addFrameSet(const QString& framesetname);
- //void addFrameSet( KWFrameSet *f );
- //void removeFrameSet( KWFrameSet *fs );
+ /***** Frame *****/
+ /** Return the amount of frames this document holds. */
+ int frameCount();
+ /** Return a the \a Frame object identified by the index frameNr. */
+ QObject* frame(int frameNr);
/** Add and return a new \a FrameSet object for text handled with \a \
TextDocument . */
- QObject* addTextFrameSet(const QString& name);
+ QObject* addTextFrame(const QString& framesetname);
/** Add and return a new \a FrameSet object. */
- QObject* addFrameSet(const QString& name);
+ QObject* addFrame(const QString& framesetname, const QString& shapeId);
/***** Layout *****/
--- trunk/koffice/kword/plugins/scripting/scripts/sample_shapes.py #618049:618050
@@ -27,25 +27,27 @@
#textframe.setZIndex(3)
# add KoStarShape frame
-starframe = KWord.addFrameSet("mystar").addFrame("KoStarShape")
+#starframe = KWord.addFrameSet("mystar").addFrame("KoStarShape")
+starframe = KWord.addFrame("mystar", "KoStarShape")
if starframe != None:
- starframe.setPosition(400, 50)
+ starframe.setPosition(450, 50)
starframe.rotate(25.0)
# add KoPathShape frame
-pathframe = KWord.addFrameSet("mypath").addFrame("KoPathShape")
+pathframe = KWord.addFrame("mypath", "KoPathShape")
if pathframe != None:
pathframe.setPosition(400, 150)
pathframe.shear(0.5, 0.5)
# add KoRegularPolygonShape frame
-polyframe = KWord.addFrameSet("mypoly").addFrame("KoRegularPolygonShape")
+polyframe = KWord.addFrame("mypoly", "KoRegularPolygonShape")
if polyframe != None:
polyframe.setPosition(420, 320)
polyframe.shear(-0.5, -0.5)
# add TableShape frame
-tableframe = KWord.addFrameSet("mytable").addFrame("TableShape")
+tableframe = KWord.addFrame("mytable", "TableShape")
if tableframe != None:
+ tableframe.setTextRunAround(tableframe.RunThrough)
tableframe.setPosition(200, 160)
tableframe.resize(160, 160)
--- trunk/koffice/kword/plugins/scripting/scripts/sample_text.py #618049:618050
@@ -3,14 +3,15 @@
import KWord, time
#KWord.insertPage( KWord.pageCount() )
-KWord.insertPage(0)
+if KWord.pageCount() < 1:
+ KWord.insertPage(0)
fs = KWord.frameSet(0)
doc = fs.textDocument()
doc.setHtml(
(
- "<h1><font color=\"blue\">Python Test Script</font></h1>"
+ "<h1><font color=\"blue\">Python Sample Script</font></h1>"
"<p><i>italic</i> and <b>bold</b> and <u>underlined</u> and a <a \
href=\"test\">link</a></p>." "<ul>"
"<li>Time=<b>%s</b></li>"
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic