r24684 by jghali - Move TextNote class in itw own files + some cleanups related to marks/notes
scribus-commit
scribus-commit at lists.scribus.net
Tue Aug 3 15:48:14 UTC 2021
Author: jghali
Date: Tue Aug 3 15:48:13 2021
New Revision: 24684
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24684
Log:
Move TextNote class in itw own files + some cleanups related to marks/notes
Added:
trunk/Scribus/scribus/textnote.cpp
trunk/Scribus/scribus/textnote.h
Modified:
trunk/Scribus/Scribus.pro
trunk/Scribus/scribus/CMakeLists.txt
trunk/Scribus/scribus/gtaction.cpp
trunk/Scribus/scribus/gtaction.h
trunk/Scribus/scribus/notesstyles.cpp
trunk/Scribus/scribus/notesstyles.h
trunk/Scribus/scribus/pageitem_noteframe.cpp
trunk/Scribus/scribus/pageitem_noteframe.h
trunk/Scribus/scribus/pageitem_textframe.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/scribusdoc.cpp
trunk/Scribus/scribus/text/storytext.cpp
trunk/Scribus/scribus/text/storytext.h
trunk/Scribus/scribus/text/textcontext.cpp
trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj
trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj.filters
trunk/Scribus/win32/msvc2017/scribus-main/Scribus.vcxproj
trunk/Scribus/win32/msvc2017/scribus-main/Scribus.vcxproj.filters
trunk/Scribus/win32/msvc2019/scribus-main/Scribus.vcxproj
trunk/Scribus/win32/msvc2019/scribus-main/Scribus.vcxproj.filters
Modified: trunk/Scribus/Scribus.pro
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/Scribus.pro
==============================================================================
--- trunk/Scribus/Scribus.pro (original)
+++ trunk/Scribus/Scribus.pro Tue Aug 3 15:48:13 2021
@@ -229,6 +229,7 @@
scribus/tablehandle.h \
scribus/tablepainter.h \
scribus/tableutils.h \
+ scribus/textnote.h \
scribus/textwriter.h \
scribus/tocgenerator.h \
scribus/transaction.h \
@@ -1348,6 +1349,7 @@
scribus/tableborder.cpp \
scribus/tablecell.cpp \
scribus/tableutils.cpp \
+ scribus/textnote.cpp \
scribus/textwriter.cpp \
scribus/tocgenerator.cpp \
scribus/transaction.cpp \
Modified: trunk/Scribus/scribus/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/CMakeLists.txt Tue Aug 3 15:48:13 2021
@@ -264,6 +264,7 @@
tableborder.cpp
tablecell.cpp
tableutils.cpp
+ textnote.cpp
textwriter.cpp
tocgenerator.cpp
transaction.cpp
Modified: trunk/Scribus/scribus/gtaction.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/scribus/gtaction.cpp
==============================================================================
--- trunk/Scribus/scribus/gtaction.cpp (original)
+++ trunk/Scribus/scribus/gtaction.cpp Tue Aug 3 15:48:13 2021
@@ -46,28 +46,21 @@
#include "sccolorengine.h"
#include "scribusdoc.h"
#include "scribus.h"
+#include "textnote.h"
#include "undomanager.h"
#include "util.h"
#include "util_text.h"
#include "ui/contentpalette.h"
#include "ui/missing.h"
-gtAction::gtAction(bool append, PageItem* pageitem) :
- m_prefsManager(PrefsManager::instance())
-{ m_textFrame = pageitem;
- m_ScMW=m_textFrame->doc()->scMW();
+gtAction::gtAction(bool append, PageItem* pageitem)
+ : m_prefsManager(PrefsManager::instance())
+{
+ m_textFrame = pageitem;
+ m_ScMW = m_textFrame->doc()->scMW();
m_it = m_textFrame;
- m_lastParagraphStyle = -1;
- m_inPara = false;
- m_isFirstWrite = true;
- m_lastCharWasLineChange = false;
- m_currentFrameStyle = "";
m_doAppend = append;
- m_updateParagraphStyles = false;
- m_overridePStyleFont = true;
m_undoManager = UndoManager::instance();
- m_noteStory = nullptr;
- m_note = nullptr;
}
void gtAction::setProgressInfo()
Modified: trunk/Scribus/scribus/gtaction.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/scribus/gtaction.h
==============================================================================
--- trunk/Scribus/scribus/gtaction.h (original)
+++ trunk/Scribus/scribus/gtaction.h Tue Aug 3 15:48:13 2021
@@ -59,7 +59,6 @@
gtAction(bool append, PageItem *pageitem);
~gtAction();
- void setTextFrame(PageItem* frame);
void setProgressInfo();
void setProgressInfoDone();
void setInfo(const QString& infoText);
@@ -84,22 +83,26 @@
void setOverridePStyleFont(bool newOPSF);
private:
- UndoManager* m_undoManager;
- ScribusMainWindow* m_ScMW;
- PageItem *m_textFrame;
- PageItem *m_it;
- int m_lastParagraphStyle;
- bool m_inPara;
- bool m_isFirstWrite;
+ PrefsManager& m_prefsManager;
+ UndoManager* m_undoManager { nullptr };
+ ScribusMainWindow* m_ScMW { nullptr };
+ PageItem *m_textFrame { nullptr };
+ PageItem *m_it { nullptr };
+ int m_lastParagraphStyle { -1 };
+ bool m_inPara { false };
+ bool m_isFirstWrite { true };
bool m_doAppend;
- bool m_lastCharWasLineChange;
- bool m_updateParagraphStyles;
+ bool m_lastCharWasLineChange { false };
+ bool m_updateParagraphStyles { false };
/* If paragraph style is used should the font style of the gtpstyle be used
or should writer respect the font set in the real paragraph style
*/
- bool m_overridePStyleFont;
+ bool m_overridePStyleFont { true };
QString m_currentFrameStyle;
FontFamilyMap m_families;
+
+ StoryText* m_noteStory { nullptr };
+ TextNote* m_note { nullptr };
int findParagraphStyle(const QString& name);
int findParagraphStyle(gtParagraphStyle* pstyle);
@@ -109,10 +112,7 @@
QString findFontName(gtFont* font);
void updateParagraphStyle(int pstyleIndex, gtParagraphStyle* pstyle);
QString parseColor(const QString &s);
- void finalize();
- PrefsManager& m_prefsManager;
- StoryText* m_noteStory;
- TextNote* m_note;
+ void finalize();
};
#endif
Modified: trunk/Scribus/scribus/notesstyles.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/scribus/notesstyles.cpp
==============================================================================
--- trunk/Scribus/scribus/notesstyles.cpp (original)
+++ trunk/Scribus/scribus/notesstyles.cpp Tue Aug 3 15:48:13 2021
@@ -2,28 +2,30 @@
#include "marks.h"
#include "util.h"
-void NotesStyle::setEndNotes(bool setendnotes)
+void NotesStyle::setEndNotes(bool isEndnoteStyle)
{
- if (m_endNotesStyle != setendnotes)
+ if (m_endNotesStyle != isEndnoteStyle)
{
- m_endNotesStyle = setendnotes;
+ m_endNotesStyle = isEndnoteStyle;
}
}
-bool NotesStyle::operator!=(const NotesStyle& n2)
+bool NotesStyle::operator!=(const NotesStyle& n2) const
{
- return ((m_nameStr != n2.m_nameStr) || (m_startNum != n2.m_startNum) || (m_endNotesStyle != n2.m_endNotesStyle) ||
- (getType() != static_cast<NotesStyle>(n2).getType()) || (m_numRange != n2.m_numRange) ||
- (m_prefixStr != n2.m_prefixStr) || (m_suffixStr != n2.m_suffixStr) ||
- (m_autoNotesHeight != n2.m_autoNotesHeight) || (m_autoNotesWidth != n2.m_autoNotesWidth) ||
- (m_autoRemoveEmptyNotesFrames != n2.m_autoRemoveEmptyNotesFrames) || (m_autoWeldNotesFrames != n2.m_autoWeldNotesFrames) ||
- (m_superscriptInMaster != n2.m_superscriptInMaster) || (m_superscriptInNote != n2.m_superscriptInNote) ||
- (m_marksCharStyle != n2.m_marksCharStyle) || (m_notesParaStyle != n2.m_notesParaStyle)
+ return ((m_nameStr != n2.m_nameStr) ||
+ (m_startNum != n2.m_startNum) ||
+ (m_endNotesStyle != n2.m_endNotesStyle) ||
+ (getType() != static_cast<NotesStyle>(n2).getType()) ||
+ (m_numRange != n2.m_numRange) ||
+ (m_prefixStr != n2.m_prefixStr) ||
+ (m_suffixStr != n2.m_suffixStr) ||
+ (m_autoNotesHeight != n2.m_autoNotesHeight) ||
+ (m_autoNotesWidth != n2.m_autoNotesWidth) ||
+ (m_autoRemoveEmptyNotesFrames != n2.m_autoRemoveEmptyNotesFrames) ||
+ (m_autoWeldNotesFrames != n2.m_autoWeldNotesFrames) ||
+ (m_superscriptInMaster != n2.m_superscriptInMaster) ||
+ (m_superscriptInNote != n2.m_superscriptInNote) ||
+ (m_marksCharStyle != n2.m_marksCharStyle) ||
+ (m_notesParaStyle != n2.m_notesParaStyle)
);
}
-
-
-QString TextNote::numString()
-{
- return notesStyle()->numString(m_number);
-}
Modified: trunk/Scribus/scribus/notesstyles.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/scribus/notesstyles.h
==============================================================================
--- trunk/Scribus/scribus/notesstyles.h (original)
+++ trunk/Scribus/scribus/notesstyles.h Tue Aug 3 15:48:13 2021
@@ -5,6 +5,7 @@
#include <QObject>
#include <QString>
#include <QList>
+
#include "numeration.h"
#include "pagestructs.h"
#include "scpage.h"
@@ -30,24 +31,30 @@
public:
NotesStyle() {}
~NotesStyle() {}
- bool operator!=(const NotesStyle& n2);
- QString name() const { return m_nameStr; }
+ bool operator!=(const NotesStyle& n2) const;
+
+ const QString& name() const { return m_nameStr; }
void setName(const QString& s) { m_nameStr = s; }
+
int start() const { return m_startNum; }
- void setStart(const int i) { m_startNum = i; }
+ void setStart(int i) { m_startNum = i; }
+
void setRange(NumerationRange ns) { m_numRange = ns; }
const NumerationRange& range() const { return m_numRange; }
- QString prefix() const { return m_prefixStr; }
+
+ const QString& prefix() const { return m_prefixStr; }
void setPrefix (const QString& str) { m_prefixStr = str; }
- QString suffix() const { return m_suffixStr; }
+
+ const QString& suffix() const { return m_suffixStr; }
void setSuffix (const QString& str) { m_suffixStr = str; }
- QString numString(const int num) const { return m_numeration.numString(num); }
- void setType(const NumFormat type) { m_numeration.numFormat = type; }
+ QString numString(int num) const { return m_numeration.numString(num); }
+ void setType(NumFormat type) { m_numeration.numFormat = type; }
const NumFormat& getType() const { return m_numeration.numFormat; }
bool isEndNotes() const { return m_endNotesStyle; }
+ void setEndNotes(bool isEndnoteStyle);
bool isAutoNotesHeight() const { return m_autoNotesHeight; }
void setAutoNotesHeight(bool set) { m_autoNotesHeight = set; }
bool isAutoNotesWidth() const { return m_autoNotesWidth; }
@@ -60,12 +67,10 @@
void setSuperscriptInNote(bool set) { m_superscriptInNote = set; }
bool isSuperscriptInMaster() const { return m_superscriptInMaster; }
void setSuperscriptInMaster(bool set) { m_superscriptInMaster = set; }
- const QString marksChStyle() const { return m_marksCharStyle; }
+ const QString& marksChStyle() const { return m_marksCharStyle; }
void setMarksCharStyle(const QString& styleName) { m_marksCharStyle = styleName; }
- const QString notesParStyle() const { return m_notesParaStyle; }
+ const QString& notesParStyle() const { return m_notesParaStyle; }
void setNotesParStyle(const QString& styleName) { m_notesParaStyle = styleName; }
-
- void setEndNotes(bool);
private:
QString m_nameStr {"Default"}; //unique name of notes style
@@ -86,37 +91,5 @@
QString m_notesParaStyle;
};
-class SCRIBUS_API TextNote : public QObject
-{
- Q_OBJECT
- friend class ScribusDoc;
-
-private:
- //only ScribusDoc can create and delete notes
- TextNote(NotesStyle *nStyle) : m_notesStyle(nStyle) { }
- ~TextNote() {}
-public:
- void setNotesStyle (NotesStyle* ns) { m_notesStyle = ns; }
- NotesStyle* notesStyle() { return m_notesStyle; }
- int num() { return m_number; }
- void setNum(const int i) { m_number = i; }
- QString numString();
- Mark* masterMark() { return m_noteMasterMark; }
- void setMasterMark(Mark* m) { m_noteMasterMark = m; }
- Mark* noteMark() { return m_noteFrameMark; }
- void setNoteMark(Mark* m) { m_noteFrameMark = m; }
- const QString saxedText() { return m_noteSaxedText; }
- void setSaxedText(const QString& string) { m_noteSaxedText = string; }
- void clearSaxedText() { m_noteSaxedText.clear(); textLen = 0; }
- bool isEndNote() { return m_notesStyle->isEndNotes(); }
- int textLen {0};
-
-protected:
- NotesStyle *m_notesStyle {nullptr};
- QString m_noteSaxedText;
- Mark *m_noteMasterMark {nullptr};
- Mark *m_noteFrameMark {nullptr};
- int m_number {0};
-};
#endif // NOTESSTYLES_H
Modified: trunk/Scribus/scribus/pageitem_noteframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/scribus/pageitem_noteframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_noteframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_noteframe.cpp Tue Aug 3 15:48:13 2021
@@ -8,6 +8,7 @@
#include "pageitem_textframe.h"
#include "scribusdoc.h"
+#include "textnote.h"
#include "undomanager.h"
#include "util.h"
#include "util_text.h"
@@ -319,42 +320,38 @@
int pos = 0;
int startPos = 0;
TextNote *note = nullptr;
- Mark* prevMrk = nullptr;
+ Mark* prevMark = nullptr;
while (pos < itemText.length())
{
- if (itemText.hasMark(pos))
- {
- Mark* mark = itemText.mark(pos);
- if (mark->isType(MARKNoteFrameType))
+ if (itemText.hasMark(pos, MARKNoteFrameType))
+ {
+ if (prevMark != nullptr)
{
- if (prevMrk != nullptr)
+ note = prevMark->getNotePtr();
+ if (note != nullptr)
{
- note = prevMrk->getNotePtr();
- if (note != nullptr)
+ int offset = 0;
+ if (itemText.text(pos - 1) == SpecialChars::PARSEP)
+ ++offset;
+ int len = pos - startPos -offset;
+ if (len <= 0)
+ note->clearSaxedText();
+ else
{
- int offset = 0;
- if (itemText.text(pos-1) == SpecialChars::PARSEP)
- ++offset;
- int len = pos - startPos -offset;
- if (len <= 0)
- note->clearSaxedText();
- else
- {
- note->setSaxedText(getItemTextSaxed(startPos, len));
- note->textLen = len;
- }
- itemText.deselectAll();
+ note->setSaxedText(getItemTextSaxed(startPos, len));
+ note->textLen = len;
}
+ itemText.deselectAll();
}
- prevMrk = mark;
- startPos = pos +1;
}
+ prevMark = itemText.mark(pos);
+ startPos = pos + 1;
}
++pos;
}
- if (prevMrk != nullptr)
- {
- note = prevMrk->getNotePtr();
+ if (prevMark != nullptr)
+ {
+ note = prevMark->getNotePtr();
Q_ASSERT(note != nullptr);
if (startPos != pos)
{
@@ -416,20 +413,3 @@
weldList.clear();
}
}
-
-int PageItem_NoteFrame::findNoteCpos(TextNote* note)
-{
- //find position of note in note`s frame
- if (itemText.length() == 0)
- return -1;
- for (int pos=0; pos < itemText.length(); ++pos)
- {
- Mark* mark = itemText.mark(pos);
- if (itemText.hasMark(pos) && mark->isType(MARKNoteFrameType))
- {
- if (mark->getNotePtr() == note)
- return (pos);
- }
- }
- return -1;
-}
Modified: trunk/Scribus/scribus/pageitem_noteframe.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/scribus/pageitem_noteframe.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_noteframe.h (original)
+++ trunk/Scribus/scribus/pageitem_noteframe.h Tue Aug 3 15:48:13 2021
@@ -67,11 +67,6 @@
//insert note at end of text in noteframe
void insertNote(TextNote* note);
-
-//not used???
- //find position of note marker in text
- int findNoteCpos(TextNote* note);
-
};
#endif // PAGEITEM_NOTEFRAME_H
Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp Tue Aug 3 15:48:13 2021
@@ -60,6 +60,7 @@
#include "text/textshaper.h"
#include "text/shapedtext.h"
#include "text/shapedtextfeed.h"
+#include "textnote.h"
#include "ui/guidemanager.h"
#include "ui/marksmanager.h"
#include "undomanager.h"
@@ -5594,7 +5595,7 @@
else
return nullptr;
}
- MarkType typ = isNoteFrame()? MARKNoteFrameType : MARKNoteMasterType;
+ MarkType typ = isNoteFrame() ? MARKNoteFrameType : MARKNoteMasterType;
for (int pos = start; pos < stop; ++pos)
{
if (itemText.hasMark(pos) && itemText.mark(pos)->isType(typ))
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&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 Tue Aug 3 15:48:13 2021
@@ -45,6 +45,7 @@
#include "scribusdoc.h"
#include "sctextstream.h"
#include "scxmlstreamreader.h"
+#include "textnote.h"
#include "undomanager.h"
#include "ui/missing.h"
#include "units.h"
Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&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 Tue Aug 3 15:48:13 2021
@@ -10,17 +10,16 @@
#include <ctime>
#include <memory>
+#include <QCursor>
+#include <QFileInfo>
+#include <QList>
+#include <QDataStream>
+#include <QScopedPointer>
+
#include "../../formatidlist.h"
+
+#include "api/api_application.h"
#include "commonstrings.h"
-#include "ui/missing.h"
-#include "prefsmanager.h"
-#include "qtiocompressor.h"
-#include "resourcecollection.h"
-#include "scconfig.h"
-#include "scpaths.h"
-#include "scpattern.h"
-#include "scribusdoc.h"
-#include "scribusview.h"
#include "hyphenator.h"
#include "notesstyles.h"
#include "pageitem_arc.h"
@@ -32,20 +31,21 @@
#include "pageitem_regularpolygon.h"
#include "pageitem_spiral.h"
#include "pageitem_table.h"
-
-#include "api/api_application.h"
-
+#include "prefsmanager.h"
+#include "qtiocompressor.h"
+#include "resourcecollection.h"
+#include "scconfig.h"
+#include "scpaths.h"
+#include "scpattern.h"
+#include "scribusdoc.h"
+#include "scribusview.h"
+#include "scxmlstreamwriter.h"
+#include "textnote.h"
+#include "ui/missing.h"
#include "units.h"
#include "util.h"
#include "util_math.h"
#include "util_color.h"
-#include <QCursor>
-#include <QFileInfo>
-#include <QList>
-#include <QDataStream>
-#include <QScopedPointer>
-
-#include "scxmlstreamwriter.h"
QString Scribus150Format::saveElements(double xp, double yp, double wp, double hp, Selection* selection, QByteArray &prevData)
{
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Tue Aug 3 15:48:13 2021
@@ -157,6 +157,7 @@
#include "serializer.h"
#include "storyloader.h"
#include "styleoptions.h"
+#include "textnote.h"
#include "tocgenerator.h"
#include "ui/about.h"
#include "ui/aboutplugins.h"
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Tue Aug 3 15:48:13 2021
@@ -97,6 +97,7 @@
#include "selection.h"
#include "serializer.h"
#include "tableborder.h"
+#include "textnote.h"
#include "text/textlayoutpainter.h"
#include "text/textshaper.h"
#include "ui/guidemanager.h"
@@ -1229,14 +1230,14 @@
currItem->replaceNamedResources(newNames);
}
// replace names in styles...
- for (int i=m_docParagraphStyles.count()-1; i >= 0; --i)
+ for (int i = m_docParagraphStyles.count() - 1; i >= 0; --i)
{
if (newNames.styles().contains(m_docParagraphStyles[i].name()))
m_docParagraphStyles.remove(i);
else
m_docParagraphStyles[i].replaceNamedResources(newNames);
}
- for (int i=m_docCharStyles.count()-1; i >= 0; --i)
+ for (int i = m_docCharStyles.count() - 1; i >= 0; --i)
{
if (newNames.charStyles().contains(m_docCharStyles[i].name()))
m_docCharStyles.remove(i);
@@ -1361,7 +1362,7 @@
replaceStyles(deletion);
}
// repair charstyle context:
- for (int i=0; i < m_docParagraphStyles.count(); ++i)
+ for (int i = 0; i < m_docParagraphStyles.count(); ++i)
{
ParagraphStyle& sty(m_docParagraphStyles[i]);
if (m_docParagraphStyles.isDefault(sty))
@@ -1388,7 +1389,7 @@
{
QMap<QString, QString> deletion;
QString deflt("");
- for (int i=0; i < m_docCharStyles.count(); ++i)
+ for (int i = 0; i < m_docCharStyles.count(); ++i)
{
const QString& nam(m_docCharStyles[i].name());
if (newStyles.find(nam) < 0)
@@ -16874,14 +16875,10 @@
continue;
if (item->prevInChain() != nullptr)
continue;
- // for (int j = item->firstInFrame(); j <= item->lastInFrame(); ++j)
- for (int j = 0; j < item->itemText.length(); ++j)
- {
- if (item->itemText.hasMark(j, mrk))
- {
- lastItem = item;
- return item;
- }
+ if (item->itemText.findMark(mrk) >= 0)
+ {
+ lastItem = item;
+ return item;
}
}
lastItem = nullptr;
@@ -16968,7 +16965,7 @@
int markPos = findMarkCPos(mrk, item);
while (markPos > -1)
{
- if (mrk->isType(MARKNoteFrameType) && markPos > 1 && item->itemText.text(markPos -1) == SpecialChars::PARSEP)
+ if (mrk->isType(MARKNoteFrameType) && markPos > 1 && item->itemText.text(markPos - 1) == SpecialChars::PARSEP)
item->itemText.removeChars(markPos - 1, 2);
else
item->itemText.removeChars(markPos, 1);
@@ -17414,39 +17411,37 @@
for (int pos = frame->firstInFrame(); pos <= frame->lastInFrame(); ++pos)
{
+ if (!frame->itemText.hasMark(pos, MARKNoteMasterType))
+ continue;
Mark* mark = frame->itemText.mark(pos);
- if (frame->itemText.hasMark(pos) && mark->isType(MARKNoteMasterType))
- {
- if (mark->getNotePtr() == nullptr)
- continue;
- if (mark->getNotePtr()->notesStyle() == nStyle)
- {
- QString numStr = nStyle->prefix() + nStyle->numString(noteNum) + nStyle->suffix();
- QString mStr = mark->getString();
- QString label = mark->label;
- if ((mStr != numStr) || flag_updateMarksLabels || flag_updateEndNotes)
- {
- doUpdate = true;
- mark->setString(numStr);
- label = "NoteMark_" + nStyle->name();
- if (nStyle->range() == NSRstory)
- label += " in " + frame->firstInChain()->itemName();
- label += "_" + QString::number(noteNum);
- mark->label = label;
- }
- TextNote* note = mark->getNotePtr();
- note->setNum(noteNum);
- note->masterMark()->setItemPtr(frame);
- if (note->noteMark() != nullptr)
- {
- note->noteMark()->setString(numStr);
- label = label.replace("NoteMark","NoteFrameMark");
- note->noteMark()->label = label;
- }
- ++index;
- ++noteNum;
- }
- }
+
+ TextNote* note = mark->getNotePtr();
+ if (note == nullptr || note->notesStyle() != nStyle)
+ continue;
+
+ QString numStr = nStyle->prefix() + nStyle->numString(noteNum) + nStyle->suffix();
+ QString mStr = mark->getString();
+ QString label = mark->label;
+ if ((mStr != numStr) || flag_updateMarksLabels || flag_updateEndNotes)
+ {
+ doUpdate = true;
+ mark->setString(numStr);
+ label = "NoteMark_" + nStyle->name();
+ if (nStyle->range() == NSRstory)
+ label += " in " + frame->firstInChain()->itemName();
+ label += "_" + QString::number(noteNum);
+ mark->label = label;
+ }
+ note->setNum(noteNum);
+ note->masterMark()->setItemPtr(frame);
+ if (note->noteMark() != nullptr)
+ {
+ note->noteMark()->setString(numStr);
+ label = label.replace("NoteMark","NoteFrameMark");
+ note->noteMark()->label = label;
+ }
+ ++index;
+ ++noteNum;
}
PageItem_NoteFrame* nF = nullptr;
if (nStyle->isEndNotes())
@@ -17933,7 +17928,7 @@
}
}
m_Selection->delaySignalsOn();
- if (m_Selection->findItem(nF)!=-1)
+ if (m_Selection->findItem(nF) != -1)
{
if (appMode == modeEdit)
view()->requestMode(modeNormal);
Modified: trunk/Scribus/scribus/text/storytext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/scribus/text/storytext.cpp
==============================================================================
--- trunk/Scribus/scribus/text/storytext.cpp (original)
+++ trunk/Scribus/scribus/text/storytext.cpp Tue Aug 3 15:48:13 2021
@@ -27,6 +27,7 @@
//FIXME: this include must go to sctextstruct.h !
#include <QList>
#include <cassert> //added to make Fedora-5 happy
+
#include "fpoint.h"
#include "notesstyles.h"
#include "scfonts.h"
@@ -34,6 +35,7 @@
#include "sctext_shared.h"
#include "selection.h"
#include "storytext.h"
+#include "textnote.h"
//
#include "util.h"
#include "resourcecollection.h"
@@ -1142,6 +1144,26 @@
return -1;
}
+int StoryText::findNote(const TextNote* textNote) const
+{
+ if (d->len <= 0)
+ return -1;
+
+ int len = d->len;
+ for (int i = 0; i < len; ++i)
+ {
+ const ScText* textItem = d->at(i);
+ if (textItem->ch != SpecialChars::OBJECT || textItem->mark == nullptr)
+ continue;
+ if (textItem->mark->getType() != MARKNoteFrameType)
+ continue;
+ if (textItem->mark->getNotePtr() == textNote)
+ return i;
+ }
+
+ return -1;
+}
+
bool StoryText::hasMark(int pos, const Mark* mrk) const
{
if (pos < 0)
@@ -1150,13 +1172,12 @@
assert(pos >= 0);
assert(pos < length());
- StoryText* that = const_cast<StoryText *>(this);
- if (that->d->at(pos)->ch == SpecialChars::OBJECT)
- return that->d->at(pos)->hasMark(mrk);
+ if (d->at(pos)->ch == SpecialChars::OBJECT)
+ return d->at(pos)->hasMark(mrk);
return false;
}
-Mark* StoryText::mark(int pos) const
+bool StoryText::hasMark(int pos, MarkType markType) const
{
if (pos < 0)
pos += length();
@@ -1164,8 +1185,21 @@
assert(pos >= 0);
assert(pos < length());
- StoryText* that = const_cast<StoryText *>(this);
- return that->d->at(pos)->mark;
+ const ScText* textItem = d->at(pos);
+ if (textItem->ch != SpecialChars::OBJECT)
+ return false;
+ return (textItem->mark && textItem->mark->isType(markType));
+}
+
+Mark* StoryText::mark(int pos) const
+{
+ if (pos < 0)
+ pos += length();
+
+ assert(pos >= 0);
+ assert(pos < length());
+
+ return d->at(pos)->mark;
}
@@ -1204,7 +1238,6 @@
if (s != currStyle.effects())
currStyle.setFeatures(s.featureList());
}
-
void StoryText::replaceMark(int pos, Mark* mrk)
{
@@ -1235,7 +1268,6 @@
{
return pos >= 0 && pos < length() && text(pos).isLowSurrogate();
}
-
LayoutFlags StoryText::flags(int pos) const
{
@@ -2171,13 +2203,13 @@
}
*/
-ScText* StoryText::item(int index)
+ScText* StoryText::item(int index)
{
assert( index < length() );
return const_cast<StoryText *>(this)->d->at(index);
}
-const ScText* StoryText::item(int index) const
+const ScText* StoryText::item(int index) const
{
assert( index < length() );
return const_cast<StoryText *>(this)->d->at(index);
Modified: trunk/Scribus/scribus/text/storytext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/scribus/text/storytext.h
==============================================================================
--- trunk/Scribus/scribus/text/storytext.h (original)
+++ trunk/Scribus/scribus/text/storytext.h Tue Aug 3 15:48:13 2021
@@ -44,10 +44,11 @@
class CharStyle;
class ParagraphStyle;
class PageItem;
+class ResourceCollection;
class ScribusDoc;
class ScText_Shared;
-class ResourceCollection;
class ShapedTextCache;
+class TextNote;
U_NAMESPACE_BEGIN
class BreakIterator;
@@ -175,11 +176,15 @@
bool hasObject(int pos) const;
PageItem* getItem(int pos) const; // deprecated
+
int findMark(const Mark* mrk, int startPos = 0) const;
bool hasMark(int pos, const Mark* mrk = nullptr) const;
+ bool hasMark(int pos, MarkType markType) const;
Mark *mark(int pos) const;
void replaceMark(int pos, Mark* mrk);
void applyMarkCharstyle(Mark* mrk, CharStyle& currStyle) const;
+
+ int findNote(const TextNote* textNote) const;
bool isHighSurrogate(int pos) const;
bool isLowSurrogate(int pos) const;
Modified: trunk/Scribus/scribus/text/textcontext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/scribus/text/textcontext.cpp
==============================================================================
--- trunk/Scribus/scribus/text/textcontext.cpp (original)
+++ trunk/Scribus/scribus/text/textcontext.cpp Tue Aug 3 15:48:13 2021
@@ -12,9 +12,8 @@
#include "styles/charstyle.h"
#include "styles/paragraphstyle.h"
#include "scribusdoc.h"
+#include "textnote.h"
#include "util.h"
-
-
static CharStyle* emptyCStyle;
static ParagraphStyle* emptyPStyle;
Modified: trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj
==============================================================================
--- trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj (original)
+++ trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj Tue Aug 3 15:48:13 2021
@@ -403,6 +403,7 @@
<moc Include="..\..\..\scribus\ui\fontreplacedialog.h" />
<ClInclude Include="..\..\..\scribus\fpoint.h" />
<ClInclude Include="..\..\..\scribus\fpointarray.h" />
+ <moc Include="..\..\..\scribus\textnote.h" />
<ClInclude Include="..\..\..\scribus\text\boxes.h" />
<ClInclude Include="..\..\..\scribus\text\frect.h" />
<ClInclude Include="..\..\..\scribus\text\fsize.h" />
@@ -503,7 +504,7 @@
<ClInclude Include="..\..\..\scribus\nfttemplate.h" />
<moc Include="..\..\..\scribus\ui\nftwidget.h" />
<moc Include="..\..\..\scribus\ui\nodeeditpalette.h" />
- <moc Include="..\..\..\scribus\notesstyles.h" />
+ <ClInclude Include="..\..\..\scribus\notesstyles.h" />
<moc Include="..\..\..\scribus\ui\notesstyleseditor.h" />
<ClInclude Include="..\..\..\scribus\numeration.h" />
<moc Include="..\..\..\scribus\observable.h" />
@@ -907,6 +908,7 @@
<ClCompile Include="..\..\..\scribus\scprintengine_pdf.cpp" />
<ClCompile Include="..\..\..\scribus\selectionrubberband.cpp" />
<ClCompile Include="..\..\..\scribus\storyloader.cpp" />
+ <ClCompile Include="..\..\..\scribus\textnote.cpp" />
<ClCompile Include="..\..\..\scribus\text\boxes.cpp" />
<ClCompile Include="..\..\..\scribus\text\glyphcluster.cpp" />
<ClCompile Include="..\..\..\scribus\text\index.cpp" />
Modified: trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj.filters
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj.filters
==============================================================================
--- trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj.filters (original)
+++ trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj.filters Tue Aug 3 15:48:13 2021
@@ -842,6 +842,9 @@
<ClInclude Include="..\..\..\scribus\api\api_application.h">
<Filter>api</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\scribus\textnote.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\scribus\desaxe\digester.cpp">
@@ -2570,6 +2573,9 @@
<Filter>api</Filter>
</ClCompile>
<ClCompile Include="..\..\..\scribus\ui\prefs_pane.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\scribus\textnote.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
Modified: trunk/Scribus/win32/msvc2017/scribus-main/Scribus.vcxproj
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/win32/msvc2017/scribus-main/Scribus.vcxproj
==============================================================================
--- trunk/Scribus/win32/msvc2017/scribus-main/Scribus.vcxproj (original)
+++ trunk/Scribus/win32/msvc2017/scribus-main/Scribus.vcxproj Tue Aug 3 15:48:13 2021
@@ -403,6 +403,7 @@
<moc Include="..\..\..\scribus\ui\fontreplacedialog.h" />
<ClInclude Include="..\..\..\scribus\fpoint.h" />
<ClInclude Include="..\..\..\scribus\fpointarray.h" />
+ <moc Include="..\..\..\scribus\textnote.h" />
<ClInclude Include="..\..\..\scribus\text\boxes.h" />
<ClInclude Include="..\..\..\scribus\text\frect.h" />
<ClInclude Include="..\..\..\scribus\text\fsize.h" />
@@ -503,7 +504,7 @@
<ClInclude Include="..\..\..\scribus\nfttemplate.h" />
<moc Include="..\..\..\scribus\ui\nftwidget.h" />
<moc Include="..\..\..\scribus\ui\nodeeditpalette.h" />
- <moc Include="..\..\..\scribus\notesstyles.h" />
+ <ClInclude Include="..\..\..\scribus\notesstyles.h" />
<moc Include="..\..\..\scribus\ui\notesstyleseditor.h" />
<ClInclude Include="..\..\..\scribus\numeration.h" />
<moc Include="..\..\..\scribus\observable.h" />
@@ -907,6 +908,7 @@
<ClCompile Include="..\..\..\scribus\scprintengine_pdf.cpp" />
<ClCompile Include="..\..\..\scribus\selectionrubberband.cpp" />
<ClCompile Include="..\..\..\scribus\storyloader.cpp" />
+ <ClCompile Include="..\..\..\scribus\textnote.cpp" />
<ClCompile Include="..\..\..\scribus\text\boxes.cpp" />
<ClCompile Include="..\..\..\scribus\text\glyphcluster.cpp" />
<ClCompile Include="..\..\..\scribus\text\index.cpp" />
Modified: trunk/Scribus/win32/msvc2017/scribus-main/Scribus.vcxproj.filters
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/win32/msvc2017/scribus-main/Scribus.vcxproj.filters
==============================================================================
--- trunk/Scribus/win32/msvc2017/scribus-main/Scribus.vcxproj.filters (original)
+++ trunk/Scribus/win32/msvc2017/scribus-main/Scribus.vcxproj.filters Tue Aug 3 15:48:13 2021
@@ -842,6 +842,9 @@
<ClInclude Include="..\..\..\scribus\api\api_application.h">
<Filter>api</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\scribus\textnote.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\scribus\desaxe\digester.cpp">
@@ -2570,6 +2573,9 @@
<Filter>api</Filter>
</ClCompile>
<ClCompile Include="..\..\..\scribus\ui\prefs_pane.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\scribus\textnote.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
Modified: trunk/Scribus/win32/msvc2019/scribus-main/Scribus.vcxproj
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/win32/msvc2019/scribus-main/Scribus.vcxproj
==============================================================================
--- trunk/Scribus/win32/msvc2019/scribus-main/Scribus.vcxproj (original)
+++ trunk/Scribus/win32/msvc2019/scribus-main/Scribus.vcxproj Tue Aug 3 15:48:13 2021
@@ -404,6 +404,7 @@
<moc Include="..\..\..\scribus\ui\fontreplacedialog.h" />
<ClInclude Include="..\..\..\scribus\fpoint.h" />
<ClInclude Include="..\..\..\scribus\fpointarray.h" />
+ <moc Include="..\..\..\scribus\textnote.h" />
<ClInclude Include="..\..\..\scribus\text\boxes.h" />
<ClInclude Include="..\..\..\scribus\text\frect.h" />
<ClInclude Include="..\..\..\scribus\text\fsize.h" />
@@ -504,7 +505,7 @@
<ClInclude Include="..\..\..\scribus\nfttemplate.h" />
<moc Include="..\..\..\scribus\ui\nftwidget.h" />
<moc Include="..\..\..\scribus\ui\nodeeditpalette.h" />
- <moc Include="..\..\..\scribus\notesstyles.h" />
+ <ClInclude Include="..\..\..\scribus\notesstyles.h" />
<moc Include="..\..\..\scribus\ui\notesstyleseditor.h" />
<ClInclude Include="..\..\..\scribus\numeration.h" />
<moc Include="..\..\..\scribus\observable.h" />
@@ -908,6 +909,7 @@
<ClCompile Include="..\..\..\scribus\scprintengine_pdf.cpp" />
<ClCompile Include="..\..\..\scribus\selectionrubberband.cpp" />
<ClCompile Include="..\..\..\scribus\storyloader.cpp" />
+ <ClCompile Include="..\..\..\scribus\textnote.cpp" />
<ClCompile Include="..\..\..\scribus\text\boxes.cpp" />
<ClCompile Include="..\..\..\scribus\text\glyphcluster.cpp" />
<ClCompile Include="..\..\..\scribus\text\index.cpp" />
Modified: trunk/Scribus/win32/msvc2019/scribus-main/Scribus.vcxproj.filters
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24684&path=/trunk/Scribus/win32/msvc2019/scribus-main/Scribus.vcxproj.filters
==============================================================================
--- trunk/Scribus/win32/msvc2019/scribus-main/Scribus.vcxproj.filters (original)
+++ trunk/Scribus/win32/msvc2019/scribus-main/Scribus.vcxproj.filters Tue Aug 3 15:48:13 2021
@@ -842,6 +842,9 @@
<ClInclude Include="..\..\..\scribus\api\api_application.h">
<Filter>api</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\scribus\textnote.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\scribus\desaxe\digester.cpp">
@@ -2570,6 +2573,9 @@
<Filter>api</Filter>
</ClCompile>
<ClCompile Include="..\..\..\scribus\ui\prefs_pane.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\scribus\textnote.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
More information about the scribus-commit
mailing list