File indexing completed on 2024-05-26 16:14:54

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2011 Smit Patel <smitpatel24@gmail.com>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 #ifndef KOODFBIBLIOGRAPHYCONFIGURATION_H
0020 #define KOODFBIBLIOGRAPHYCONFIGURATION_H
0021 
0022 #include <QString>
0023 #include <QMetaType>
0024 #include <QObject>
0025 
0026 #include "KoXmlReader.h"
0027 #include "koodf_export.h"
0028 
0029 class KoXmlWriter;
0030 
0031 // TODO: add namespacing prefix
0032 typedef QPair<QString, Qt::SortOrder> SortKeyPair;
0033 
0034 /**
0035  * load and save the bibliography-configuration element from the text: namespace.
0036  * • Prefix
0037  * • Suffix
0038  * • Numbered entries
0039  * • Sort by position
0040  * • Sort algorithm
0041  */
0042 class KOODF_EXPORT KoOdfBibliographyConfiguration : public QObject
0043 {
0044     Q_OBJECT
0045 public:
0046 
0047     KoOdfBibliographyConfiguration();
0048     ~KoOdfBibliographyConfiguration() override;
0049     KoOdfBibliographyConfiguration(const KoOdfBibliographyConfiguration &other);
0050     KoOdfBibliographyConfiguration &operator=(const KoOdfBibliographyConfiguration &other);
0051 
0052     static const QList<QString> bibTypes;
0053     static const QList<QString> bibDataFields;
0054 
0055     /**
0056      * load the bibliography-configuration element
0057      */
0058     void loadOdf(const KoXmlElement &element);
0059 
0060     /**
0061      * save the bibliography-configuration element
0062      */
0063     void saveOdf(KoXmlWriter * writer) const;
0064 
0065     /**
0066      * Sort by position
0067      * If text:sort-by-position attribute is true then bibliography entries or citations will be
0068      * sorted according to their position in document.
0069      */
0070     bool sortByPosition() const;
0071     void setSortByPosition(bool enable);
0072 
0073     /**
0074      * Numbered entries
0075      * If text:numbered-entries attribute is true then bibliography entries or citations will be numbered.
0076      */
0077     bool numberedEntries() const;
0078     void setNumberedEntries(bool enable);
0079 
0080     /**
0081      * Prefix
0082      * The text:prefix attribute specifies prefix of bibliography entry or citation(text:bibliography-mark)
0083      */
0084     QString prefix() const;
0085     void setPrefix(const QString &prefixValue);
0086 
0087     /**
0088      * Suffix
0089      * The text:suffix attribute specifies suffix of bibliography entry or citation(text:bibliography-mark)
0090      */
0091     QString suffix() const;
0092     void setSuffix(const QString &suffixValue);
0093 
0094     /**
0095      * Sort algorithm
0096      * The text:sort-algorithm attribute specifies sorting algorithm for bibliography entry
0097      */
0098     QString sortAlgorithm() const;
0099     void setSortAlgorithm(const QString &algorithm);
0100 
0101     /**
0102      * Sort Keys
0103      * The text:sort-key attribute specifies sort key for bibliography entry
0104      */
0105     QVector<SortKeyPair> sortKeys() const;
0106     void setSortKeys(const QVector<SortKeyPair> &sortKeys);
0107 
0108 private:
0109 
0110     class Private;
0111     Private * const d;
0112 
0113 };
0114 
0115 Q_DECLARE_METATYPE(KoOdfBibliographyConfiguration*)
0116 
0117 #endif // KOODFBIBLIOGRAPHYCONFIGURATION_H