[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: koffice
From: Sebastian Sauer <mail () dipe ! org>
Date: 2007-05-31 19:05:43
Message-ID: 1180638343.476317.13337.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 670217 by sebsauer:
* Added the KoScriptingGuiClient that inherits Kross::GUIClient to be later able to \
extend it with KOffice-related functionality.
* Let KWord, KSpread and Krita use it rather then the Kross::GUIClient direct.
M +3 -2 krita/plugins/viewplugins/scripting/scriptingpart.cpp
M +8 -7 kspread/plugins/scripting/ScriptingPart.cpp
M +3 -2 kword/plugins/scripting/KWScriptingPart.cpp
M +1 -1 libs/kokross/CMakeLists.txt
A libs/kokross/KoScriptingGuiClient.cpp [License: LGPL (v2+)]
A libs/kokross/KoScriptingGuiClient.h [License: LGPL (v2+)]
M +32 -70 libs/kotext/opendocument/KoOpenDocumentLoader.cpp
M +6 -1 libs/kotext/styles/KoListLevelProperties.cpp
--- trunk/koffice/krita/plugins/viewplugins/scripting/scriptingpart.cpp \
#670216:670217 @@ -46,6 +46,7 @@
// koffice/libs/kokross
#include <KoScriptingDocker.h>
+#include <KoScriptingGuiClient.h>
// krita
#include <kis_global.h>
@@ -68,7 +69,7 @@
{
public:
KisView2* view;
- Kross::GUIClient* guiclient;
+ KoScriptingGuiClient* guiclient;
QPointer< Scripting::Module > module;
};
@@ -81,7 +82,7 @@
d->view = dynamic_cast< KisView2* >(parent);
Q_ASSERT(d->view);
- d->guiclient = new Kross::GUIClient( d->view, d->view );
+ d->guiclient = new KoScriptingGuiClient( d->view, d->view );
//d->guiclient ->setXMLFile(locate("data","kritaplugins/scripting.rc"), true);
//BEGIN TODO: understand why the ScriptGUIClient doesn't "link" its actions to \
the menu
--- trunk/koffice/kspread/plugins/scripting/ScriptingPart.cpp #670216:670217
@@ -22,20 +22,21 @@
#include "ScriptingPart.h"
#include "ScriptingModule.h"
-
+// Qt
#include <QApplication>
#include <QFileInfo>
-
+// KDE
#include <kgenericfactory.h>
#include <kstandarddirs.h>
#include <kactioncollection.h>
#include <kcmdlineargs.h>
#include <kurl.h>
-
+// KSpread
#include <Doc.h>
#include <View.h>
-
-//#define KROSS_MAIN_EXPORT KDE_EXPORT
+// KOffice
+#include <KoScriptingGuiClient.h>
+// Kross
#include <kross/core/manager.h>
#include <kross/ui/guiclient.h>
@@ -46,7 +47,7 @@
class ScriptingPart::Private
{
public:
- Kross::GUIClient* guiclient;
+ KoScriptingGuiClient* guiclient;
ScriptingModule* module;
Private() : module(0) {}
@@ -67,7 +68,7 @@
// Create the Kross GUIClient which is the higher level to let
// Kross deal with scripting code.
- d->guiclient = new Kross::GUIClient(this, this);
+ d->guiclient = new KoScriptingGuiClient(this, this);
//d->guiclient ->setXMLFile(locate("data","kspreadplugins/scripting.rc"), true);
// Setup the actions Kross provides and KSpread likes to have.
--- trunk/koffice/kword/plugins/scripting/KWScriptingPart.cpp #670216:670217
@@ -37,6 +37,7 @@
#include <kross/ui/model.h>
// koffice
#include <KoScriptingDocker.h>
+#include <KoScriptingGuiClient.h>
// kword
#include <KWView.h>
@@ -48,7 +49,7 @@
{
public:
KWView* view;
- Kross::GUIClient* guiclient;
+ KoScriptingGuiClient* guiclient;
Scripting::Module* module;
Private() : module(0) {}
~Private() { delete module; }
@@ -68,7 +69,7 @@
// Create the Kross GUIClient which is the higher level to let
// Kross deal with scripting code.
- d->guiclient = new Kross::GUIClient(this, this);
+ d->guiclient = new KoScriptingGuiClient(this, this);
//d->guiclient ->setXMLFile(locate("data","kspreadplugins/scripting.rc"), true);
d->module = new Scripting::Module();
--- trunk/koffice/libs/kokross/CMakeLists.txt #670216:670217
@@ -1,5 +1,5 @@
include_directories(${KDE4_KDECORE_INCLUDES} ${KOMAIN_INCLUDES})
-set(kokross_LIB_SRCS KoScriptingModule.cpp KoScriptingDocker.cpp KoScriptManager.cpp \
KoScriptManagerAdd.cpp) +set(kokross_LIB_SRCS KoScriptingModule.cpp \
KoScriptingDocker.cpp KoScriptManager.cpp KoScriptManagerAdd.cpp \
KoScriptingGuiClient.cpp) kde4_automoc(kokross ${kokross_LIB_SRCS})
kde4_add_library(kokross SHARED ${kokross_LIB_SRCS})
--- trunk/koffice/libs/kotext/opendocument/KoOpenDocumentLoader.cpp #670216:670217
@@ -51,7 +51,7 @@
#include <klocale.h>
// if defined then debugging is enabled
-//#define KOOPENDOCUMENTLOADER_DEBUG
+#define KOOPENDOCUMENTLOADER_DEBUG
/// \internal d-pointer class.
class KoOpenDocumentLoader::Private
@@ -121,52 +121,6 @@
//1.6: KoStyleCollection::loadOasisStyles
void KoOpenDocumentLoader::loadStyles(KoOasisLoadingContext& context, \
QList<KoXmlElement*> styleElements) {
-#if 0 //1.6:
- QStringList followingStyles;
- QList<KoXmlElement*> userStyles = context.oasisStyles().customStyles( \
"paragraph" ).values();
- bool defaultStyleDeleted = false;
- int stylesLoaded = 0;
- const unsigned int nStyles = userStyles.count();
- for (unsigned int item = 0; item < nStyles; item++) {
- KoXmlElement* styleElem = userStyles[item];
- if ( !styleElem ) continue;
- Q_ASSERT( !styleElem->isNull() );
- if( !defaultStyleDeleted ) { // we are going to import at least one style.
- KoParagStyle *s = defaultStyle();
- //kDebug() << "loadOasisStyles looking for Standard, to delete it. Found \
" << s << endl;
- if(s) removeStyle(s); // delete the standard style.
- defaultStyleDeleted = true;
- }
- KoParagStyle *sty = new KoParagStyle( QString::null );
- // Load the style
- sty->loadStyle( *styleElem, context );
- // Style created, now let's try to add it
- const int oldStyleCount = count();
- sty = addStyle( sty );
- // the real value of followingStyle is set below after loading all styles
- sty->setFollowingStyle( sty );
- kDebug() << " Loaded style " << sty->name() << endl;
- if ( count() > oldStyleCount ) {
- const QString following = styleElem->attributeNS( KoXmlNS::style, \
"next-style-name", QString::null );
- followingStyles.append( following );
- ++stylesLoaded;
- }
- else kWarning() << "Found duplicate style declaration, overwriting former " \
<< sty->name() << endl;
- }
- if( followingStyles.count() != styleList().count() ) kDebug() << "Ouch, " << \
followingStyles.count() << " following-styles, but " << styleList().count() << " \
styles in styleList" << endl;
- unsigned int i = 0;
- QString tmpString;
- foreach( tmpString, followingStyles ) {
- const QString followingStyleName = tmpString;
- if ( !followingStyleName.isEmpty() ) {
- KoParagStyle * style = findStyle( followingStyleName );
- if ( style ) styleAt(i)->setFollowingStyle( style );
- }
- }
- // TODO the same thing for style inheritance (style:parent-style-name) and \
setParentStyle()
- Q_ASSERT( defaultStyle() );
- return stylesLoaded;
-#endif
foreach(KoXmlElement* styleElem, styleElements) {
Q_ASSERT( styleElem );
Q_ASSERT( !styleElem->isNull() );
@@ -230,7 +184,6 @@
style->loadOasis(context, *it.value());
d->addStyle(style);
}
-
}
void KoOpenDocumentLoader::loadSettings(KoOasisLoadingContext& context, const \
QDomDocument& settings) @@ -334,14 +287,9 @@
kDebug() << "KoOpenDocumentLoader::loadParagraph \
paragraphStyle.localName=" << (paragraphStyle ? paragraphStyle->localName() : "NULL") \
<< " masterPageName=" << masterPageName << endl; #endif
- /*
- QString styleName = context.styleStack().userStyleName( "paragraph" );
- KoParagraphStyle *style = d->stylemanager->paragraphStyle(styleName);
- if ( !style ) {
- kDebug() << "KoOpenDocumentLoader::loadSpan: Unknown style. Using \
default!" << endl;
- style = d->stylemanager->defaultParagraphStyle();
- }
- */
+ //QString styleName = context.styleStack().userStyleName( "paragraph" );
+ //KoParagraphStyle *style = d->stylemanager->paragraphStyle(styleName);
+ //if ( !style ) style = d->stylemanager->defaultParagraphStyle();
//d->currentMasterPage = masterPageName; // do this first to avoid recursion
context.styleStack().save();
@@ -362,7 +310,7 @@
style->applyStyle(block);
}
-#if 0
+#if 0 //1.6:
// This is quite ugly... OOo stores the starting page-number in the first \
paragraph style...
QString pageNumber = context.styleStack().attributeNS( KoXmlNS::style, \
"page-number" );
if ( !pageNumber.isEmpty() ) \
doc->variableCollection()->variableSetting()->setStartingPageNumber( \
pageNumber.toInt() ); @@ -438,8 +386,6 @@
if( level > 0 ) {
listStyle = new KoListStyle();
KoListLevelProperties props;
- //props.setListItemPrefix("ABC");
- //props.setStyle( KoListStyle::NoItem );
props.setStyle( KoListStyle::DecimalItem );
props.setDisplayLevel(level);
listStyle->setLevel(props);
@@ -554,10 +500,8 @@
QString styleName;
if ( parent.hasAttributeNS( KoXmlNS::text, "style-name" ) ) {
styleName = parent.attributeNS( KoXmlNS::text, "style-name", QString::null \
);
- /*
- KoXmlElement* listElem = context.oasisStyles().listStyles()[ styleName ];
- if(listElem) context.addStyles( listElem, "paragraph" );
- */
+ //KoXmlElement* listElem = context.oasisStyles().listStyles()[ styleName ];
+ //if(listElem) context.addStyles( listElem, "paragraph" );
}
// Get the KoListStyle the name may reference to
@@ -565,12 +509,21 @@
#ifdef KOOPENDOCUMENTLOADER_DEBUG
kDebug()<<"KoOpenDocumentLoader::loadList styleName="<<styleName<<" \
listStyle="<<(listStyle ? listStyle->name() : "NULL")<<endl; #endif
- if( ! listStyle ) {
+ if( ! listStyle ) { // even if wellformed documents shouldn't reference a style \
we don't know about yet, we handle that case... listStyle = new KoListStyle();
listStyle->setName(styleName);
d->addStyle(listStyle);
}
+
+KoParagraphStyle* paragStyle = new KoParagraphStyle();
+paragStyle->setName(styleName);
+paragStyle->setListStyle(*listStyle);
+
+
+
+
+
// Set the style and create the textlist
QTextListFormat listformat;
QTextList* list = cursor.insertList(listformat);
@@ -578,7 +531,7 @@
// we need at least one item, so add a dummy-item we remove later again
cursor.insertBlock();
QTextBlock prev = cursor.block();
-
+static int level = 1;
// Iterate over list items and add them to the textlist
KoXmlElement e;
forEachElement(e, parent) {
@@ -594,8 +547,18 @@
list->setFormat(f);
}
*/
- listStyle->applyStyle(cursor.block());
+
+//KoListLevelProperties properties = listStyle->level(level);
+//QTextListFormat lf;
+//properties.applyStyle(lf);
+//list->setFormat(lf);
+
+QTextBlock bl = cursor.block();
+paragStyle->applyStyle(bl);
+paragStyle->setListLevel(level);
+ //listStyle->applyStyle(cursor.block(), level);
loadBody(context, e, cursor);
+level++;
}
// add the new blocks to the list
@@ -604,6 +567,9 @@
list->add(b);
list->removeItem(0); // remove the first dummy item again
+
+
+
/*
// Get the matching paragraph style
//QString userStyleName = context.styleStack().userStyleName( "paragraph" );
@@ -814,9 +780,6 @@
#ifdef KOOPENDOCUMENTLOADER_DEBUG
kDebug() << " <line-break> Node localName=" << localName << endl;
#endif
- //QTextBlockFormat emptyTbf;
- //QTextCharFormat emptyCf;
- //cursor.insertBlock(emptyTbf, emptyCf);
cursor.insertText( "\n" );
}
else if ( isTextNS && localName == "number" ) // text:number
@@ -861,6 +824,5 @@
context.styleStack().restore();
}
}
-//#endif
#include "KoOpenDocumentLoader.moc"
--- trunk/koffice/libs/kotext/styles/KoListLevelProperties.cpp #670216:670217
@@ -348,9 +348,14 @@
const QString level = style.attributeNS( KoXmlNS::text, "level", QString() );
if( ! level.isNull() ) {
- //kDebug()<<"KoListLevelProperties::loadOasis "<<style.localName()<<" \
LEVEL="<<level<<endl; + kDebug()<<"KoListLevelProperties::loadOasis \
"<<style.localName()<<" LEVEL="<<level<<endl; const int i = level.toInt();
setLevel(i);
setDisplayLevel(i);
}
+
+ //KoXmlElement props = style.firstChildElement("list-level-properties");
+ //const QString spaceBefore = props.attributeNS( KoXmlNS::style, "space-before", \
QString() ); + //const QString minLabelWidth = props.attributeNS( KoXmlNS::style, \
"min-label-width", QString() ); +
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic