r23672 by jghali - PageItem_NoteFrame: add getNamedResources() overload in order to collect note styles

scribus-commit scribus-commit at lists.scribus.net
Mon Apr 27 01:08:32 UTC 2020


Author: jghali
Date: Mon Apr 27 01:08:32 2020
New Revision: 23672

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23672
Log:
PageItem_NoteFrame: add getNamedResources() overload in order to collect note styles

Modified:
    trunk/Scribus/scribus/pageitem_noteframe.cpp
    trunk/Scribus/scribus/pageitem_noteframe.h
    trunk/Scribus/scribus/resourcecollection.h

Modified: trunk/Scribus/scribus/pageitem_noteframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23672&path=/trunk/Scribus/scribus/pageitem_noteframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_noteframe.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_noteframe.cpp	Mon Apr 27 01:08:32 2020
@@ -131,6 +131,30 @@
 	else
 		m_SizeLocked = false;
 	deleteIt = false;
+}
+
+void PageItem_NoteFrame::getNamedResources(ResourceCollection& lists) const
+{
+	PageItem_TextFrame::getNamedResources(lists);
+
+	if (m_nstyle)
+		lists.collectNoteStyle(m_nstyle->name());
+}
+
+void PageItem_NoteFrame::replaceNamedResources(ResourceCollection& newNames)
+{
+	PageItem_TextFrame::replaceNamedResources(newNames);
+
+	if (m_nstyle)
+	{
+		const auto& rsrcNoteStyles = newNames.noteStyles();
+		auto it = rsrcNoteStyles.find(m_nstyle->name());
+		if ((it != rsrcNoteStyles.end()) && (*it != m_nstyle->name()))
+		{
+			NotesStyle* newStyle = m_Doc->getNotesStyle(*it);
+			setNoteStyle(newStyle);
+		}
+	}
 }
 
 void PageItem_NoteFrame::setNoteStyle(NotesStyle *nStyle, PageItem_TextFrame* master)

Modified: trunk/Scribus/scribus/pageitem_noteframe.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23672&path=/trunk/Scribus/scribus/pageitem_noteframe.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_noteframe.h	(original)
+++ trunk/Scribus/scribus/pageitem_noteframe.h	Mon Apr 27 01:08:32 2020
@@ -23,6 +23,9 @@
 
 	//overloaded text frame layouting
 	void layout() override;
+
+	void getNamedResources(ResourceCollection& lists) const override;
+	void replaceNamedResources(ResourceCollection& newNames) override;
 
 	//indicate if noteframe should be deleted
 	bool deleteIt;

