Commit a6de88e9 authored by Thorsten Zachmann's avatar Thorsten Zachmann

o implement loading of additional attributes

svn path=/trunk/koffice/; revision=805968
parent cf2ab296
......@@ -777,6 +777,14 @@ bool KoShape::loadOdfAttributes( const KoXmlElement & element, KoShapeLoadingCon
}
if ( attributes & OdfAdditionalAttributes ) {
QSet<KoShapeLoadingContext::AdditionalAttributeData> additionalAttributeData = KoShapeLoadingContext::additionalAttributeData();
foreach ( KoShapeLoadingContext::AdditionalAttributeData attributeData, additionalAttributeData ) {
if ( element.hasAttributeNS( attributeData.ns, attributeData.tag ) ) {
QString value = element.attributeNS( attributeData.ns, attributeData.tag );
//kDebug(30006) << "load additional attribute" << attributeData.tag << value;
setAddtionalAttribute( attributeData.name, value );
}
}
}
return true;
......
......@@ -25,6 +25,13 @@
#include <kdebug.h>
uint qHash( const KoShapeLoadingContext::AdditionalAttributeData & attributeData )
{
return qHash( attributeData.name );
}
static QSet<KoShapeLoadingContext::AdditionalAttributeData> s_additionlAttributes;
class KoShapeLoadingContext::Private {
public:
Private( KoOdfLoadingContext &c, KoShapeControllerBase * sc )
......@@ -138,6 +145,16 @@ KoSharedLoadingData * KoShapeLoadingContext::sharedData( const QString & id ) co
return data;
}
void KoShapeLoadingContext::addAdditionalAttributeData( const AdditionalAttributeData & attributeData )
{
s_additionlAttributes.insert( attributeData );
}
QSet<KoShapeLoadingContext::AdditionalAttributeData> KoShapeLoadingContext::additionalAttributeData()
{
return s_additionlAttributes;
}
KoShapeControllerBase * KoShapeLoadingContext::shapeController() const
{
return d->shapeController;
......
......@@ -22,6 +22,7 @@
#define KOSHAPELOADINGCONTEXT_H
#include <QMap>
#include <QSet>
#include <QString>
#include "flake_export.h"
......@@ -41,6 +42,33 @@ class KoSharedLoadingData;
class FLAKE_EXPORT KoShapeLoadingContext
{
public:
/**
* Struct to store data about additional attributes that should be loaded during
* the shape loading.
*
* Make sure all parameters point to const char * that stay around. e.g. The a KoXmlNS or
* a "tag" defined string e.g.
* AdditionalAttributeData( KoXmlNS::presentation, "placeholder", presentation:placeholder" )
*/
struct AdditionalAttributeData
{
AdditionalAttributeData( const char * const ns, const char * const tag, const char * name )
: ns( ns )
, tag( tag )
, name( name )
{
}
const char * const ns;
const char * const tag;
const char * const name;
bool operator==( const AdditionalAttributeData & other ) const
{
return ( qstrcmp( name, other.name ) == 0 );
}
};
/**
* constructor
* @param context the context created for generic ODF loading.
......@@ -117,6 +145,26 @@ public:
*/
KoSharedLoadingData * sharedData( const QString & id ) const;
/**
* @brief Add an additional attribute that should be loaded during shape loading
*
* An application can use that to set the data for additional attributes that should be
* loaded during shape loading.
* If attribute is set it will not change if set again. The tag is used to differentiate
* the attributes
*
* @param attributeData The data describing the additional attribute data
*/
static void addAdditionalAttributeData( const AdditionalAttributeData & attributeData );
/**
* @brief Get the additional attribute data for loading of a shape
*
* This is used by KoShape::loadOdfAttributes to load all additional attributes defined
* in the returned set.
*/
static QSet<AdditionalAttributeData> additionalAttributeData();
private:
/**
* Get the shape controller
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment