summaryrefslogtreecommitdiffstats
path: root/scribus/sctextstruct.cpp
diff options
context:
space:
mode:
authorcraig <craig@11d20701-8431-0410-a711-e3c959e3b870>2012-01-01 11:40:09 +0000
committercraig <craig@11d20701-8431-0410-a711-e3c959e3b870>2012-01-01 11:40:09 +0000
commit7ed83b6c6666eb8b6b104c211ae7e52907350372 (patch)
tree4430b556abac0ad660a0aacf1887d77f85d8be02 /scribus/sctextstruct.cpp
downloadscribus-7ed83b6c6666eb8b6b104c211ae7e52907350372.tar.gz
scribus-7ed83b6c6666eb8b6b104c211ae7e52907350372.tar.xz
scribus-7ed83b6c6666eb8b6b104c211ae7e52907350372.zip
Branch 1.3.5 tree to 1.4.x tree, goodbye 1.3.x
git-svn-id: svn://scribus.net/branches/Version14x/Scribus@17163 11d20701-8431-0410-a711-e3c959e3b870
Diffstat (limited to 'scribus/sctextstruct.cpp')
-rw-r--r--scribus/sctextstruct.cpp143
1 files changed, 143 insertions, 0 deletions
diff --git a/scribus/sctextstruct.cpp b/scribus/sctextstruct.cpp
new file mode 100644
index 0000000..44315b5
--- /dev/null
+++ b/scribus/sctextstruct.cpp
@@ -0,0 +1,143 @@
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+
+#include <QObject>
+#include <QList>
+#include <QPointer>
+#include "sctextstruct.h"
+#include "scfonts.h"
+#include "pageitem.h"
+#include "scribusdoc.h"
+
+void GlyphLayout::growWithTabLayout()
+{
+ if (more)
+ shrink();
+ more = new TabLayout();
+}
+
+struct InlineFrameData
+{
+ QPointer<PageItem> item;
+ int refs;
+
+ void reserve()
+ {
+ ++refs;
+ }
+
+ bool release()
+ {
+ --refs;
+ if (refs == 0 && item != NULL)
+ {
+ item->doc()->FrameItems.removeAll(item);
+ item->doc()->updateFrameItems();
+ delete item;
+ item = NULL;
+ }
+ return refs == 0;
+ }
+};
+
+InlineFrame::InlineFrame(PageItem* item)
+{
+ d = new InlineFrameData;
+ d->item = item;
+ d->refs = 1;
+}
+
+InlineFrame::InlineFrame(const InlineFrame& other)
+{
+ d = other.d;
+ d->reserve();
+}
+
+InlineFrame& InlineFrame::operator= (const InlineFrame& other)
+{
+ if (this != &other)
+ {
+ if (d->release())
+ delete d;
+ d = other.d;
+ d->reserve();
+ }
+ return *this;
+}
+
+InlineFrame::~InlineFrame()
+{
+ if (d->release())
+ delete d;
+}
+
+bool InlineFrame::hasItem() const
+{
+ return d->item != NULL;
+}
+
+bool InlineFrame::isShared() const
+{
+ return d->refs > 1;
+}
+
+PageItem* InlineFrame::getItem()
+{
+ return d->item;
+}
+
+QList<PageItem*> InlineFrame::getGroupedItems()
+{
+ QList<PageItem*> result;
+// result.setAutoDelete(false);
+ if (hasItem())
+ {
+ PageItem* dItem = d->item;
+ ScribusDoc& doc(*dItem->doc());
+ result.append(d->item);
+ if (dItem->Groups.count() != 0)
+ {
+ for (int ga=0; ga < doc.FrameItems.count(); ++ga)
+ {
+ if (doc.FrameItems.at(ga)->Groups.count() != 0)
+ {
+ if (doc.FrameItems.at(ga)->Groups.top() == dItem->Groups.top())
+ {
+ if (doc.FrameItems.at(ga)->ItemNr != dItem->ItemNr)
+ {
+ if (!result.contains(doc.FrameItems.at(ga)))
+ result.append(doc.FrameItems.at(ga));
+ }
+ }
+ }
+ }
+ }
+ }
+ return result;
+}
+
+
+ScText::~ScText()
+{
+ // delete the linked list if present
+ GlyphLayout * more = glyph.more;
+ while (more) {
+ glyph.more = glyph.more->more;
+ delete more;
+ more = glyph.more;
+ }
+ if (parstyle)
+ delete parstyle;
+ parstyle = NULL;
+}
+
+bool ScText::hasObject() const
+{
+ if (this->ch == SpecialChars::OBJECT)
+ return this->embedded.hasItem();
+ return false;
+}