Commit 8c7a1aca authored by Inge Wallin's avatar Inge Wallin

Merge the git-libs-named_styles-ingwa branch into master

REVIEW: 109980

Squashed commit of the following:

commit 5b8d9b5315d03dfb797467abc95cdaad5a3c709c
Merge: 1939759 48a972a
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Fri Apr 12 18:27:26 2013 +0200

    Merge branch 'master' into libs-named_styles-ingwa

commit 19397593f2ef699dc2ca64ea6f77941a6bcd4b74
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Fri Apr 12 14:30:34 2013 +0200

    Implement loading of styles for use while traversing the odf files.

commit 89ec4c9251a73c3e5dcf5c0772bfc0f58e82aee2
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Fri Apr 12 14:29:54 2013 +0200

    Add a FIXME for later.

commit 33ae417997c6b06f10723472fde37be030d2b7bf
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Fri Apr 12 14:27:42 2013 +0200

    Fix a bug with saving style parent name.

commit 6ee0036fb69f5b4e2544c6a7837e388b90c84487
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Fri Apr 12 11:56:51 2013 +0200

    Implement saving of styles.

commit 8a6ede27c9e3f253d893613ea2fb3b2cfaebe0f5
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Fri Apr 12 07:05:44 2013 +0200

    Make the style read all properties, just not the first one.

commit fe05435f97c2b79d47e3e7c97544790ef5d6c32d
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Thu Apr 11 19:30:50 2013 +0200

    Fix some bugs with attributes in KoXmlStreamReader.

    This was done by letting KoXmlStreamAttributes emulate a QVector
    rather than inherit from it.

commit e6d403d8b88617a5cdb6d800ee9fcaf8d85d4e62
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Sun Apr 7 09:16:49 2013 +0200

    Port the styles classes to the KoXmlStreamReader.

commit bbf7e862847bf6ce1c98e810bc6f54316c309e49
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Sun Apr 7 09:15:10 2013 +0200

    Fix a bug with soundness calculation in the precense of unexpected namespaces.

commit 3d7d932026b615a351575820751dcdd8257192d8
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Sat Apr 6 20:38:22 2013 +0200

    Fix ugliness.

commit cb57db362f5dd04cbf9ed41581e79ff0b2402ae8
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Sat Apr 6 20:31:04 2013 +0200

    Implement attribute handling for unsound documents.

    Actually, the only thing that was left was to rewrite the prefix for
    attributes.

commit d27e4cf44386d9175fcbb9bbdf8c4966fe0b492a
Merge: d6d3898 d0643a2
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Sat Apr 6 16:35:34 2013 +0200

    Merge branch 'master' into libs-named_styles-ingwa

commit d6d38981ee95c0c68b9c2eff82da034ab3938037
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Sat Apr 6 16:16:24 2013 +0200

    Make attributes work for sound documents.

    This introduces the new classes KoXmlStreamAttribute and
    KoXmlStreamAttributes, which are API compatible equivalents of the
    corresponding QXmlStreamReader classes.

    So far the workings for unsound documents are not done yet.

commit 463d566f098c40816834d2044281328a61fe3da3
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Wed Apr 3 20:57:27 2013 +0200

    Disable copying of a KoXmlStreamReader.

commit 06ce87efd9b7121dbeb39542b341e8158cfcd593
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Wed Apr 3 20:40:06 2013 +0200

    Reimplement a little more of the QXmlStreamReader API

     * All the constructors
     * the setDevice() function

commit 4fcf23e3f5b36d4ee418cc614ee61cf2425eb88b
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Wed Apr 3 20:24:41 2013 +0200

    Also install the KoXmlStreamReader.h file

commit 124440310ad0042c8a657ceb687f74b6123e9cc6
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Wed Apr 3 20:23:32 2013 +0200

    Add a convenience function to prepare the stream reader for reading ODF.

