Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit b6bddb57 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Remove unused eventaction system

Important for ODF applications like stage, but not for Krita.
parent 45383192
......@@ -98,9 +98,6 @@ set(kritaflake_SRCS
KoInputDeviceHandler.cpp
KoInputDeviceHandlerEvent.cpp
KoInputDeviceHandlerRegistry.cpp
KoEventAction.cpp
KoEventActionFactoryBase.cpp
KoEventActionRegistry.cpp
KoImageData.cpp
KoImageData_p.cpp
KoImageCollection.cpp
......@@ -150,8 +147,6 @@ set(kritaflake_SRCS
commands/KoConnectionShapeTypeCommand.cpp
commands/KoShapeShadowCommand.cpp
commands/KoPathReverseCommand.cpp
commands/KoEventActionAddCommand.cpp
commands/KoEventActionRemoveCommand.cpp
commands/KoShapeRenameCommand.cpp
commands/KoShapeRunAroundCommand.cpp
commands/KoPathPointMergeCommand.cpp
......
/* This file is part of the KDE project
* Copyright (C) 2008 Thomas Zander <zander@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KoEventAction.h"
#include <QString>
class Q_DECL_HIDDEN KoEventAction::Private
{
public:
QString id;
};
KoEventAction::KoEventAction()
: d(new Private())
{
}
KoEventAction::~KoEventAction()
{
delete d;
}
QString KoEventAction::id() const
{
return d->id;
}
void KoEventAction::setId(const QString &id)
{
d->id = id;
}
/* This file is part of the KDE project
Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KOEVENTACTION_H
#define KOEVENTACTION_H
#include "kritaflake_export.h"
#include "KoXmlReaderForward.h"
class QString;
class KoShapeLoadingContext;
class KoShapeSavingContext;
/**
* This is the base class for actions that are executed on events.
*
* See ODF:
* 9.9 Presentation Events
* Many objects inside a presentation document support special presentation events. For example, a
* user can advance the presentation one frame when clicking on an object with a corresponding
* event. Presentation events are contained with a graphic object's event listener table. See section
* 9.2.21 for details.
*
* 12.4 Event Listener Tables
* Many objects such as controls, images, text boxes, or an entire document support events. An
* event binds the occurrence of a particular condition to an action that is executed if the condition
* arises. For example, if a user places the cursor over a graphic, this condition triggers an action
* that is supported by the office application. This event, called "on-mouse-over", can be associated
* with a macro that is executed whenever the condition occurs, that is, whenever a user places the
* cursor over a graphic.
*/
class KRITAFLAKE_EXPORT KoEventAction
{
public:
/**
* Constructor
*/
KoEventAction();
virtual ~KoEventAction();
/**
* Set The id of the action
*
* @param id this is the value that is used for storing the event action in odf.
*/
void setId(const QString &id);
/**
* The id of the action
*
* The id is the value that is used for storing the event action in odf.
*/
QString id() const;
/**
* Load action from ODF.
*
* @param context the KoShapeLoadingContext used for loading
* @param element element which represents the shape in odf
*
* @return false if loading failed
*/
virtual bool loadOdf(const KoXmlElement &element, KoShapeLoadingContext &context) = 0;
/**
* Store the action as ODF.
*
* @param context The KoShapeSavingContext used for saving
*/
virtual void saveOdf(KoShapeSavingContext &context) const = 0;
/**
* Start the action.
*/
virtual void start() = 0;
/**
* Finish the action
*
* If the action takes some time to finish it can bs stoped with
* this method before its end.
*/
virtual void finish() {}
private:
class Private;
Private * const d;
};
#endif /* KOEVENTACTION_H */
/* This file is part of the KDE project
Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KoEventActionFactoryBase.h"
class Q_DECL_HIDDEN KoEventActionFactoryBase::Private
{
public:
Private(const QString & id, const QString & action)
: id(id)
, action(action) {}
const QString id;
const QString action;
};
KoEventActionFactoryBase::KoEventActionFactoryBase(const QString &id, const QString & action)
: d(new Private(id, action))
{
}
KoEventActionFactoryBase::~KoEventActionFactoryBase()
{
delete d;
}
QString KoEventActionFactoryBase::action() const
{
return d->action;
}
QString KoEventActionFactoryBase::id() const
{
return d->id;
}
/* This file is part of the KDE project
Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KOEVENTACTIONFACTORY_H
#define KOEVENTACTIONFACTORY_H
#include <QString>
#include "kritaflake_export.h"
class KoEventAction;
class QWidget;
/**
* Factory for creating KoEventActions
*
* This is the base class for event action plugins. Each plugin that ships a KoEventAction should
* also ship a factory.
*/
class KRITAFLAKE_EXPORT KoEventActionFactoryBase
{
public:
/**
* Factory to create events
*
* @param id The id of the event action
* @param action Only presentation event actions need to set the action. It is not used
* for script event actions.
*/
explicit KoEventActionFactoryBase(const QString &id, const QString & action = QString());
virtual ~KoEventActionFactoryBase();
/**
* Create the event action.
*/
virtual KoEventAction *createEventAction() = 0;
/**
* Create the widget to configure the action
*/
virtual QWidget *createOptionWidget() = 0;
/**
* The action is used to differentiate presentation effects.
*/
QString action() const;
/**
* return the id for the variable this factory creates.
* @return the id for the variable this factory creates.
*/
QString id() const;
private:
class Private;
Private * const d;
};
#endif /* KOEVENTACTIONFACTORY_H */
/* This file is part of the KDE project
Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KoEventActionRegistry.h"
#include <QHash>
#include <QGlobalStatic>
#include <FlakeDebug.h>
#include <KoXmlReader.h>
#include <KoXmlNS.h>
#include "KoEventActionFactoryBase.h"
#include "KoEventAction.h"
#include <KoPluginLoader.h>
class KoEventActionRegistry::Singleton
{
public:
Singleton()
: initDone(false) {}
KoEventActionRegistry q;
bool initDone;
};
Q_GLOBAL_STATIC(KoEventActionRegistry::Singleton, singleton)
class Q_DECL_HIDDEN KoEventActionRegistry::Private
{
public:
QHash<QString, KoEventActionFactoryBase*> presentationEventActionFactories;
QHash<QString, KoEventActionFactoryBase*> presentationEventActions;
QHash<QString, KoEventActionFactoryBase*> scriptEventActionFactories;
};
KoEventActionRegistry * KoEventActionRegistry::instance()
{
KoEventActionRegistry * registry = &(singleton->q);
if (! singleton->initDone) {
singleton->initDone = true;
registry->init();
}
return registry;
}
KoEventActionRegistry::KoEventActionRegistry()
: d(new Private())
{
}
KoEventActionRegistry::~KoEventActionRegistry()
{
delete d;
}
void KoEventActionRegistry::addPresentationEventAction(KoEventActionFactoryBase * factory)
{
const QString & action = factory->action();
if (! action.isEmpty()) {
d->presentationEventActionFactories.insert(factory->id(), factory);
d->presentationEventActions.insert(action, factory);
}
}
void KoEventActionRegistry::addScriptEventAction(KoEventActionFactoryBase * factory)
{
d->scriptEventActionFactories.insert(factory->id(), factory);
}
QList<KoEventActionFactoryBase *> KoEventActionRegistry::presentationEventActions()
{
return d->presentationEventActionFactories.values();
}
QList<KoEventActionFactoryBase *> KoEventActionRegistry::scriptEventActions()
{
return d->scriptEventActionFactories.values();
}
void KoEventActionRegistry::init()
{
KoPluginLoader::PluginsConfig config;
config.whiteList = "PresentationEventActionPlugins";
config.blacklist = "PresentationEventActionPluginsDisabled";
config.group = "calligra";
KoPluginLoader::instance()->load(QString::fromLatin1("Calligra/PresentationEventAction"),
QString::fromLatin1("[X-PresentationEventAction-PluginVersion] == 28"),
config);
config.whiteList = "ScriptEventActionPlugins";
config.blacklist = "ScriptEventActionPluginsDisabled";
KoPluginLoader::instance()->load(QString::fromLatin1("Calligra/ScriptEventAction"),
QString::fromLatin1("[X-ScriptEventAction-PluginVersion] == 28"),
config);
}
QSet<KoEventAction*> KoEventActionRegistry::createEventActionsFromOdf(const KoXmlElement & e, KoShapeLoadingContext & context) const
{
QSet<KoEventAction *> eventActions;
if (e.namespaceURI() == KoXmlNS::office && e.tagName() == "event-listeners") {
KoXmlElement element;
forEachElement(element, e) {
if (element.tagName() == "event-listener") {
if (element.namespaceURI() == KoXmlNS::presentation) {
QString action(element.attributeNS(KoXmlNS::presentation, "action", QString()));
QHash<QString, KoEventActionFactoryBase *>::const_iterator it(d->presentationEventActions.find(action));
if (it != d->presentationEventActions.constEnd()) {
KoEventAction * eventAction = it.value()->createEventAction();
if (eventAction) {
if (eventAction->loadOdf(element, context)) {
eventActions.insert(eventAction);
} else {
delete eventAction;
}
}
} else {
warnFlake << "presentation:event-listerer action = " << action << "not supported";
}
} else if (element.namespaceURI() == KoXmlNS::script) {
// TODO
} else {
warnFlake << "element" << e.namespaceURI() << e.tagName() << "not supported";
}
} else {
warnFlake << "element" << e.namespaceURI() << e.tagName() << "not supported";
}
}
} else {
warnFlake << "office:event-listeners not found got:" << e.namespaceURI() << e.tagName();
}
return eventActions;
}
/* This file is part of the KDE project
Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KOEVENTACTIONREGISTRY_H
#define KOEVENTACTIONREGISTRY_H
#include <QList>
#include <QSet>
#include "kritaflake_export.h"
#include "KoXmlReaderForward.h"
class KoEventAction;
class KoEventActionFactoryBase;
class KoShapeLoadingContext;
/**
* This singletion keeps a register of all available KoEventActionFactoryBase objects.
*
* It creates the event actions when loaded from odf.
*/
class KRITAFLAKE_EXPORT KoEventActionRegistry
{
public:
class Singleton;
KoEventActionRegistry();
~KoEventActionRegistry();
/**
* Return an instance of the KoEventActionRegistry
*/
static KoEventActionRegistry *instance();
/**
* Create action events for the elements given
*/
QSet<KoEventAction*> createEventActionsFromOdf(const KoXmlElement &element, KoShapeLoadingContext &context) const;
/**
* Add presentation event action.
*/
void addPresentationEventAction(KoEventActionFactoryBase *factory);
/**
* Add script event action.
*/
void addScriptEventAction(KoEventActionFactoryBase *factory);
/**
* Get presentation event actions.
*/
QList<KoEventActionFactoryBase *> presentationEventActions();
/**
* Get script event actions.
*/
QList<KoEventActionFactoryBase *> scriptEventActions();
private:
KoEventActionRegistry(const KoEventActionRegistry &);
KoEventActionRegistry operator=(const KoEventActionRegistry &);
void init();
class Private;
Private *d;
};
#endif /* KOEVENTACTIONREGISTRY_H */
......@@ -45,8 +45,6 @@
#include "KoShapeShadow.h"
#include "KoClipPath.h"
#include "KoPathShape.h"
#include "KoEventAction.h"
#include "KoEventActionRegistry.h"
#include "KoOdfWorkaround.h"
#include "KoFilterEffectStack.h"
#include <KoSnapData.h>
......@@ -133,7 +131,6 @@ KoShapePrivate::~KoShapePrivate()
if (filterEffectStack && !filterEffectStack->deref())
delete filterEffectStack;
delete clipPath;
qDeleteAll(eventActions);
}
void KoShapePrivate::shapeChanged(KoShape::ChangeType type)
......@@ -875,24 +872,6 @@ void KoShape::clearConnectionPoints()
d->connectors.clear();
}
void KoShape::addEventAction(KoEventAction *action)
{
Q_D(KoShape);
d->eventActions.insert(action);
}
void KoShape::removeEventAction(KoEventAction *action)
{
Q_D(KoShape);
d->eventActions.remove(action);
}
QSet<KoEventAction *> KoShape::eventActions() const
{
Q_D(const KoShape);
return d->eventActions;
}
KoShape::TextRunAroundSide KoShape::textRunAroundSide() const
{
Q_D(const KoShape);
......@@ -1596,10 +1575,6 @@ bool KoShape::loadOdfAttributes(const KoXmlElement &element, KoShapeLoadingConte
}
if (attributes & OdfCommonChildElements) {
const KoXmlElement eventActionsElement(KoXml::namedItemNS(element, KoXmlNS::office, "event-listeners"));
if (!eventActionsElement.isNull()) {
d->eventActions = KoEventActionRegistry::instance()->createEventActionsFromOdf(eventActionsElement, context);
}
// load glue points (connection points)
loadOdfGluePoints(element, context);
}
......@@ -2051,15 +2026,6 @@ void KoShape::saveOdfAttributes(KoShapeSavingContext &context, int attributes) c
void KoShape::saveOdfCommonChildElements(KoShapeSavingContext &context) const
{
Q_D(const KoShape);
// save event listeners see ODF 9.2.21 Event Listeners
if (d->eventActions.size() > 0) {
context.xmlWriter().startElement("office:event-listeners");
foreach(KoEventAction * action, d->eventActions) {
action->saveOdf(context);
}
context.xmlWriter().endElement();
}
// save glue points see ODF 9.2.19 Glue Points
if(d->connectors.count()) {
KoConnectionPoints::const_iterator cp = d->connectors.constBegin();
......
......@@ -51,7 +51,6 @@ class KoShapeSavingContext;
class KoShapeLoadingContext;
class KoGenStyle;
class KoShapeShadow;
class KoEventAction;
class KoShapePrivate;
class KoFilterEffectStack;
class KoSnapData;
......@@ -368,21 +367,6 @@ public:
/// Removes all connection points
void clearConnectionPoints();
/**
* Add a event action
*/
void addEventAction(KoEventAction *action);
/**
* Remove a event action
*/
void removeEventAction(KoEventAction *action);
/**
* Get all event actions
*/
QSet<KoEventAction *> eventActions() const;
/**
* Return the side text should flow around this shape. This implements the ODF style:wrap
* attribute that specifies how text is displayed around a frame or graphic object.
......
......@@ -84,7 +84,6 @@ public:
KoClipPath * clipPath; ///< the current clip path
QMap<QString, QString> additionalAttributes;
QMap<QByteArray, QString> additionalStyleAttributes;
QSet<KoEventAction *> eventActions; ///< list of event actions the shape has
KoFilterEffectStack *filterEffectStack; ///< stack of filter effects applied to the shape
qreal transparency; ///< the shapes transparency
QString hyperLink; //hyperlink for this shape
......
/* This file is part of the KDE project
* Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KoEventActionAddCommand.h"
#include <klocalizedstring.h>
#include "KoShape.h"
#include "KoEventAction.h"
class KoEventActionAddCommandPrivate
{
public:
KoEventActionAddCommandPrivate(KoShape *s, KoEventAction *a)
: shape(s), eventAction(a), deleteEventAction(true)
{
}
~KoEventActionAddCommandPrivate() {
if (deleteEventAction)
delete eventAction;
}
KoShape *shape;
KoEventAction *eventAction;
bool deleteEventAction;
};
KoEventActionAddCommand::KoEventActionAddCommand(KoShape *shape, KoEventAction *eventAction, KUndo2Command *parent)