Modified: trunk/Scribus/scribus/resourcecollection.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23672&path=/trunk/Scribus/scribus/resourcecollection.h
==============================================================================
--- trunk/Scribus/scribus/resourcecollection.h	(original)
+++ trunk/Scribus/scribus/resourcecollection.h	Mon Apr 27 01:08:32 2020
@@ -30,7 +30,7 @@
 /** 
 *   A simple structure which holds the names of all resources & styles used in a doc or part of a document.
 *   Also holds pointers to the doc's fontset and colorset.
-*   The names are stored as a QMap<QString,QString>. When a doc is queried for it's used resources, these
+*   The names are stored as a QMap<QString, QString>. When a doc is queried for it's used resources, these
 *   maps get an entry  (nam -> nam) for each used resource 'nam'. You can replace resources consistently by
 *   changing these maps and asking the doc to use the altered maps to change all old names to the new one.
 *   Operations:
@@ -44,16 +44,18 @@
 {
 	public:
 		ResourceCollection() {}
-		void collectFont(const QString& name)         { if (!name.isEmpty()) m_fonts.insert(name,name); }
-		void collectFontfeatures(const QString& name) { if (!name.isEmpty()) m_fontfeatures.insert(name,name); }
-		void collectPattern(const QString& name)      { if (!name.isEmpty()) m_patterns.insert(name,name); }
-		void collectColor(const QString& name)        { if (!name.isEmpty()) m_colors.insert(name,name); }
-		void collectGradient(const QString& name)     { if (!name.isEmpty()) m_gradients.insert(name,name); }
-		void collectStyle(const QString& name)        { if (!name.isEmpty()) m_pstyles.insert(name,name); }
-		void collectCharStyle(const QString& name)    { if (!name.isEmpty()) m_cstyles.insert(name,name); }
-		void collectLineStyle(const QString& name)    { if (!name.isEmpty()) m_linestyles.insert(name,name); }
-		void collectTableStyle(const QString& name)   { if (!name.isEmpty()) m_tableStyles.insert(name,name); }
-		void collectCellStyle(const QString& name)    { if (!name.isEmpty()) m_cellStyles.insert(name,name); }
+
+		void collectFont(const QString& name)         { if (!name.isEmpty()) m_fonts.insert(name, name); }
+		void collectFontfeatures(const QString& name) { if (!name.isEmpty()) m_fontfeatures.insert(name, name); }
+		void collectPattern(const QString& name)      { if (!name.isEmpty()) m_patterns.insert(name, name); }
+		void collectColor(const QString& name)        { if (!name.isEmpty()) m_colors.insert(name, name); }
+		void collectGradient(const QString& name)     { if (!name.isEmpty()) m_gradients.insert(name, name); }
+		void collectStyle(const QString& name)        { if (!name.isEmpty()) m_pstyles.insert(name, name); }
+		void collectCharStyle(const QString& name)    { if (!name.isEmpty()) m_cstyles.insert(name, name); }
+		void collectLineStyle(const QString& name)    { if (!name.isEmpty()) m_linestyles.insert(name, name); }
+		void collectTableStyle(const QString& name)   { if (!name.isEmpty()) m_tableStyles.insert(name, name); }
+		void collectCellStyle(const QString& name)    { if (!name.isEmpty()) m_cellStyles.insert(name, name); }
+		void collectNoteStyle(const QString& name)    { if (!name.isEmpty()) m_noteStyles.insert(name, name); }
 
 		void mapFont(const QString& oldname, const QString& newname)         { m_fonts.insert(oldname, newname); }
 		void mapPattern(const QString& oldname, const QString& newname)      { m_patterns.insert(oldname, newname); }
@@ -65,17 +67,19 @@
 		void mapLineStyle(const QString& oldname, const QString& newname)    { m_linestyles.insert(oldname, newname); }
 		void mapTableStyle(const QString& oldname, const QString& newname)   { m_tableStyles.insert(oldname, newname); }
 		void mapCellStyle(const QString& oldname, const QString& newname)    { m_cellStyles.insert(oldname, newname); }
+		void mapNoteStyle(const QString& oldname, const QString& newname)    { m_noteStyles.insert(oldname, newname); }
 
-		void mapFonts(const QMap<QString,QString>& newnames)        { m_fonts = newnames; }
-		void mapPatterns(const QMap<QString,QString>& newnames)     { m_patterns = newnames; }
-		void mapFontfeatures(const QMap<QString,QString>& newnames) { m_fontfeatures = newnames; }
-		void mapColors(const QMap<QString,QString>& newnames)       { m_colors = newnames; }
-		void mapGradients(const QMap<QString,QString>& newnames)    { m_gradients = newnames; }
-		void mapStyles(const QMap<QString,QString>& newnames)       { m_pstyles = newnames; }
-		void mapCharStyles(const QMap<QString,QString>& newnames)   { m_cstyles = newnames; }
-		void mapLineStyles(const QMap<QString,QString>& newnames)   { m_linestyles = newnames; }
-		void mapTableStyles(const QMap<QString,QString>& newnames)  { m_tableStyles = newnames; }
-		void mapCellStyles(const QMap<QString,QString>& newnames)   { m_cellStyles = newnames; }
+		void mapFonts(const QMap<QString, QString>& newnames)        { m_fonts = newnames; }
+		void mapPatterns(const QMap<QString, QString>& newnames)     { m_patterns = newnames; }
+		void mapFontfeatures(const QMap<QString, QString>& newnames) { m_fontfeatures = newnames; }
+		void mapColors(const QMap<QString, QString>& newnames)       { m_colors = newnames; }
+		void mapGradients(const QMap<QString, QString>& newnames)    { m_gradients = newnames; }
+		void mapStyles(const QMap<QString, QString>& newnames)       { m_pstyles = newnames; }
+		void mapCharStyles(const QMap<QString, QString>& newnames)   { m_cstyles = newnames; }
+		void mapLineStyles(const QMap<QString, QString>& newnames)   { m_linestyles = newnames; }
+		void mapTableStyles(const QMap<QString, QString>& newnames)  { m_tableStyles = newnames; }
+		void mapCellStyles(const QMap<QString, QString>& newnames)   { m_cellStyles = newnames; }
+		void mapNoteStyles(const QMap<QString, QString>& newnames)   { m_noteStyles = newnames; }
 
 		const QMap<QString, QString>& fonts()        { return m_fonts; }
 		const QMap<QString, QString>& fontfeatures() { return m_fontfeatures; }
@@ -87,6 +91,7 @@
 		const QMap<QString, QString>& lineStyles()   { return m_linestyles; }
 		const QMap<QString, QString>& tableStyles()  { return m_tableStyles; }
 		const QMap<QString, QString>& cellStyles()   { return m_cellStyles; }
+		const QMap<QString, QString>& noteStyles()   { return m_noteStyles; }
 
 		QList<QString> fontNames() const         { return m_fonts.keys(); }
 		QList<QString> patternNames() const      { return m_patterns.keys(); }
@@ -98,26 +103,29 @@
 		QList<QString> lineStyleNames() const    { return m_linestyles.keys(); }
 		QList<QString> tableStyleNames() const   { return m_tableStyles.keys(); }
 		QList<QString> cellStyleNames() const    { return m_cellStyles.keys(); }
+		QList<QString> noteStyleNames() const    { return m_noteStyles.keys(); }
 
 		// modifies newNames so that forall x in both newNames.key() and in existingNames, newNames[x] will map to a new unique name
-		static void makeUnique(QMap<QString,QString>& newNames, const QList<QString> existingNames);
+		static void makeUnique(QMap<QString, QString>& newNames, const QList<QString> existingNames);
 
 		void makeNamedResourcesUnique(ResourceCollection& other);
 
 		SCFonts* availableFonts {nullptr};
 		ColorList* availableColors {nullptr};
 		QMap<QString, VGradient> *availableGradients {nullptr};
+
 	private:
-		QMap<QString,QString> m_fonts;
-		QMap<QString,QString> m_patterns;
-		QMap<QString,QString> m_fontfeatures;
-		QMap<QString,QString> m_colors;
-		QMap<QString,QString> m_gradients;
-		QMap<QString,QString> m_pstyles;
-		QMap<QString,QString> m_cstyles;
-		QMap<QString,QString> m_linestyles;
-		QMap<QString,QString> m_tableStyles;
-		QMap<QString,QString> m_cellStyles;
+		QMap<QString, QString> m_fonts;
+		QMap<QString, QString> m_patterns;
+		QMap<QString, QString> m_fontfeatures;
+		QMap<QString, QString> m_colors;
+		QMap<QString, QString> m_gradients;
+		QMap<QString, QString> m_pstyles;
+		QMap<QString, QString> m_cstyles;
+		QMap<QString, QString> m_linestyles;
+		QMap<QString, QString> m_tableStyles;
+		QMap<QString, QString> m_cellStyles;
+		QMap<QString, QString> m_noteStyles;
 };
 
 #endif




More information about the scribus-commit mailing list