commit 596521a04a332425d2539c057165e03f47169292
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Wed Apr 3 20:05:28 2013 +0200

    Clean up the API to KoXmlStreamReader.

    In particular, remove the extra struct that was declared previously.

    Thanks to Jaroslaw Staniek for valuable feedback.

commit 56e84833de1c0dc404894a730c8eb65921fd2dd8
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Tue Apr 2 22:39:33 2013 +0200

    First version of the KoXmlStreamReader.

    Attributes are still not handled and I need to do a lot of testing.
    But the main ideas are all in there.

commit 3938eec04343319785cbad8f10c455840a4ea626
Merge: b856e3b 00ff2b2
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Tue Apr 2 17:15:36 2013 +0200

    Merge branch 'master' into libs-named_styles-ingwa

commit b856e3ba7f61465ea00c88084b6a3ef35c1fbc67
Merge: 6e303e8 4a46fc5
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Thu Mar 28 15:22:42 2013 +0100

    Merge branch 'master' into libs-named_styles-ingwa

commit 6e303e81aa1ba950c4d75581568af86a71bfa76d
Merge: 4dc251b f9aba74
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Sun Mar 24 19:02:47 2013 +0100

    Merge branch 'master' into libs-named_styles-ingwa

commit 4dc251b109977a719537c12f43d2106b9488253e
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Sun Mar 24 19:00:37 2013 +0100

    Add a KoOdfStyleManager to Karbon and make it read the styles.

commit 41711859d0a4035647d2821b89588610e1bf0d9e
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Sun Mar 24 16:58:43 2013 +0100

    Initialize some values

commit 1c1c06f1d8d2b24ca488aa53d3537ea06e2babe5
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Sun Mar 24 16:48:16 2013 +0100

    Make the style manager load all styles.

    Also implement display-name

commit 4bf58b88976006a50e0e127315294ba20e7c0e62
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Sun Mar 24 15:33:48 2013 +0100

    Read styles and property set attributes.

    Most style attributes and property set children are not yet read.

commit 8d22a38864e49bcc9dfa95f7a63151c0ca8e86fd
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Sun Mar 24 08:26:51 2013 +0100

    Split KoOdfStyleProperties into its own file.

commit d83ad0872c6f45b24109e8a88105b180c5cc799e
Merge: acf47fc 736ad31
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Thu Mar 21 07:54:42 2013 +0100

    Merge branch 'master' into libs-named_styles-ingwa

commit acf47fc833b5e56d0b4feec4f2ec0aad0455f68d
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Fri Mar 8 11:41:52 2013 +0100

    Copy loading of styles from the epub filter and adapt it

commit bf4604b870bf957e9f01ad6748ba02cb5ef3c672
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Fri Mar 8 10:00:57 2013 +0100

    Some minor changes

     - Switch to QHash from QMap
     - Some name changes
     - Some rearranging of the code

commit 5418bf6222ba8af07a1b6bc9caf2ba2eb6bbf52d
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Fri Mar 8 09:33:49 2013 +0100

    Add a flag to tell whether a style is in use.

    This is used when the styles are sorted in style selectors in the UI.

commit e2789d78aca233cce431ce7f292508f893d1f914
Merge: 509f638 68b1bfb
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Fri Mar 8 09:04:47 2013 +0100

    Merge branch 'master' into libs-named_styles-ingwa

commit 509f638e25fae5ada70478f6ae481374fe316993
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Sun Mar 3 02:34:40 2013 +0100

    Fix includes

commit b8fcabf8a8d338b08922ed316ede1f52b6ab21b8
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Sun Mar 3 02:27:25 2013 +0100

    Add the embryo to a new style manager.

commit 1b5798e5aea65de88322aaab47ee761fabf4564a
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Sun Mar 3 01:42:24 2013 +0100

    Add some nice defaults

commit ba7db6b0492c76a66d60861ba4583aba3c676be9
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Sun Mar 3 01:24:02 2013 +0100

    Added new style storage class

