From scribus-commit at lists.scribus.net Tue Dec 1 10:30:38 2020 From: scribus-commit at lists.scribus.net (scribus-commit) Date: Tue, 01 Dec 2020 10:30:38 -0000 Subject: r24303 by jghali - #16365: Opening attached PDF in Scribus leads to crash Message-ID: Author: jghali Date: Tue Dec 1 10:30:37 2020 New Revision: 24303 URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24303 Log: #16365: Opening attached PDF in Scribus leads to crash Modified: trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp Modified: trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24303&path=/trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp ============================================================================== --- trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp (original) +++ trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp Tue Dec 1 10:30:37 2020 @@ -797,7 +797,7 @@ LinkAction *linkAction = nullptr; linkAction = LinkAction::parseAction(&names, pdfDoc->getCatalog()->getBaseURI()); #endif - if (linkAction) + if (linkAction && (linkAction.get()->getKind() == actionJavaScript)) { #if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) LinkJavaScript *jsa = (LinkJavaScript*) linkAction.get(); From scribus-commit at lists.scribus.net Thu Dec 3 16:07:01 2020 From: scribus-commit at lists.scribus.net (scribus-commit) Date: Thu, 03 Dec 2020 16:07:01 -0000 Subject: r24304 by jghali - Fix build with old poppler versions Message-ID: Author: jghali Date: Thu Dec 3 16:07:01 2020 New Revision: 24304 URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24304 Log: Fix build with old poppler versions Modified: trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp Modified: trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24304&path=/trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp ============================================================================== --- trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp (original) +++ trunk/Scribus/scribus/plugins/import/pdf/importpdf.cpp Thu Dec 3 16:07:01 2020 @@ -791,19 +791,15 @@ if (names.isDict()) { #if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) - std::unique_ptr linkAction; - linkAction = LinkAction::parseAction(&names, pdfDoc->getCatalog()->getBaseURI()); + std::unique_ptr linkActionUPtr = LinkAction::parseAction(&names, pdfDoc->getCatalog()->getBaseURI()); + LinkAction *linkAction = linkActionUPtr.get(); #else LinkAction *linkAction = nullptr; linkAction = LinkAction::parseAction(&names, pdfDoc->getCatalog()->getBaseURI()); #endif - if (linkAction && (linkAction.get()->getKind() == actionJavaScript)) + if (linkAction && (linkAction->getKind() == actionJavaScript)) { -#if POPPLER_ENCODED_VERSION >= POPPLER_VERSION_ENCODE(0, 86, 0) - LinkJavaScript *jsa = (LinkJavaScript*) linkAction.get(); -#else LinkJavaScript *jsa = (LinkJavaScript*) linkAction; -#endif if (jsa->isOk()) { QString script = UnicodeParsedString(jsa->getScript()); From scribus-commit at lists.scribus.net Sat Dec 5 21:22:11 2020 From: scribus-commit at lists.scribus.net (scribus-commit) Date: Sat, 05 Dec 2020 21:22:11 -0000 Subject: r24305 by jghali - Some strings fixes from Weblate Message-ID: Author: jghali Date: Sat Dec 5 21:22:10 2020 New Revision: 24305 URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24305 Log: Some strings fixes from Weblate Modified: trunk/Scribus/scribus/plugins/import/ai/importaiplugin.cpp trunk/Scribus/scribus/plugins/import/idml/importidmlplugin.cpp trunk/Scribus/scribus/plugins/import/idml_old/importidml.cpp trunk/Scribus/scribus/ui/annota.cpp Modified: trunk/Scribus/scribus/plugins/import/ai/importaiplugin.cpp URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24305&path=/trunk/Scribus/scribus/plugins/import/ai/importaiplugin.cpp ============================================================================== --- trunk/Scribus/scribus/plugins/import/ai/importaiplugin.cpp (original) +++ trunk/Scribus/scribus/plugins/import/ai/importaiplugin.cpp Sat Dec 5 21:22:10 2020 @@ -167,8 +167,8 @@ msgBox.setText( tr("This file contains 2 versions of the data.")); msgBox.setInformativeText( tr("Choose which one should be imported")); msgBox.setIcon(QMessageBox::Question); - QPushButton *pdfButton = msgBox.addButton( tr("Use the pdf part"), QMessageBox::ActionRole); - msgBox.addButton( tr("Use the ai part"), QMessageBox::ActionRole); + QPushButton *pdfButton = msgBox.addButton( tr("Use the PDF part"), QMessageBox::ActionRole); + msgBox.addButton( tr("Use the AI part"), QMessageBox::ActionRole); msgBox.setDefaultButton(pdfButton); msgBox.exec(); if ((QPushButton *)msgBox.clickedButton() == pdfButton) Modified: trunk/Scribus/scribus/plugins/import/idml/importidmlplugin.cpp URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24305&path=/trunk/Scribus/scribus/plugins/import/idml/importidmlplugin.cpp ============================================================================== --- trunk/Scribus/scribus/plugins/import/idml/importidmlplugin.cpp (original) +++ trunk/Scribus/scribus/plugins/import/idml/importidmlplugin.cpp Sat Dec 5 21:22:10 2020 @@ -58,11 +58,11 @@ { importAction->setText( tr("Import Idml...")); FileFormat* fmt = getFormatByExt("idml"); - fmt->trName = tr("Adobe Indesign IDML"); - fmt->filter = tr("Adobe Indesign IDML (*.idml *.IDML)"); + fmt->trName = tr("Adobe InDesign IDML"); + fmt->filter = tr("Adobe InDesign IDML (*.idml *.IDML)"); FileFormat* fmt2 = getFormatByExt("idms"); - fmt2->trName = tr("Adobe Indesign IDMS"); - fmt2->filter = tr("Adobe Indesign IDMS (*.idms *.IDMS)"); + fmt2->trName = tr("Adobe InDesign IDMS"); + fmt2->filter = tr("Adobe InDesign IDMS (*.idms *.IDMS)"); } ImportIdmlPlugin::~ImportIdmlPlugin() @@ -96,8 +96,8 @@ void ImportIdmlPlugin::registerFormats() { FileFormat fmt(this); - fmt.trName = tr("Adobe Indesign IDML"); - fmt.filter = tr("Adobe Indesign IDML (*.idml *.IDML)"); + fmt.trName = tr("Adobe InDesign IDML"); + fmt.filter = tr("Adobe InDesign IDML (*.idml *.IDML)"); fmt.formatId = 0; fmt.fileExtensions = QStringList() << "idml"; fmt.load = true; @@ -110,8 +110,8 @@ registerFormat(fmt); FileFormat fmt2(this); - fmt2.trName = tr("Adobe Indesign IDMS"); - fmt2.filter = tr("Adobe Indesign IDMS (*.idms *.IDMS)"); + fmt2.trName = tr("Adobe InDesign IDMS"); + fmt2.filter = tr("Adobe InDesign IDMS (*.idms *.IDMS)"); fmt2.formatId = 0; fmt2.fileExtensions = QStringList() << "idms"; fmt2.load = true; Modified: trunk/Scribus/scribus/plugins/import/idml_old/importidml.cpp URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24305&path=/trunk/Scribus/scribus/plugins/import/idml_old/importidml.cpp ============================================================================== --- trunk/Scribus/scribus/plugins/import/idml_old/importidml.cpp (original) +++ trunk/Scribus/scribus/plugins/import/idml_old/importidml.cpp Sat Dec 5 21:22:10 2020 @@ -49,8 +49,8 @@ void ImportIdml::languageChange() { FileFormat* fmt = getFormatByExt("idml"); - fmt->trName = tr("Adobe Indesign IDML"); - fmt->filter = tr("Adobe Indesign IDML (*.idml *.IDML)"); + fmt->trName = tr("Adobe InDesign IDML"); + fmt->filter = tr("Adobe InDesign IDML (*.idml *.IDML)"); } const QString ImportIdml::fullTrName() const @@ -62,8 +62,8 @@ { AboutData* about = new AboutData; about->authors = "Jain Basil Aliyas"; - about->shortDescription = tr("Imports Adobe Idml Packages"); - about->description = tr("Imports Adobe Indesign's idml packages into Scribus\n converting Indesign objects into scribus pageitems; not all are supported in Scribus, but all those supported are being imported here"); + about->shortDescription = tr("Imports Adobe IDML Packages"); + about->description = tr("Imports Adobe InDesign's IDML packages into Scribus\n converting InDesign objects into Scribus pageitems; not all are supported in Scribus, but all those supported are being imported here"); about->license = tr("GPL"); Q_CHECK_PTR(about); return about; @@ -78,7 +78,7 @@ void ImportIdml::registerFormats() { FileFormat fmt(this); - QString idmlName=tr("Adobe Indesign IDML"); + QString idmlName=tr("Adobe InDesign IDML"); fmt.trName = idmlName; fmt.formatId = 0; fmt.filter =idmlName + "(*.idml *.IDML)"; // QFileDialog filter Modified: trunk/Scribus/scribus/ui/annota.cpp URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24305&path=/trunk/Scribus/scribus/ui/annota.cpp ============================================================================== --- trunk/Scribus/scribus/ui/annota.cpp (original) +++ trunk/Scribus/scribus/ui/annota.cpp Sat Dec 5 21:22:10 2020 @@ -131,7 +131,7 @@ iconCombo->addItem( tr("Comment")); iconCombo->addItem( tr("Key")); iconCombo->addItem( tr("Help")); - iconCombo->addItem( tr("NewParagraph")); + iconCombo->addItem( tr("New Paragraph")); iconCombo->addItem( tr("Paragraph")); iconCombo->addItem( tr("Insert")); iconCombo->addItem( tr("Cross")); From scribus-commit at lists.scribus.net Sat Dec 5 23:35:35 2020 From: scribus-commit at lists.scribus.net (scribus-commit) Date: Sat, 05 Dec 2020 23:35:35 -0000 Subject: r24306 by jghali - Small indentation fix Message-ID: Author: jghali Date: Sat Dec 5 23:35:35 2020 New Revision: 24306 URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24306 Log: Small indentation fix Modified: trunk/Scribus/scribus/pdflib_core.cpp Modified: trunk/Scribus/scribus/pdflib_core.cpp URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24306&path=/trunk/Scribus/scribus/pdflib_core.cpp ============================================================================== --- trunk/Scribus/scribus/pdflib_core.cpp (original) +++ trunk/Scribus/scribus/pdflib_core.cpp Sat Dec 5 23:35:35 2020 @@ -1094,7 +1094,7 @@ else if (Options.displayThumbs) PutDoc("/PageMode /UseThumbs\n"); else if ((Options.Version == PDFVersion::PDF_15 || Options.Version == PDFVersion::PDF_16) && (Options.displayLayers)) - PutDoc("/PageMode /UseOC\n"); + PutDoc("/PageMode /UseOC\n"); if (!Options.openAction.isEmpty()) { writer.OpenActionObj = writer.newObject(); From scribus-commit at lists.scribus.net Sun Dec 6 00:41:14 2020 From: scribus-commit at lists.scribus.net (scribus-commit) Date: Sun, 06 Dec 2020 00:41:14 -0000 Subject: r24307 by jghali - #11420: improvements related to text styles management during page import Message-ID: Author: jghali Date: Sun Dec 6 00:41:14 2020 New Revision: 24307 URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24307 Log: #11420: improvements related to text styles management during page import Modified: trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp trunk/Scribus/scribus/scribusdoc.cpp trunk/Scribus/scribus/scribusdoc.h trunk/Scribus/scribus/style.h trunk/Scribus/scribus/styles/style.cpp trunk/Scribus/scribus/styles/styleset.h Modified: trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24307&path=/trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp ============================================================================== --- trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp (original) +++ trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp Sun Dec 6 00:41:14 2020 @@ -191,13 +191,13 @@ Q_ASSERT(m_Doc==nullptr || m_AvailableFonts==nullptr); return false; } - ParagraphStyle vg; + struct ScribusDoc::BookMa bok; QMap bookmarks; - QMap TableID; - QMap TableIDM; - QMap TableIDF; + QMap TableID; + QMap TableIDM; + QMap TableIDF; QList TableItems; QList TableItemsM; QList TableItemsF; @@ -230,6 +230,8 @@ if (m_Doc->autoSaveTimer->isActive()) m_Doc->autoSaveTimer->stop(); + parStyleMap.clear(); + charStyleMap.clear(); groupRemap.clear(); itemRemap.clear(); itemNext.clear(); @@ -323,9 +325,10 @@ } if (tagName == "STYLE") { - readParagraphStyle(m_Doc, reader, vg); + ParagraphStyle pstyle; + readParagraphStyle(m_Doc, reader, pstyle); StyleSettmp; - tmp.create(vg); + tmp.create(pstyle); m_Doc->redefineStyles(tmp, false); } if (tagName == "CHARSTYLE") @@ -1216,7 +1219,12 @@ { static const QString CPARENT("CPARENT"); if (attrs.hasAttribute(CPARENT)) - newStyle.setParent(attrs.valueAsString(CPARENT)); + { + QString parentStyle = attrs.valueAsString(CPARENT); + if (!parentStyle.isEmpty()) + parentStyle = charStyleMap.value(parentStyle, parentStyle); + newStyle.setParent(parentStyle); + } static const QString FONT("FONT"); if (attrs.hasAttribute(FONT)) @@ -1364,13 +1372,12 @@ else newStyle.setDefaultStyle(false); - QString parentStyle = attrs.valueAsString("PARENT", ""); + QString parentStyle = attrs.valueAsString("PARENT", QString()); if (!parentStyle.isEmpty() && (parentStyle != newStyle.name())) { + parentStyle = parStyleMap.value(parentStyle, parentStyle); if (m_Doc->styleExists(parentStyle)) newStyle.setParent(parentStyle); - else if (parStyleMap.contains(parentStyle)) - newStyle.setParent(parStyleMap.value(parentStyle)); else newStyle.setParent(CommonStrings::DefaultParagraphStyle); } @@ -1447,7 +1454,7 @@ if (attrs.hasAttribute(MaxGlyphExtend)) newStyle.setMaxGlyphExtension(attrs.valueAsDouble(MaxGlyphExtend)); - readCharacterStyleAttrs( doc, attrs, newStyle.charStyle()); + readCharacterStyleAttrs(doc, attrs, newStyle.charStyle()); // newStyle.tabValues().clear(); int numTabs = attrs.valueAsInt("NUMTAB", 0); @@ -2172,7 +2179,7 @@ QStack< QList > groupStack; QStack< QList > groupStackP; QStack groupStack2; - QMap TableID2; + QMap TableID2; QList TableItems2; pat.setDoc(doc); @@ -3178,14 +3185,14 @@ Q_ASSERT(m_Doc==nullptr || m_AvailableFonts==nullptr); return false; } - ParagraphStyle vg; + struct ScribusDoc::BookMa bok; QMap bookmarks; ScPage* newPage = nullptr; QString tmp; - QMap TableID; + QMap TableID; QList TableItems; QStack< QList > groupStackFI; QStack< QList > groupStackMI; @@ -3218,6 +3225,7 @@ itemCountM = 0; parStyleMap.clear(); + charStyleMap.clear(); legacyStyleMap.clear(); legacyStyleMap[0] = "0"; legacyStyleMap[1] = "1"; @@ -3299,7 +3307,7 @@ readMultiline(ml, reader); QHash::ConstIterator mlit = m_Doc->docLineStyles.constFind(mlName2); if (mlit != m_Doc->docLineStyles.constEnd() && ml != mlit.value()) - mlName2 = getUniqueName(mlName2, m_Doc->docLineStyles); + mlName2 = getUniqueName(mlName2, m_Doc->docLineStyles); m_Doc->docLineStyles.insert(mlName2, ml); } if (tagName == "Pattern") @@ -3317,7 +3325,13 @@ } if (tagName == "STYLE") { - getStyle(vg, reader, nullptr, m_Doc, true); + ParagraphStyle pStyle; + getStyle(pStyle, reader, nullptr, m_Doc, true); + } + if (tagName == "CHARSTYLE") + { + CharStyle cstyle; + getStyle(cstyle, reader, nullptr, m_Doc, true); } if (((tagName == "PAGE") || (tagName == "MASTERPAGE")) && (attrs.valueAsInt("NUM") == pageNumber)) { @@ -3677,64 +3691,106 @@ return true; } -void Scribus134Format::getStyle(ParagraphStyle& style, ScXmlStreamReader& reader, StyleSet *tempStyles, ScribusDoc* doc, bool fl) +void Scribus134Format::getStyle(ParagraphStyle& style, ScXmlStreamReader& reader, StyleSet *tempStyles, ScribusDoc* doc, bool equiv) { bool found(false); const StyleSet &docParagraphStyles = tempStyles ? *tempStyles : doc->paragraphStyles(); + + style.erase(); readParagraphStyle(doc, reader, style); - for (int i = 0; i < docParagraphStyles.count(); ++i) - { - const ParagraphStyle& paraStyle = docParagraphStyles[i]; - if (style.name() == paraStyle.name()) - { - if (style.equiv(paraStyle)) - { - if (fl) - { - legacyStyleMap[legacyStyleCount] = style.name(); - legacyStyleCount++; - } - found = true; - } - else - { - style.setName(docParagraphStyles.getUniqueCopyName(paraStyle.name())); - found = false; - } - break; - } - } - if (!found && fl) - { - for (int i = 0; i < docParagraphStyles.count(); ++i) - { - const ParagraphStyle& paraStyle = docParagraphStyles[i]; - if (style.equiv(paraStyle)) - { - parStyleMap[style.name()] = paraStyle.name(); - style.setName(paraStyle.name()); + + // Do not duplicate default style + if (style.isDefaultStyle()) + style.setDefaultStyle(false); + + const ParagraphStyle* foundStyle = docParagraphStyles.getPointer(style.name()); + if (foundStyle) + { + found = style.equiv(*foundStyle); + if (found) + { + if (equiv) + { legacyStyleMap[legacyStyleCount] = style.name(); legacyStyleCount++; - found = true; - break; - } - } - } - if (!found) - { - if (tempStyles) - tempStyles->create(style); - else - { - StyleSet tmp; - tmp.create(style); - doc->redefineStyles(tmp, false); - } - if (fl) - { + } + return; + } + QString newName = docParagraphStyles.getUniqueCopyName(style.name()); + parStyleMap[style.name()] = newName; + style.setName(newName); + } + + if (equiv) + { + const ParagraphStyle* equivStyle = docParagraphStyles.findEquivalent(style); + if (equivStyle) + { + parStyleMap[style.name()] = equivStyle->name(); + style.setName(equivStyle->name()); legacyStyleMap[legacyStyleCount] = style.name(); legacyStyleCount++; - } + return; + } + } + + if (tempStyles) + tempStyles->create(style); + else + { + StyleSet tmp; + tmp.create(style); + doc->redefineStyles(tmp, false); + } + if (equiv) + { + legacyStyleMap[legacyStyleCount] = style.name(); + legacyStyleCount++; + } +} + +void Scribus134Format::getStyle(CharStyle& style, ScXmlStreamReader& reader, StyleSet *tempStyles, ScribusDoc* doc, bool equiv) +{ + bool found(false); + const StyleSet &docCharStyles = tempStyles ? *tempStyles : doc->charStyles(); + + style.erase(); + ScXmlStreamAttributes attrs = reader.scAttributes(); + readNamedCharacterStyleAttrs(m_Doc, attrs, style); + + // Do not duplicate default style + if (style.isDefaultStyle()) + style.setDefaultStyle(false); + + const CharStyle* foundStyle = docCharStyles.getPointer(style.name()); + if (foundStyle) + { + found = style.equiv(*foundStyle); + if (found) + return; + QString newName = docCharStyles.getUniqueCopyName(style.name()); + parStyleMap[style.name()] = newName; + style.setName(newName); + } + + if (equiv) + { + const CharStyle* equivStyle = docCharStyles.findEquivalent(style); + if (equivStyle) + { + charStyleMap[style.name()] = equivStyle->name(); + style.setName(equivStyle->name()); + return; + } + } + + if (tempStyles) + tempStyles->create(style); + else + { + StyleSet tmp; + tmp.create(style); + doc->redefineCharStyles(tmp, false); } } @@ -3747,6 +3803,9 @@ QScopedPointer ioDevice(slaReader(fileName)); if (ioDevice.isNull()) return false; + + parStyleMap.clear(); + charStyleMap.clear(); ScXmlStreamReader reader(ioDevice.data()); ScXmlStreamAttributes attrs; @@ -3784,6 +3843,9 @@ QScopedPointer ioDevice(slaReader(fileName)); if (ioDevice.isNull()) return false; + + parStyleMap.clear(); + charStyleMap.clear(); ScXmlStreamReader reader(ioDevice.data()); ScXmlStreamAttributes attrs; Modified: trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24307&path=/trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h ============================================================================== --- trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h (original) +++ trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h Sun Dec 6 00:41:14 2020 @@ -38,6 +38,7 @@ // Standard plugin implementation Scribus134Format(); virtual ~Scribus134Format(); + QString fullTrName() const override; const AboutData* getAboutData() const override; void deleteAboutData(const AboutData* about) const override; @@ -83,7 +84,8 @@ QIODevice* slaReader(const QString & fileName); - void getStyle(ParagraphStyle& style, ScXmlStreamReader& reader, StyleSet *docParagraphStyles, ScribusDoc* doc, bool fl); + void getStyle(ParagraphStyle& style, ScXmlStreamReader& reader, StyleSet *docParagraphStyles, ScribusDoc* doc, bool equiv); + void getStyle(CharStyle& style, ScXmlStreamReader& reader, StyleSet *docCharStyles, ScribusDoc* doc, bool equiv); void readDocAttributes(ScribusDoc* doc, ScXmlStreamAttributes& attrs); void readCMSSettings(ScribusDoc* doc, ScXmlStreamAttributes& attrs); @@ -116,7 +118,8 @@ bool readTableOfContents(ScribusDoc* doc, ScXmlStreamReader& reader); PageItem* pasteItem(ScribusDoc *doc, ScXmlStreamAttributes& attrs, const QString& baseDir, PageItem::ItemKind itemKind, int pagenr = -2 /* currentPage*/); - + + QMap charStyleMap; QMap parStyleMap; QMap legacyStyleMap; uint legacyStyleCount; Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24307&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp ============================================================================== --- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp (original) +++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp Sun Dec 6 00:41:14 2020 @@ -202,7 +202,6 @@ bool Scribus150Format::loadElements(const QString& data, const QString& fileDir, int toLayer, double Xp_in, double Yp_in, bool loc) { - ParagraphStyle vg; isNewFormat = false; LayerToPaste = toLayer; Xp = Xp_in; @@ -214,10 +213,10 @@ QList TableItemsF; QList TableItemsM; QList WeldItems; - QMap TableID; - QMap TableIDF; - QMap TableIDM; - QMap WeldID; + QMap TableID; + QMap TableIDF; + QMap TableIDM; + QMap WeldID; QStack< QList > groupStackFI; QStack< QList > groupStackMI; QStack< QList > groupStackPI; @@ -228,6 +227,8 @@ QStack groupStackMI2; QStack groupStackPI2; + parStyleMap.clear(); + charStyleMap.clear(); itemRemap.clear(); itemNext.clear(); itemCount = 0; @@ -283,7 +284,12 @@ } // 10/25/2004 pv - None is "reserved" color. cannot be defined in any file... if (tagName == "COLOR" && attrs.valueAsString("NAME") != CommonStrings::None) + { + QString colorName = attrs.valueAsString("NAME"); + if (m_Doc->PageColors.contains(colorName)) + continue; readColor(m_Doc->PageColors, attrs); + } if (tagName == "Gradient") { VGradient gra; @@ -292,31 +298,27 @@ if (!success) break; gra.setRepeatMethod((VGradient::VGradientRepeatMethod)(attrs.valueAsInt("Ext", VGradient::pad))); - if (!grName.isEmpty()) - { + if (!grName.isEmpty() && !m_Doc->docGradients.contains(grName)) m_Doc->docGradients.insert(grName, gra); - } } if (tagName == "STYLE") { - readParagraphStyle(m_Doc, reader, vg); - StyleSettmp; - tmp.create(vg); - m_Doc->redefineStyles(tmp, false); + ParagraphStyle pstyle; + getStyle(pstyle, reader, nullptr, m_Doc, true); } if (tagName == "CHARSTYLE") { CharStyle cstyle; - StyleSet temp; - ScXmlStreamAttributes attrs = reader.scAttributes(); - readNamedCharacterStyleAttrs(m_Doc, attrs, cstyle); - temp.create(cstyle); - m_Doc->redefineCharStyles(temp, false); + getStyle(cstyle, reader, nullptr, m_Doc, true); } if (tagName == "TableStyle") { TableStyle tstyle; readTableStyle(m_Doc, reader, tstyle); + // FIXME: import style under new name if existing + // Do not break current doc for now + if (m_Doc->tableStyles().contains(tstyle.name())) + continue; StyleSet temp; temp.create(tstyle); m_Doc->redefineTableStyles(temp, false); @@ -325,6 +327,10 @@ { CellStyle tstyle; readCellStyle(m_Doc, reader, tstyle); + // FIXME: import style under new name if existing + // Do not break current doc for now + if (m_Doc->cellStyles().contains(tstyle.name())) + continue; StyleSet temp; temp.create(tstyle); m_Doc->redefineCellStyles(temp, false); @@ -339,11 +345,10 @@ multiLine ml; QString mlName = attrs.valueAsString("Name"); success = readMultiline(ml, reader); - if (!success) break; - if (!mlName.isEmpty()) - { + if (!success) + break; + if (!mlName.isEmpty() && !m_Doc->docLineStyles.contains(mlName)) m_Doc->docLineStyles.insert(mlName, ml); - } } if ((tagName == "ITEM") || (tagName == "PAGEOBJECT") || (tagName == "FRAMEOBJECT")) { @@ -746,9 +751,10 @@ bool Scribus150Format::loadStory(const QByteArray& data, StoryText& story, PageItem* item) { - ParagraphStyle vg; isNewFormat = false; + parStyleMap.clear(); + charStyleMap.clear(); itemRemap.clear(); itemNext.clear(); itemCount = 0; @@ -816,13 +822,14 @@ } if (tagName == "STYLE") { - readParagraphStyle(m_Doc, reader, vg); + ParagraphStyle pstyle; + readParagraphStyle(m_Doc, reader, pstyle); // FIXME: import style under new name if existing // Do not break current doc for now - if (m_Doc->paragraphStyles().contains(vg.name())) + if (m_Doc->paragraphStyles().contains(pstyle.name())) continue; StyleSet tmp; - tmp.create(vg); + tmp.create(pstyle); m_Doc->redefineStyles(tmp, false); } if (tagName == "CHARSTYLE") @@ -930,20 +937,20 @@ Q_ASSERT(m_Doc == nullptr || m_AvailableFonts == nullptr); return false; } - ParagraphStyle vg; + Xp = 0.0; Yp = 0.0; GrX = 0.0; GrY = 0.0; isNewFormat = false; - QMap TableID; - QMap TableIDM; - QMap TableIDF; + QMap TableID; + QMap TableIDM; + QMap TableIDF; QList TableItems; QList TableItemsM; QList TableItemsF; - QMap WeldID; + QMap WeldID; QList WeldItems; QStack< QList > groupStackFI; QStack< QList > groupStackMI; @@ -1501,7 +1508,7 @@ Q_ASSERT(m_Doc==nullptr || m_AvailableFonts==nullptr); return false; } - ParagraphStyle vg; + Xp = 0.0; Yp = 0.0; GrX = 0.0; @@ -1511,13 +1518,13 @@ isNewFormat = false; - QMap TableID; - QMap TableIDM; - QMap TableIDF; + QMap TableID; + QMap TableIDM; + QMap TableIDF; QList TableItems; QList TableItemsM; QList TableItemsF; - QMap WeldID; + QMap WeldID; QList WeldItems; QStack< QList > groupStackFI; QStack< QList > groupStackMI; @@ -1555,6 +1562,8 @@ if (m_Doc->autoSaveTimer->isActive()) m_Doc->autoSaveTimer->stop(); + parStyleMap.clear(); + charStyleMap.clear(); itemRemap.clear(); itemNext.clear(); itemCount = 0; @@ -1665,9 +1674,10 @@ } if (tagName == "STYLE") { - readParagraphStyle(m_Doc, reader, vg); + ParagraphStyle pstyle; + readParagraphStyle(m_Doc, reader, pstyle); StyleSettmp; - tmp.create(vg); + tmp.create(pstyle); m_Doc->redefineStyles(tmp, false); } if (tagName == "CHARSTYLE") @@ -2789,7 +2799,12 @@ { static const QString CPARENT("CPARENT"); if (attrs.hasAttribute(CPARENT)) - newStyle.setParent(attrs.valueAsString(CPARENT)); + { + QString parentStyle = attrs.valueAsString(CPARENT); + if (!parentStyle.isEmpty()) + parentStyle = charStyleMap.value(parentStyle, parentStyle); + newStyle.setParent(parentStyle); + } static const QString FONT("FONT"); if (attrs.hasAttribute(FONT)) @@ -2956,13 +2971,12 @@ else newStyle.setDefaultStyle(false); - QString parentStyle = attrs.valueAsString("PARENT", ""); + QString parentStyle = attrs.valueAsString("PARENT", QString()); if (!parentStyle.isEmpty() && (parentStyle != newStyle.name())) { + parentStyle = parStyleMap.value(parentStyle, parentStyle); if (m_Doc->styleExists(parentStyle)) newStyle.setParent(parentStyle); - else if (parStyleMap.contains(parentStyle)) - newStyle.setParent(parStyleMap.value(parentStyle)); else newStyle.setParent(CommonStrings::DefaultParagraphStyle); } @@ -3133,7 +3147,7 @@ if (attrs.hasAttribute(BSHADE)) newStyle.setBackgroundShade(attrs.valueAsInt(BSHADE, 100)); - readCharacterStyleAttrs( doc, attrs, newStyle.charStyle()); + readCharacterStyleAttrs(doc, attrs, newStyle.charStyle()); // newStyle.tabValues().clear(); QList tbs; @@ -6361,7 +6375,7 @@ Q_ASSERT(m_Doc==nullptr || m_AvailableFonts==nullptr); return false; } - ParagraphStyle vg; + Xp = 0.0; Yp = 0.0; GrX = 0.0; @@ -6397,6 +6411,7 @@ } parStyleMap.clear(); + charStyleMap.clear(); itemRemap.clear(); itemNext.clear(); itemCount = 0; @@ -6458,7 +6473,12 @@ } if (tagName == "COLOR" && attrs.valueAsString("NAME") != CommonStrings::None) + { + QString colorName = attrs.valueAsString("NAME"); + if (m_Doc->PageColors.contains(colorName)) + continue; readColor(m_Doc->PageColors, attrs); + } if (tagName == "Gradient" && attrs.valueAsString("Name") != CommonStrings::None) { VGradient gra; @@ -6467,10 +6487,8 @@ if (!success) break; gra.setRepeatMethod((VGradient::VGradientRepeatMethod)(attrs.valueAsInt("Ext", VGradient::pad))); - if (!grName.isEmpty()) - { + if (!grName.isEmpty() && !m_Doc->docGradients.contains(grName)) m_Doc->docGradients.insert(grName, gra); - } } if (tagName == "JAVA") { @@ -6506,9 +6524,9 @@ QString mlName = attrs.valueAsString("Name"); QString mlName2 = mlName; readMultiline(ml, reader); - QHash::ConstIterator mlit = m_Doc->docLineStyles.find(mlName2); + QHash::ConstIterator mlit = m_Doc->docLineStyles.constFind(mlName2); if (mlit != m_Doc->docLineStyles.constEnd() && ml != mlit.value()) - mlName2 = getUniqueName(mlName2, m_Doc->docLineStyles); + mlName2 = getUniqueName(mlName2, m_Doc->docLineStyles); m_Doc->docLineStyles.insert(mlName2, ml); } if (tagName == "Pattern") @@ -6526,7 +6544,37 @@ } if (tagName == "STYLE") { - getStyle(vg, reader, nullptr, m_Doc, true); + ParagraphStyle pstyle; + getStyle(pstyle, reader, nullptr, m_Doc, true); + } + if (tagName == "CHARSTYLE") + { + CharStyle cstyle; + getStyle(cstyle, reader, nullptr, m_Doc, true); + } + if (tagName == "TableStyle") + { + TableStyle tstyle; + readTableStyle(m_Doc, reader, tstyle); + // FIXME: import style under new name if existing + // Do not break current doc for now + if (m_Doc->tableStyles().contains(tstyle.name())) + continue; + StyleSet temp; + temp.create(tstyle); + m_Doc->redefineTableStyles(temp, false); + } + if (tagName == "CellStyle") + { + CellStyle tstyle; + readCellStyle(m_Doc, reader, tstyle); + // FIXME: import style under new name if existing + // Do not break current doc for now + if (m_Doc->cellStyles().contains(tstyle.name())) + continue; + StyleSet temp; + temp.create(tstyle); + m_Doc->redefineCellStyles(temp, false); } if (((tagName == "PAGE") || (tagName == "MASTERPAGE")) && (attrs.valueAsInt("NUM") == pageNumber)) { @@ -7026,52 +7074,92 @@ return true; } -void Scribus150Format::getStyle(ParagraphStyle& style, ScXmlStreamReader& reader, StyleSet *tempStyles, ScribusDoc* doc, bool fl) +void Scribus150Format::getStyle(ParagraphStyle& style, ScXmlStreamReader& reader, StyleSet *tempStyles, ScribusDoc* doc, bool equiv) { bool found(false); const StyleSet &docParagraphStyles = tempStyles ? *tempStyles : doc->paragraphStyles(); + + style.erase(); readParagraphStyle(doc, reader, style); - for (int xx = 0; xx < docParagraphStyles.count(); ++xx) - { - const ParagraphStyle& paraStyle = docParagraphStyles[xx]; - if (style.name() == paraStyle.name()) - { - if (style.equiv(paraStyle)) - { - found = true; - } - else - { - style.setName(docParagraphStyles.getUniqueCopyName(paraStyle.name())); - found = false; - } - break; - } - } - if (!found && fl) - { - for (int xx = 0; xx < docParagraphStyles.count(); ++xx) - { - const ParagraphStyle& paraStyle = docParagraphStyles[xx]; - if (style.equiv(paraStyle)) - { - parStyleMap[style.name()] = paraStyle.name(); - style.setName(paraStyle.name()); - found = true; - break; - } - } - } - if (!found) - { - if (tempStyles) - tempStyles->create(style); - else - { - StyleSet tmp; - tmp.create(style); - doc->redefineStyles(tmp, false); - } + + // Do not duplicate default style + if (style.isDefaultStyle()) + style.setDefaultStyle(false); + + const ParagraphStyle* foundStyle = docParagraphStyles.getPointer(style.name()); + if (foundStyle) + { + found = style.equiv(*foundStyle); + if (found) + return; + QString newName = docParagraphStyles.getUniqueCopyName(style.name()); + parStyleMap[style.name()] = newName; + style.setName(newName); + } + + if (equiv) + { + const ParagraphStyle* equivStyle = docParagraphStyles.findEquivalent(style); + if (equivStyle) + { + parStyleMap[style.name()] = equivStyle->name(); + style.setName(equivStyle->name()); + return; + } + } + + if (tempStyles) + tempStyles->create(style); + else + { + StyleSet tmp; + tmp.create(style); + doc->redefineStyles(tmp, false); + } +} + +void Scribus150Format::getStyle(CharStyle& style, ScXmlStreamReader& reader, StyleSet *tempStyles, ScribusDoc* doc, bool equiv) +{ + bool found(false); + const StyleSet &docCharStyles = tempStyles ? *tempStyles : doc->charStyles(); + + style.erase(); + ScXmlStreamAttributes attrs = reader.scAttributes(); + readNamedCharacterStyleAttrs(m_Doc, attrs, style); + + // Do not duplicate default style + if (style.isDefaultStyle()) + style.setDefaultStyle(false); + + const CharStyle* foundStyle = docCharStyles.getPointer(style.name()); + if (foundStyle) + { + found = style.equiv(*foundStyle); + if (found) + return; + QString newName = docCharStyles.getUniqueCopyName(style.name()); + parStyleMap[style.name()] = newName; + style.setName(newName); + } + + if (equiv) + { + const CharStyle* equivStyle = docCharStyles.findEquivalent(style); + if (equivStyle) + { + charStyleMap[style.name()] = equivStyle->name(); + style.setName(equivStyle->name()); + return; + } + } + + if (tempStyles) + tempStyles->create(style); + else + { + StyleSet tmp; + tmp.create(style); + doc->redefineCharStyles(tmp, false); } } @@ -7085,6 +7173,9 @@ if (ioDevice.isNull()) return false; + parStyleMap.clear(); + charStyleMap.clear(); + ScXmlStreamReader reader(ioDevice.data()); ScXmlStreamAttributes attrs; while (!reader.atEnd() && !reader.hasError()) @@ -7121,6 +7212,9 @@ QScopedPointer ioDevice(slaReader(fileName)); if (ioDevice.isNull()) return false; + + parStyleMap.clear(); + charStyleMap.clear(); ScXmlStreamReader reader(ioDevice.data()); ScXmlStreamAttributes attrs; Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24307&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h ============================================================================== --- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h (original) +++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h Sun Dec 6 00:41:14 2020 @@ -117,7 +117,8 @@ QIODevice* slaReader(const QString & fileName); - void getStyle(ParagraphStyle& style, ScXmlStreamReader& reader, StyleSet *docParagraphStyles, ScribusDoc* doc, bool fl); + void getStyle(ParagraphStyle& style, ScXmlStreamReader& reader, StyleSet *docParagraphStyles, ScribusDoc* doc, bool equiv); + void getStyle(CharStyle& style, ScXmlStreamReader& reader, StyleSet *docCharStyles, ScribusDoc* doc, bool equiv); void readDocAttributes(ScribusDoc* doc, ScXmlStreamAttributes& attrs); void readCMSSettings(ScribusDoc* doc, ScXmlStreamAttributes& attrs); @@ -190,8 +191,8 @@ void writeGradients(ScXmlStreamWriter & docu, bool part = false); void writeGradients(ScXmlStreamWriter & docu, const QStringList& gradientNames); void writeHyphenatorLists(ScXmlStreamWriter& docu); - void writePStyles(ScXmlStreamWriter& docu); - void writeCStyles(ScXmlStreamWriter& docu); + void writeParagraphStyles(ScXmlStreamWriter& docu); + void writeCharStyles(ScXmlStreamWriter& docu); void writeTableStyles(ScXmlStreamWriter& docu); void writeCellStyles(ScXmlStreamWriter& docu); void putPStyle(ScXmlStreamWriter& docu, const ParagraphStyle & style, const QString &nodeName); @@ -221,7 +222,8 @@ void WritePages(ScribusDoc *doc, ScXmlStreamWriter& docu, QProgressBar *dia2, uint maxC, bool master); void WriteObjects(ScribusDoc *doc, ScXmlStreamWriter& docu, const QString& baseDir, QProgressBar *dia2, uint maxC, ItemSelection master, QList *items = 0); void SetItemProps(ScXmlStreamWriter& docu, PageItem* item, const QString& baseDir); - + + QMap charStyleMap; QMap parStyleMap; QMap itemRemap; Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24307&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp ============================================================================== --- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp (original) +++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp Sun Dec 6 00:41:14 2020 @@ -92,20 +92,9 @@ } } - // Write paragraph styles - QList::Iterator it; - QList names = lists.styleNames(); - QList styleList = m_Doc->getSortedStyleList(); - for (int i = 0; i < styleList.count(); ++i) - { - const ParagraphStyle& paragraphStyle = m_Doc->paragraphStyles()[styleList[i]]; - if (names.contains(paragraphStyle.name())) - putPStyle(writer, paragraphStyle, "STYLE"); - } - // Write character styles - names = lists.charStyleNames(); - styleList = m_Doc->getSortedCharStyleList(); + QList names = lists.charStyleNames(); + QList styleList = m_Doc->getSortedCharStyleList(); for (int i = 0; i < styleList.count(); ++i) { const CharStyle& charStyle = m_Doc->charStyles()[styleList[i]]; @@ -114,6 +103,16 @@ writer.writeStartElement("CHARSTYLE"); putNamedCStyle(writer, charStyle); writer.writeEndElement(); + } + + // Write paragraph styles + names = lists.styleNames(); + styleList = m_Doc->getSortedStyleList(); + for (int i = 0; i < styleList.count(); ++i) + { + const ParagraphStyle& paragraphStyle = m_Doc->paragraphStyles()[styleList[i]]; + if (names.contains(paragraphStyle.name())) + putPStyle(writer, paragraphStyle, "STYLE"); } writeLineStyles(writer, lists.lineStyleNames()); @@ -189,21 +188,10 @@ if (pi && !embeddedFrames.contains(pi)) embeddedFrames.append(pi); } - - // Write paragraph styles - QList::Iterator it; - QList names = lists.styleNames(); - QList styleList = m_Doc->getSortedStyleList(); - for (int i = 0; i < styleList.count(); ++i) - { - const ParagraphStyle& paragraphStyle = m_Doc->paragraphStyles()[styleList[i]]; - if (names.contains(paragraphStyle.name())) - putPStyle(writer, paragraphStyle, "STYLE"); - } - + // Write character styles - names = lists.charStyleNames(); - styleList = m_Doc->getSortedCharStyleList(); + QList names = lists.charStyleNames(); + QList styleList = m_Doc->getSortedCharStyleList(); for (int i = 0; i < styleList.count(); ++i) { const CharStyle& charStyle = m_Doc->charStyles()[styleList[i]]; @@ -212,6 +200,16 @@ writer.writeStartElement("CHARSTYLE"); putNamedCStyle(writer, charStyle); writer.writeEndElement(); + } + + // Write paragraph styles + names = lists.styleNames(); + styleList = m_Doc->getSortedStyleList(); + for (int i = 0; i < styleList.count(); ++i) + { + const ParagraphStyle& paragraphStyle = m_Doc->paragraphStyles()[styleList[i]]; + if (names.contains(paragraphStyle.name())) + putPStyle(writer, paragraphStyle, "STYLE"); } writeLineStyles(writer, lists.lineStyleNames()); @@ -525,8 +523,8 @@ writeColors(docu); writeGradients(docu); writeHyphenatorLists(docu); - writePStyles(docu); - writeCStyles(docu); + writeCharStyles(docu); + writeParagraphStyles(docu); writeTableStyles(docu); writeCellStyles(docu); writeLineStyles(docu); @@ -801,7 +799,7 @@ docu.writeEndElement(); } -void Scribus150Format::writePStyles(ScXmlStreamWriter & docu) +void Scribus150Format::writeParagraphStyles(ScXmlStreamWriter & docu) { QList styleList = m_Doc->getSortedStyleList(); for (int a = 0; a < styleList.count(); ++a) @@ -927,7 +925,7 @@ } -void Scribus150Format::writeCStyles(ScXmlStreamWriter & docu) +void Scribus150Format::writeCharStyles(ScXmlStreamWriter & docu) { QList styleList = m_Doc->getSortedCharStyleList(); for (int a = 0; a < styleList.count(); ++a) Modified: trunk/Scribus/scribus/scribusdoc.cpp URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24307&path=/trunk/Scribus/scribus/scribusdoc.cpp ============================================================================== --- trunk/Scribus/scribus/scribusdoc.cpp (original) +++ trunk/Scribus/scribus/scribusdoc.cpp Sun Dec 6 00:41:14 2020 @@ -1048,14 +1048,14 @@ } } -bool ScribusDoc::styleExists(const QString& styleName) -{ - for (int i = 0; i < paragraphStyles().count(); ++i) - { - if (paragraphStyles()[i].name() == styleName) - return true; - } - return false; +bool ScribusDoc::styleExists(const QString& styleName) const +{ + return m_docParagraphStyles.contains(styleName); +} + +bool ScribusDoc::charStyleExists(const QString& styleName) const +{ + return m_docCharStyles.contains(styleName); } QList ScribusDoc::getSortedStyleList() Modified: trunk/Scribus/scribus/scribusdoc.h URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24307&path=/trunk/Scribus/scribus/scribusdoc.h ============================================================================== --- trunk/Scribus/scribus/scribusdoc.h (original) +++ trunk/Scribus/scribus/scribusdoc.h Sun Dec 6 00:41:14 2020 @@ -613,7 +613,9 @@ ResourceCollection m_newNames; }; void replaceNamedResources(ResourceCollection& newNames); - bool styleExists(const QString& styleName); + + bool styleExists(const QString& styleName) const; + bool charStyleExists(const QString& styleName) const; QList getSortedStyleList(); QList getSortedCharStyleList(); Modified: trunk/Scribus/scribus/style.h URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24307&path=/trunk/Scribus/scribus/style.h ============================================================================== --- trunk/Scribus/scribus/style.h (original) +++ trunk/Scribus/scribus/style.h Sun Dec 6 00:41:14 2020 @@ -24,7 +24,6 @@ #include "styles/stylecontext.h" #include "desaxe/saxio.h" - /** * This is the base class for all style-like objects: CharStyles, * ParagraphStyles, LineStyles, FrameStyles, CellStyles, @@ -34,7 +33,8 @@ * the stored m_contextversion against the StyleContext's version and updates all * attributes if they are different. */ -class SCRIBUS_API BaseStyle : public SaxIO { +class SCRIBUS_API BaseStyle : public SaxIO +{ protected: bool m_isDefaultStyle; QString m_name; @@ -42,6 +42,7 @@ int m_contextversion; QString m_parent; QString m_shortcut; + public: // static const short NOVALUE = -16000; @@ -81,6 +82,8 @@ QString name() const { return m_name; } void setName(const QString& n) { m_name = n.isEmpty() ? "" : n; } bool hasName() const { return ! m_name.isEmpty(); } + + QString baseName() const; virtual QString displayName() const = 0;/*{ if ( hasName() || !hasParent() || !m_context) Modified: trunk/Scribus/scribus/styles/style.cpp URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24307&path=/trunk/Scribus/scribus/styles/style.cpp ============================================================================== --- trunk/Scribus/scribus/styles/style.cpp (original) +++ trunk/Scribus/scribus/styles/style.cpp Sun Dec 6 00:41:14 2020 @@ -59,6 +59,21 @@ m_contextversion = m_context->version(); } +QString BaseStyle::baseName() const +{ + if (m_name.isEmpty()) + return QString(); + + static QRegExp rx("^(.*)\\s+\\((\\d+)\\)$"); + if (rx.indexIn(m_name) != -1) + { + QStringList matches = rx.capturedTexts(); + if (matches.count() >= 3) + return matches[1]; + } + return m_name; +} + const BaseStyle* BaseStyle::parentStyle() const { //qDebug() << QString("follow %1").arg(reinterpret_cast(m_context),16); Modified: trunk/Scribus/scribus/styles/styleset.h URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24307&path=/trunk/Scribus/scribus/styles/styleset.h ============================================================================== --- trunk/Scribus/scribus/styles/styleset.h (original) +++ trunk/Scribus/scribus/styles/styleset.h Sun Dec 6 00:41:14 2020 @@ -21,6 +21,11 @@ { return * dynamic_cast(resolve(name)); } + + const STYLE* getPointer(const QString& name) const + { + return dynamic_cast(resolve(name)); + } STYLE& operator[] (int index) { @@ -37,6 +42,8 @@ inline bool contains(const QString& name) const; inline int find(const QString& name) const; + + const STYLE* findEquivalent(const STYLE& style) const; inline const BaseStyle* resolve(const QString& name) const; @@ -149,6 +156,17 @@ if (styles[i]->name() == name) return i; return -1; +} + +template +const STYLE* StyleSet