File indexing completed on 2024-12-22 04:11:44
0001 /* 0002 * SPDX-License-Identifier: GPL-3.0-or-later 0003 */ 0004 0005 #ifndef KOCOLORSET_P_H 0006 #define KOCOLORSET_P_H 0007 0008 #include <QHash> 0009 #include <QXmlStreamReader> 0010 #include <QDomElement> 0011 #include <QPointer> 0012 #include <kundo2stack.h> 0013 0014 #include <KisSwatch.h> 0015 #include <KisSwatchGroup.h> 0016 0017 #include "KoColorSet.h" 0018 0019 struct RiffHeader { 0020 quint32 riff; 0021 quint32 size; 0022 quint32 signature; 0023 quint32 data; 0024 quint32 datasize; 0025 quint16 version; 0026 quint16 colorcount; 0027 }; 0028 0029 class KoColorSet::Private 0030 { 0031 0032 public: 0033 Private(KoColorSet *a_colorSet); 0034 0035 public: 0036 KisSwatchGroupSP global() { 0037 Q_ASSERT(swatchGroups.size() > 0 && swatchGroups.first()->name() == GLOBAL_GROUP_NAME); 0038 return swatchGroups.first(); 0039 } 0040 public: 0041 bool init(); 0042 0043 bool saveGpl(QIODevice *dev) const; 0044 bool loadGpl(); 0045 0046 bool loadAct(); 0047 bool loadRiff(); 0048 bool loadPsp(); 0049 bool loadAco(); 0050 bool loadXml(); 0051 bool loadSbz(); 0052 bool loadAse(); 0053 bool loadAcb(); 0054 0055 bool saveKpl(QIODevice *dev) const; 0056 bool loadKpl(); 0057 0058 public: 0059 0060 KoColorSet *colorSet {0}; 0061 KoColorSet::PaletteType paletteType {UNKNOWN}; 0062 QByteArray data; 0063 QString comment; 0064 QList<KisSwatchGroupSP> swatchGroups; 0065 KUndo2Stack undoStack; 0066 bool isLocked {false}; 0067 int columns; 0068 0069 private: 0070 0071 friend struct AddSwatchCommand; 0072 friend struct RemoveSwatchCommand; 0073 friend struct ChangeGroupNameCommand; 0074 friend struct AddGroupCommand; 0075 friend struct RemoveGroupCommand; 0076 friend struct ClearCommand; 0077 friend struct SetColumnCountCommand; 0078 friend struct SetCommentCommand; 0079 friend struct SetPaletteTypeCommand; 0080 friend struct MoveGroupCommand; 0081 0082 KoColorSet::PaletteType detectFormat(const QString &fileName, const QByteArray &ba); 0083 void scribusParseColor(KoColorSet *set, QXmlStreamReader *xml); 0084 bool loadScribusXmlPalette(KoColorSet *set, QXmlStreamReader *xml); 0085 quint8 readByte(QIODevice *io); 0086 quint16 readShort(QIODevice *io); 0087 qint32 readInt(QIODevice *io); 0088 float readFloat(QIODevice *io); 0089 QString readUnicodeString(QIODevice *io, bool sizeIsInt = false); 0090 0091 const KoColorProfile *loadColorProfile(QScopedPointer<KoStore> &store, 0092 const QString &path, 0093 const QString &modelId, 0094 const QString &colorDepthId); 0095 0096 void saveKplGroup(QDomDocument &doc, QDomElement &groupEle, 0097 const KisSwatchGroupSP group, QSet<const KoColorSpace *> &colorSetSet) const; 0098 bool loadKplProfiles(QScopedPointer<KoStore> &store); 0099 bool loadKplColorset(QScopedPointer<KoStore> &store); 0100 bool loadSbzSwatchbook(QScopedPointer<KoStore> &store); 0101 void loadKplGroup(const QDomDocument &doc, const QDomElement &parentElement, KisSwatchGroupSP group, QString version); 0102 }; 0103 0104 #endif // KOCOLORSET_P_H