commit b3a1d64dfd38d7c459cf26036aade7c2946624a4
Author: Inge Wallin <inge@lysator.liu.se>
Date:   Sat Mar 2 00:34:09 2013 +0100

    Normalize SIGNAL and SLOT signatures in the chart shape.
parent 0ab08e1e
......@@ -666,6 +666,7 @@ set(KOPLUGIN_INCLUDES ${CMAKE_SOURCE_DIR}/libs/koplugin)
# koodf is at the bottom of the stack
set(KOODF_INCLUDES ${CMAKE_SOURCE_DIR}/libs/odf
${CMAKE_SOURCE_DIR}/libs/odf/styles
${CMAKE_BINARY_DIR}/libs/odf
${KDE4_INCLUDES})
......
......@@ -40,6 +40,7 @@ set(koodf_LIB_SRCS
KoTarStore.cpp
KoDirectoryStore.cpp
KoZipStore.cpp
KoXmlStreamReader.cpp
KoXmlReader.cpp
KoXmlWriter.cpp
KoEncryptedStore.cpp
......@@ -63,6 +64,10 @@ set(koodf_LIB_SRCS
KoRowStyle.cpp
KoTblStyle.cpp
KoElementReference.cpp
styles/KoOdfStyle.cpp
styles/KoOdfStyleProperties.cpp
styles/KoOdfStyleManager.cpp
)
kde4_add_library(koodf SHARED ${koodf_LIB_SRCS})
......@@ -113,6 +118,7 @@ install( FILES
KoColumns.h
KoStore.h
KoStoreDevice.h
KoXmlStreamReader.h
KoXmlReader.h
KoXmlWriter.h
KoXmlReaderForward.h
......
This diff is collapsed.
/* This file is part of the KDE project
Copyright (C) 2013 Inge Wallin <inge@lysator.liu.se>
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 KOXMLSTREAMREADER_H
#define KOXMLSTREAMREADER_H
#include "KoXmlStreamReader.h"
#include <QXmlStreamReader>
#include <QStringRef>
#include <QVector>
#include <QSharedData>
#include "koodf_export.h"
class QByteArray;
class QString;
class QIODevice;
class KoXmlStreamAttributes;
/**
* @brief An XML stream reader based on QXmlStreamReader and with namespace handling better suited to use for ODF in Calligra.
*
* Opendocument uses an XML encoding which makes heavy use of
* namespaces. So normally you would want to compare the qualified
* name when accessing tagnames and attributes.
*
* However, in QXmlStreamReader you have to either make an explicit
* comparison with the namespace URI for every element and attribute
* or risk that documents that use the correct namespaces but not the
* normal namespace prefixes are wrongly interpreted. This is because
* the prefix (e.g. "fo" in "fo:border-width") is declared at the
* beginning of the document using a namespace declaration attribute
* such as: xmlns:fo="http://www.w3.org/1999/XSL/Format". In this case
* xmlns:fo could just as well be xmlns:xxx which makes the expected
* fo:border-width become xxx:border-width in the rest of this
* document.
*
* However, it is extremely rare to find document that uses such
* non-standard namespace prefixes. This gives us the opportunity to
* optimize for the common case, which is exactly what
* KoXmlStreamReader does.
*
* The way to use this class is to tell it which namespaces and
* prefixes that you expect before you open the XML stream. Then it
* checks if the namespaces and prefixes in the document are the same
* as the expected ones. If they are in fact the same, the document
* is pronounced "sound", and for the rest of the processing you can
* use the qualified name with the expected prefix ("fo:border-width")
* with the maximum performance.
*
* If the namespace(s) in the document are the expected ones but the
* prefix(es) are not, you can still compare the qualified name to
* your expected ones. But in this case the document is deemed
* "unsound" and for every access to attributes or calls to
* qualifiedName(), KoXmlStreamReader will rewrite the actual name in
* the document to become what you expect. The functions
* namespaceUri() and name() are not affected, only the prefixes.
*/
class KOODF_EXPORT KoXmlStreamReader : public QXmlStreamReader
{
friend class KoXmlStreamAttribute;
friend class KoXmlStreamAttributes;
public:
KoXmlStreamReader();
KoXmlStreamReader(QIODevice *device);
KoXmlStreamReader(const QByteArray &data);
KoXmlStreamReader(const QString &data);
KoXmlStreamReader(const char *data);
~KoXmlStreamReader();
void clear();
void addExpectedNamespace(QString prefix, QString namespaceUri);
void addExtraNamespace(QString prefix, QString namespaceUri);
// --------------------------------
// Reimplemented from QXmlStreamReader
QStringRef prefix() const;
QStringRef qualifiedName() const;
void setDevice(QIODevice *device);
KoXmlStreamAttributes attributes() const;
private:
// No copying
KoXmlStreamReader(KoXmlStreamReader &other);
KoXmlStreamReader &operator=(KoXmlStreamReader &other);
// Only for friend classes KoXmlStreamAttributes and KoXmlStreamAttribute.
bool isSound() const;
class Private;
Private * const d;
};
/**
* @brief KoXmlStreamAttribute is a source-compatible replacement for QXmlStreamAttribute.
*
* In addition to the API from QXmlStreamAttribute, it offers the same
* advantages that KoXmlStreamReader does over QXmlStreamReader: when
* asked for the qualified name of an attribute it will return the
* expected one even if the prefix declared in the namespace
* declaration of the document is different.
*
* @see KoXmlStreamReader
*/
class KoXmlStreamAttribute
{
friend class QVector<KoXmlStreamAttribute>; // For the default constructor
friend class KoXmlStreamAttributes; // For the normal constructor
friend class KoXmlStreamReader;
public:
~KoXmlStreamAttribute();
// API taken from QXmlStreamAttribute
bool isDefault() const;
QStringRef name() const;
QStringRef namespaceUri() const;
QStringRef prefix() const;
QStringRef qualifiedName() const;
QStringRef value() const;
bool operator==(const KoXmlStreamAttribute &other) const;
bool operator!=(const KoXmlStreamAttribute &other) const;
KoXmlStreamAttribute &operator=(const KoXmlStreamAttribute &other);
private:
// Only for friend classes.
KoXmlStreamAttribute();
KoXmlStreamAttribute(const KoXmlStreamAttribute &other);
KoXmlStreamAttribute(const QXmlStreamAttribute *attr, const KoXmlStreamReader *reader);
class Private;
Private * const d;
};
/**
* @brief KoXmlStreamAttributes is a mostly source-compatible replacement for QXmlStreamAttributes.
*
* All the convenience functions of KoXmlStreamAttributes work exactly
* like the counterparts of QXmlStreamAttributes but they give the
* expected prefix for the registered expected namespaces.
*
* Not all functions from QVector are implemented but the ones that
* make sense for this read-only class are. This class can only be
* used in connection with KoXmlStreamReader.
*
* @see KoXmlStreamReader
*/
class KoXmlStreamAttributes
{
friend class KoXmlStreamReader;
public:
typedef const KoXmlStreamAttribute *const_iterator;
KoXmlStreamAttributes(const KoXmlStreamAttributes &other);
~KoXmlStreamAttributes();
KoXmlStreamAttributes &operator=(const KoXmlStreamAttributes &other);
// Relevant parts of the QVector API
const KoXmlStreamAttribute &at(int i) const;
int size() const;
KoXmlStreamAttribute value(int i) const;
const KoXmlStreamAttribute &operator[](int i) const;
const_iterator begin() const;
const_iterator end() const;
// Convenience functions taken from QXmlStreamAttributes API
void append(const QString &namespaceUri, const QString &name, const QString &value);
void append(const QXmlStreamAttribute &attribute);
void append(const QString &qualifiedName, const QString &value);
bool hasAttribute(const QString &qualifiedName) const;
bool hasAttribute(const QLatin1String &qualifiedName) const;
bool hasAttribute ( const QString & namespaceUri, const QString & name ) const;
QStringRef value ( const QString & namespaceUri, const QString & name ) const;
QStringRef value ( const QString & namespaceUri, const QLatin1String & name ) const;
QStringRef value ( const QLatin1String & namespaceUri, const QLatin1String & name ) const;
QStringRef value(const QString &qualifiedName) const;
QStringRef value(const QLatin1String &qualifiedName) const;
private:
// Only available from friend class KoXmlStreamReader.
KoXmlStreamAttributes(const KoXmlStreamReader *r, const QXmlStreamAttributes &qAttrs);
// This class is implicitly shared.
class Private;
QSharedDataPointer<Private> d;
};
void prepareForOdf(KoXmlStreamReader &reader);
#endif /* KOGENCHANGES_H */
/* This file is part of the KDE project
*
* Copyright (C) 2013 Inge Wallin <inge@lysator.liu.se>
*
* 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.
*/
// Own
#include "KoOdfStyle.h"
// Qt
#include <QString>
// KDE
#include <kdebug.h>
// Odflib
#include "KoXmlStreamReader.h"
#include "KoXmlWriter.h"
#include "KoOdfStyleProperties.h"
// ================================================================
// class KoOdfStyle
class KoOdfStyle::Private
{
public:
Private();
~Private();
QString name;
QString family;
QString parent;
QString displayName;
bool isDefaultStyle;
bool inUse;
//
QHash<QString, KoOdfStyleProperties*> properties; // e.g. "text-properties",
};
KoOdfStyle::Private::Private()
: isDefaultStyle(false)
, inUse(false)
{
}
KoOdfStyle::Private::~Private()
{
qDeleteAll(properties);
}
// ----------------------------------------------------------------
KoOdfStyle::KoOdfStyle()
: d(new KoOdfStyle::Private())
{
}
KoOdfStyle::~KoOdfStyle()
{
delete d;
}
QString KoOdfStyle::name() const
{
return d->name;
}
void KoOdfStyle::setName(QString &name)
{
d->name = name;
}
QString KoOdfStyle::family() const
{
return d->family;
}
void KoOdfStyle::setFamily(QString &family)
{
d->family = family;
}
QString KoOdfStyle::parent() const
{
return d->parent;
}
void KoOdfStyle::setParent(QString &parent)
{
d->parent = parent;
}
QString KoOdfStyle::displayName() const
{
return d->displayName;
}
void KoOdfStyle::setDisplayName(QString &name)
{
d->displayName = name;
}
bool KoOdfStyle::isDefaultStyle() const
{
return d->isDefaultStyle;
}
void KoOdfStyle::setIsDefaultStyle(bool isDefaultStyle)
{
d->isDefaultStyle = isDefaultStyle;
}
bool KoOdfStyle::inUse() const
{
return d->inUse;
}
void KoOdfStyle::setInUse(bool inUse)
{
d->inUse = inUse;
}
QHash<QString, KoOdfStyleProperties*> KoOdfStyle::properties()
{
return d->properties;
}
KoOdfStyleProperties *KoOdfStyle::properties(QString &name) const
{
return d->properties.value(name, 0);
}
QString KoOdfStyle::property(QString &propertySet, QString &property) const
{
KoOdfStyleProperties *props = d->properties.value(propertySet, 0);
if (props)
return props->value(property);
else
return QString();
}
void KoOdfStyle::setProperty(QString &propertySet, QString &property, QString &value)
{
KoOdfStyleProperties *props = d->properties.value(propertySet);
if (!props)
props = new KoOdfStyleProperties();
props->setValue(property, value);
}
bool KoOdfStyle::readOdf(KoXmlStreamReader &reader)
{
// Load style attributes.
KoXmlStreamAttributes attrs = reader.attributes();
QString dummy; // Because the set*() methods take a QString &,
dummy = attrs.value("style:family").toString();
setFamily(dummy);
dummy = attrs.value("style:name").toString();
setName(dummy);
dummy = attrs.value("style:parent-style-name").toString();
setParent(dummy);
dummy = attrs.value("style:display-name").toString();
setDisplayName(dummy);
kDebug() << "Style:" << name() << family() << parent() << displayName();
// Load child elements: property sets and other children.
while (reader.readNextStartElement()) {
// So far we only have support for text-, paragaph- and graphic-properties
QString propertiesType = reader.qualifiedName().toString();
if (propertiesType == "style:text-properties"
|| propertiesType == "style:paragraph-properties"
|| propertiesType == "style:graphic-properties")
{
kDebug() << "properties type: " << propertiesType;
// FIXME: In the future, create per type.
KoOdfStyleProperties *properties = new KoOdfStyleProperties();
if (!properties->readOdf(reader)) {
return false;
}
d->properties[propertiesType] = properties;
}
}
return true;
}
bool KoOdfStyle::saveOdf(KoXmlWriter *writer)
{
if (d->isDefaultStyle) {
writer->startElement("style:default-style");
writer->addAttribute("style:name", d->name);
}
else {
writer->startElement("style:style");
}
// Write style attributes
writer->addAttribute("style:family", d->family);
if (!d->parent.isEmpty()) {
writer->addAttribute("style:parent-style-name", d->parent);
}
if (!d->displayName.isEmpty()) {
writer->addAttribute("style:display-name", d->displayName);
}
// Write properties
foreach(const QString &propertySet, d->properties.keys()) {
d->properties.value(propertySet)->saveOdf(propertySet, writer);
}
writer->endElement(); // style:{default-,}style
return true;
}
/* This file is part of the KDE project
*
* Copyright (C) 2013 Inge Wallin <inge@lysator.liu.se>
*
* 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 KOODF_STYLE_H
#define KOODF_STYLE_H
#include "koodf_export.h"
#include <QHash>
class QString;
class KoXmlStreamReader;
class KoOdfStyleProperties;
class KoXmlWriter;
class KOODF_EXPORT KoOdfStyle
{
public:
KoOdfStyle();
~KoOdfStyle();
QString name() const;
void setName(QString &name);
QString family() const;
void setFamily(QString &family);
QString parent() const;
void setParent(QString &parent);
QString displayName() const;
void setDisplayName(QString &name);
bool inUse() const;
void setInUse(bool inUse);
bool isDefaultStyle() const;
void setIsDefaultStyle(bool isDefaultStyle);
QHash<QString, KoOdfStyleProperties*> properties();
/**
* @brief Return the list of properties in the selected property set.
* @param name name of the property set. Example: "text-properties" or "paragraph-properties"
*/
KoOdfStyleProperties *properties(QString &name) const;
QString property(QString &propertySet, QString &property) const;
void setProperty(QString &propertySet, QString &property, QString &value);
bool readOdf(KoXmlStreamReader &reader);
bool saveOdf(KoXmlWriter *writer);
private:
class Private;
Private * const d;
};
#endif
/* This file is part of the KDE project
*
* Copyright (C) 2013 Inge Wallin <inge@lysator.liu.se>
*
* 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.
*/
// Own
#include "KoOdfStyleManager.h"
// Qt
#include <QHash>
#include <QString>
// KDE
#include <kdebug.h>
// odf lib
#include "KoStore.h"
#include <KoOdfReadStore.h>
#include <KoXmlStreamReader.h>
#include <KoXmlNS.h>
#include <KoXmlWriter.h>
#include "KoOdfStyle.h"
// ================================================================
// class KoOdfStyleManager
class KoOdfStyleManager::Private
{
public:
Private() {};
QHash<QString, KoOdfStyle*> styles; // name, style
QHash<QString, KoOdfStyle*> defaultStyles; // family, style
};
// ----------------------------------------------------------------
KoOdfStyleManager::KoOdfStyleManager()
: d(new KoOdfStyleManager::Private())
{
}
KoOdfStyleManager::~KoOdfStyleManager()
{
delete d;