Back to index

scribus-ng  1.3.4.dfsg+svn20071115
resourcecollection.h
Go to the documentation of this file.
00001 /*
00002  For general Scribus (>=1.3.2) copyright and licensing information please refer
00003  to the COPYING file provided with the program. Following this notice may exist
00004  a copyright and/or license notice that predates the release of Scribus 1.3.2
00005  for which a new license (GPL+exception) is in place.
00006  */
00007 /***************************************************************************
00008 *                                                                         *
00009 *   This program is free software; you can redistribute it and/or modify  *
00010 *   it under the terms of the GNU General Public License as published by  *
00011 *   the Free Software Foundation; either version 2 of the License, or     *
00012 *   (at your option) any later version.                                   *
00013 *                                                                         *
00014 ***************************************************************************/
00015 
00016 
00017 #ifndef RESOURCE_COLLECTION_H
00018 #define RESOURCE_COLLECTION_H
00019 
00020 #include <qstring.h>
00021 #include <qmap.h>
00022 #include <qvaluelist.h>
00023 
00024 #include "scfonts.h"
00025 #include "sccolor.h"
00026 
00040 class ResourceCollection
00041 {
00042 public:
00043        void collectFont(const QString& name)      { if (!name.isEmpty()) m_fonts.insert(name,name); }
00044        void collectPattern(const QString& name)   { if (!name.isEmpty()) m_patterns.insert(name,name); }
00045        void collectColor(const QString& name)     { if (!name.isEmpty()) m_colors.insert(name,name); }
00046        void collectStyle(const QString& name)     { if (!name.isEmpty()) m_pstyles.insert(name,name); }
00047        void collectCharStyle(const QString& name) { if (!name.isEmpty()) m_cstyles.insert(name,name); }
00048        void collectLineStyle(const QString& name) { if (!name.isEmpty()) m_linestyles.insert(name,name); }
00049        
00050        void mapFont(const QString& oldname, const QString& newname)      { m_fonts.insert(oldname, newname); }
00051        void mapPattern(const QString& oldname, const QString& newname)   { m_patterns.insert(oldname, newname); }
00052        void mapColor(const QString& oldname, const QString& newname)     { m_colors.insert(oldname, newname); }
00053        void mapStyle(const QString& oldname, const QString& newname)     { m_pstyles.insert(oldname, newname); }
00054        void mapCharStyle(const QString& oldname, const QString& newname) { m_cstyles.insert(oldname, newname); }
00055        void mapLineStyle(const QString& oldname, const QString& newname) { m_linestyles.insert(oldname, newname); }
00056        
00057        void mapFonts(const QMap<QString,QString>& newnames)      { m_fonts = newnames; }
00058        void mapPatterns(const QMap<QString,QString>& newnames)   { m_patterns = newnames; }
00059        void mapColors(const QMap<QString,QString>& newnames)     { m_colors = newnames; }
00060        void mapStyles(const QMap<QString,QString>& newnames)     { m_pstyles = newnames; }
00061        void mapCharStyles(const QMap<QString,QString>& newnames) { m_cstyles = newnames; }
00062        void mapLineStyles(const QMap<QString,QString>& newnames) { m_linestyles = newnames; }
00063        
00064        const QMap<QString, QString>& fonts()      { return m_fonts; }
00065        const QMap<QString, QString>& patterns()   { return m_patterns; }
00066        const QMap<QString, QString>& colors()     { return m_colors; }
00067        const QMap<QString, QString>& styles()     { return m_pstyles; }
00068        const QMap<QString, QString>& charStyles() { return m_cstyles; }
00069        const QMap<QString, QString>& lineStyles() { return m_linestyles; }
00070        
00071        QValueList<QString> fontNames() const      { return m_fonts.keys(); }
00072        QValueList<QString> patternNames() const   { return m_patterns.keys(); }
00073        QValueList<QString> colorNames() const     { return m_colors.keys(); }
00074        QValueList<QString> styleNames() const     { return m_pstyles.keys(); }
00075        QValueList<QString> charStyleNames() const { return m_cstyles.keys(); }
00076        QValueList<QString> lineStyleNames() const { return m_linestyles.keys(); }
00077 
00078        // modifies newNames so that forall x in both newNames.key() and in existingNames, newNames[x] will map to a new unique name
00079        static void makeUnique(QMap<QString,QString>& newNames, const QValueList<QString> existingNames);
00080 
00081        void makeNamedResourcesUnique(ResourceCollection& other);
00082        
00083        SCFonts* availableFonts;
00084        ColorList* availableColors;
00085 private:
00086        QMap<QString,QString> m_fonts;
00087        QMap<QString,QString> m_patterns;
00088        QMap<QString,QString> m_colors;
00089        QMap<QString,QString> m_pstyles;
00090        QMap<QString,QString> m_cstyles;
00091        QMap<QString,QString> m_linestyles;
00092 };
00093 
00094 
00095 #endif