[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra] /: Use only one property for all kinds of generated
From:       Casper Boemann <cbo () boemann ! dk>
Date:       2011-09-10 20:59:25
Message-ID: 20110910205925.217D5A60A6 () git ! kde ! org
[Download RAW message or body]

Git commit e2c6c3d16c562b31c8dd7e4528b865fc7c483d48 by Casper Boemann.
Committed on 10/09/2011 at 22:57.
Pushed by boemann into branch 'master'.

Use only one property for all kinds of generated documents. so we can reuse gode for \
layout etc

M  +2    -2    libs/kotext/KoTextEditor.cpp
M  +2    -2    libs/kotext/opendocument/KoTextLoader.cpp
M  +4    -4    libs/kotext/opendocument/KoTextWriter_p.cpp
M  +1    -2    libs/kotext/styles/KoParagraphStyle.h
M  +1    -1    libs/textlayout/IndexGeneratorManager.cpp
M  +23   -71   libs/textlayout/KoTextLayoutArea.cpp
M  +1    -2    libs/textlayout/KoTextLayoutArea.h
M  +6    -6    libs/textlayout/KoTextLayoutArea_paint.cpp
M  +1    -1    plugins/textshape/ReferencesTool.cpp
M  +1    -1    plugins/textshape/dialogs/InsertBibliographyDialog.cpp
M  +1    -1    plugins/textshape/dialogs/TableOfContentsPreview.cpp

http://commits.kde.org/calligra/e2c6c3d16c562b31c8dd7e4528b865fc7c483d48

diff --git a/libs/kotext/KoTextEditor.cpp b/libs/kotext/KoTextEditor.cpp
index 21001e1..dab532d 100644
--- a/libs/kotext/KoTextEditor.cpp
+++ b/libs/kotext/KoTextEditor.cpp
@@ -1398,7 +1398,7 @@ void KoTextEditor::insertTableOfContents()
     KoTableOfContentsGeneratorInfo *info = new KoTableOfContentsGeneratorInfo();
     QTextDocument *tocDocument = new QTextDocument();
     tocFormat.setProperty(KoParagraphStyle::TableOfContentsData, \
                QVariant::fromValue<KoTableOfContentsGeneratorInfo*>(info) );
-    tocFormat.setProperty(KoParagraphStyle::TableOfContentsDocument, \
QVariant::fromValue<QTextDocument*>(tocDocument) ); +    \
tocFormat.setProperty(KoParagraphStyle::GeneratedDocument, \
QVariant::fromValue<QTextDocument*>(tocDocument) );  
     KoChangeTracker *changeTracker = KoTextDocument(d->document).changeTracker();
     if (changeTracker && changeTracker->recordChanges()) {
@@ -1458,7 +1458,7 @@ void KoTextEditor::insertBibliography()
     *autoUpdate = false;
 
     bibFormat.setProperty( KoParagraphStyle::BibliographyData, \
                QVariant::fromValue<KoBibliographyInfo*>(info));
-    bibFormat.setProperty( KoParagraphStyle::BibliographyDocument, \
QVariant::fromValue<QTextDocument*>(bibDocument)); +    bibFormat.setProperty( \
KoParagraphStyle::GeneratedDocument, \
                QVariant::fromValue<QTextDocument*>(bibDocument));
     bibFormat.setProperty( KoParagraphStyle::AutoUpdateBibliography, \
QVariant::fromValue<bool *>(autoUpdate));  
     KoChangeTracker *changeTracker = KoTextDocument(d->document).changeTracker();
diff --git a/libs/kotext/opendocument/KoTextLoader.cpp \
b/libs/kotext/opendocument/KoTextLoader.cpp index e9d47da..6ce4695 100644
--- a/libs/kotext/opendocument/KoTextLoader.cpp
+++ b/libs/kotext/opendocument/KoTextLoader.cpp
@@ -2333,7 +2333,7 @@ void KoTextLoader::loadTableOfContents(const KoXmlElement \
&element, QTextCursor  // uncomment to see what has been loaded
             //info.tableOfContentData()->dump();
             tocFormat.setProperty(KoParagraphStyle::TableOfContentsData, \
                QVariant::fromValue<KoTableOfContentsGeneratorInfo*>(info) );
-            tocFormat.setProperty(KoParagraphStyle::TableOfContentsDocument, \
QVariant::fromValue<QTextDocument*>(tocDocument) ); +            \
tocFormat.setProperty(KoParagraphStyle::GeneratedDocument, \
QVariant::fromValue<QTextDocument*>(tocDocument) );  cursor.insertBlock(tocFormat);
 
             // We'll just try to find displayable elements and add them as \
paragraphs @@ -2401,7 +2401,7 @@ void KoTextLoader::loadBibliography(const \
KoXmlElement &element, QTextCursor &cu  info->loadOdf(d->textSharedData, e);
 
             bibFormat.setProperty(KoParagraphStyle::BibliographyData, \
                QVariant::fromValue<KoBibliographyInfo*>(info));
-            bibFormat.setProperty(KoParagraphStyle::BibliographyDocument, \
QVariant::fromValue<QTextDocument*>(bibDocument)); +            \
bibFormat.setProperty(KoParagraphStyle::GeneratedDocument, \
                QVariant::fromValue<QTextDocument*>(bibDocument));
             bibFormat.setProperty(KoParagraphStyle::AutoUpdateBibliography, \
QVariant::fromValue<bool *>(autoUpdate));  cursor.insertBlock(bibFormat);
             // We'll just try to find displayable elements and add them as \
                paragraphs
diff --git a/libs/kotext/opendocument/KoTextWriter_p.cpp \
b/libs/kotext/opendocument/KoTextWriter_p.cpp index 20358aa..b5008ce 100644
--- a/libs/kotext/opendocument/KoTextWriter_p.cpp
+++ b/libs/kotext/opendocument/KoTextWriter_p.cpp
@@ -87,12 +87,12 @@ void KoTextWriter::Private::writeBlocks(QTextDocument *document, \
int from, int t  }
             }
         }
-        if (format.hasProperty(KoParagraphStyle::TableOfContentsDocument)) {
+        if (format.hasProperty(KoParagraphStyle::TableOfContentsData)) {
             saveTableOfContents(document, listStyles, block);
             block = block.next();
             continue;
         }
-        if (format.hasProperty(KoParagraphStyle::BibliographyDocument)) {
+        if (format.hasProperty(KoParagraphStyle::BibliographyData)) {
             saveBibliography(document, listStyles, block);
             block = block.next();
             continue;
@@ -1245,7 +1245,7 @@ void KoTextWriter::Private::saveTableOfContents(QTextDocument \
*document, QHash<Q  writer->startElement("text:table-of-content");
 
     KoTableOfContentsGeneratorInfo *info = \
toc.blockFormat().property(KoParagraphStyle::TableOfContentsData).value<KoTableOfContentsGeneratorInfo*>();
                
-    QTextDocument *tocDocument = \
toc.blockFormat().property(KoParagraphStyle::TableOfContentsDocument).value<QTextDocument*>();
 +    QTextDocument *tocDocument = \
toc.blockFormat().property(KoParagraphStyle::GeneratedDocument).value<QTextDocument*>();
  if (!info->m_styleName.isNull()) {
             writer->addAttribute("text:style-name",info->m_styleName);
     }
@@ -1275,7 +1275,7 @@ void KoTextWriter::Private::saveBibliography(QTextDocument \
*document, QHash<QTex  writer->startElement("text:bibliography");
 
     KoBibliographyInfo *info = \
bib.blockFormat().property(KoParagraphStyle::BibliographyData).value<KoBibliographyInfo*>();
                
-    QTextDocument *bibDocument = \
bib.blockFormat().property(KoParagraphStyle::BibliographyDocument).value<QTextDocument*>();
 +    QTextDocument *bibDocument = \
bib.blockFormat().property(KoParagraphStyle::GeneratedDocument).value<QTextDocument*>();
  if (!info->m_styleName.isNull()) {
             writer->addAttribute("text:style-name",info->m_styleName);
     }
diff --git a/libs/kotext/styles/KoParagraphStyle.h \
b/libs/kotext/styles/KoParagraphStyle.h index 0c4f25f..447b752 100644
--- a/libs/kotext/styles/KoParagraphStyle.h
+++ b/libs/kotext/styles/KoParagraphStyle.h
@@ -159,11 +159,10 @@ public:
 
         NormalLineHeight,         ///< bool, internal property for reserved usage
         BibliographyData,
-        BibliographyDocument,
         AutoUpdateBibliography,
 
         TableOfContentsData,      // set when block is instead a TableOfContents
-        TableOfContentsDocument,  // set when block is instead a TableOfContents
+        GeneratedDocument,  // set when block is instead a generated document
         Shadow                    //< KoShadowStyle, the shadow of this paragraph
     };
 
diff --git a/libs/textlayout/IndexGeneratorManager.cpp \
b/libs/textlayout/IndexGeneratorManager.cpp index 1ee6ebe..f941140 100644
--- a/libs/textlayout/IndexGeneratorManager.cpp
+++ b/libs/textlayout/IndexGeneratorManager.cpp
@@ -134,7 +134,7 @@ bool IndexGeneratorManager::generate()
             QVariant data = format.property(KoParagraphStyle::TableOfContentsData);
             KoTableOfContentsGeneratorInfo *tocInfo = \
data.value<KoTableOfContentsGeneratorInfo *>();  
-            data = format.property(KoParagraphStyle::TableOfContentsDocument);
+            data = format.property(KoParagraphStyle::GeneratedDocument);
             QTextDocument *tocDocument = data.value<QTextDocument *>();
 
             ToCGenerator *generator = m_generators[tocInfo];
diff --git a/libs/textlayout/KoTextLayoutArea.cpp \
b/libs/textlayout/KoTextLayoutArea.cpp index 63d2628..48f1e9d 100644
--- a/libs/textlayout/KoTextLayoutArea.cpp
+++ b/libs/textlayout/KoTextLayoutArea.cpp
@@ -150,11 +150,11 @@ KoPointedAt KoTextLayoutArea::hitTest(const QPointF &p, \
Qt::HitTestAccuracy accu  if (!block.isValid())
                 continue;
         }
-        if (block.blockFormat().hasProperty(KoParagraphStyle::TableOfContentsDocument)) \
{ +        if (block.blockFormat().hasProperty(KoParagraphStyle::GeneratedDocument)) \
{  // check if p is over table of content
-            if (point.y() > m_tableOfContentsAreas[tocIndex]->top()
-                    && point.y() < m_tableOfContentsAreas[tocIndex]->bottom()) {
-                pointedAt = m_tableOfContentsAreas[tocIndex]->hitTest(point, \
accuracy); +            if (point.y() > m_generatedDocAreas[tocIndex]->top()
+                    && point.y() < m_generatedDocAreas[tocIndex]->bottom()) {
+                pointedAt = m_generatedDocAreas[tocIndex]->hitTest(point, accuracy);
                 pointedAt.position = block.position();
                 return pointedAt;
             }
@@ -262,10 +262,10 @@ QRectF KoTextLayoutArea::selectionBoundingBox(QTextCursor \
&cursor) const  if (!block.isValid())
                 continue;
         }
-        if (block.blockFormat().hasProperty(KoParagraphStyle::TableOfContentsDocument)) \
{ +        if (block.blockFormat().hasProperty(KoParagraphStyle::GeneratedDocument)) \
{  if (cursor.selectionStart()  <= block.position()
                 && cursor.selectionEnd() >= block.position()) {
-                retval |= m_tableOfContentsAreas[tocIndex]->boundingRect();
+                retval |= m_generatedDocAreas[tocIndex]->boundingRect();
             }
             ++tocIndex;
             continue;
@@ -332,8 +332,8 @@ bool KoTextLayoutArea::layout(FrameIterator *cursor)
     m_footNoteAreas.clear();
     qDeleteAll(m_preregisteredFootNoteAreas);
     m_preregisteredFootNoteAreas.clear();
-    qDeleteAll(m_tableOfContentsAreas);
-    m_tableOfContentsAreas.clear();
+    qDeleteAll(m_generatedDocAreas);
+    m_generatedDocAreas.clear();
     m_blockRects.clear();
     delete m_endNotesArea;
     m_endNotesArea=0;
@@ -422,19 +422,19 @@ bool KoTextLayoutArea::layout(FrameIterator *cursor)
                 cursor->currentSubFrameIterator = 0;
             }
         } else if (block.isValid()) {
-            if (block.blockFormat().hasProperty(KoParagraphStyle::TableOfContentsDocument)) \
                {
-                QVariant data = \
                block.blockFormat().property(KoParagraphStyle::TableOfContentsDocument);
                
-                QTextDocument *tocDocument = data.value<QTextDocument *>();
+            if (block.blockFormat().hasProperty(KoParagraphStyle::GeneratedDocument)) \
{ +                QVariant data = \
block.blockFormat().property(KoParagraphStyle::GeneratedDocument); +                \
QTextDocument *generatedDocument = data.value<QTextDocument *>();  
-                // Let's create KoTextLayoutArea and let it handle the ToC
-                KoTextLayoutArea *tocArea = new KoTextLayoutArea(this, \
                documentLayout());
-                m_tableOfContentsAreas.append(tocArea);
+                // Let's create KoTextLayoutArea and let it handle the generated \
document +                KoTextLayoutArea *area = new KoTextLayoutArea(this, \
documentLayout()); +                m_generatedDocAreas.append(area);
                 m_y += m_bottomSpacing;
                 if (!m_blockRects.isEmpty()) {
                     m_blockRects.last().setBottom(m_y);
                 }
-                tocArea->setVirginPage(virginPage());
-                tocArea->setReferenceRect(left(), right(), m_y, \
maximumAllowedBottom()); +                area->setVirginPage(virginPage());
+                area->setReferenceRect(left(), right(), m_y, \
maximumAllowedBottom());  QTextLayout *blayout = block.layout();
                 blayout->beginLayout();
                 QTextLine line = blayout->createLine();
@@ -442,70 +442,22 @@ bool KoTextLayoutArea::layout(FrameIterator *cursor)
                 line.setPosition(QPointF(left(), m_y));
                 blayout->endLayout();
 
-                if (tocArea->layout(cursor->subFrameIterator(tocDocument->rootFrame())) \
== false) { +                if \
(area->layout(cursor->subFrameIterator(generatedDocument->rootFrame())) == false) {  \
cursor->lineTextStart = 1; // fake we are not done  m_endOfArea = new \
                FrameIterator(cursor);
-                    m_y = tocArea->bottom();
+                    m_y = area->bottom();
                     setBottom(m_y + m_footNotesHeight);
                     // Expand bounding rect so if we have content outside we show it
-                    expandBoundingLeft(tocArea->boundingRect().left());
-                    expandBoundingRight(tocArea->boundingRect().right());
+                    expandBoundingLeft(area->boundingRect().left());
+                    expandBoundingRight(area->boundingRect().right());
                     return false;
                 }
                 setVirginPage(false);
                 // Expand bounding rect so if we have content outside we show it
-                expandBoundingLeft(tocArea->boundingRect().left());
-                expandBoundingRight(tocArea->boundingRect().right());
+                expandBoundingLeft(area->boundingRect().left());
+                expandBoundingRight(area->boundingRect().right());
                 m_bottomSpacing = 0;
-                m_y = tocArea->bottom();
-                delete cursor->currentSubFrameIterator;
-                cursor->lineTextStart = -1; // fake we are done
-                cursor->currentSubFrameIterator = 0;
-            } else if \
                (block.blockFormat().hasProperty(KoParagraphStyle::BibliographyDocument)) \
                {
-
-                QVariant data = \
                block.blockFormat().property(KoParagraphStyle::BibliographyDocument);
-                QTextDocument *bibDocument = data.value<QTextDocument *>();
-
-                data = \
                block.blockFormat().property(KoParagraphStyle::BibliographyData);
-                KoBibliographyInfo *bibInfo = data.value<KoBibliographyInfo *>();
-
-                if (!bibInfo->generator()) {
-                    // The generator attaches itself to the bibInfo
-                    new BibliographyGenerator(bibDocument, block, bibInfo, \
                cursor->it.currentBlock().document());
-                }
-
-                // Let's create KoTextLayoutArea and let to handle the Bibliography
-                KoTextLayoutArea *bibArea = new KoTextLayoutArea(this, \
                documentLayout());
-                m_bibliographyAreas.append(bibArea);
-                m_y += m_bottomSpacing;
-                if (!m_blockRects.isEmpty()) {
-                    m_blockRects.last().setBottom(m_y);
-                }
-                bibArea->setVirginPage(virginPage());
-                bibArea->setReferenceRect(left(), right(), m_y, \
                maximumAllowedBottom());
-                QTextLayout *blayout = block.layout();
-                blayout->beginLayout();
-                QTextLine line = blayout->createLine();
-                line.setNumColumns(0);
-                line.setPosition(QPointF(left(), m_y));
-                blayout->endLayout();
-
-                if (bibArea->layout(cursor->subFrameIterator(bibDocument->rootFrame())) \
                == false) {
-                    cursor->lineTextStart = 1; // fake we are not done
-                    m_endOfArea = new FrameIterator(cursor);
-                    m_y = bibArea->bottom();
-                    setBottom(m_y + m_footNotesHeight);
-                    // Expand bounding rect so if we have content outside we show it
-                    expandBoundingLeft(bibArea->boundingRect().left());
-                    expandBoundingRight(bibArea->boundingRect().right());
-                    return false;
-                }
-                setVirginPage(false);
-                // Expand bounding rect so if we have content outside we show it
-                expandBoundingLeft(bibArea->boundingRect().left());
-                expandBoundingRight(bibArea->boundingRect().right());
-                m_bottomSpacing = 0;
-                m_y = bibArea->bottom();
+                m_y = area->bottom();
                 delete cursor->currentSubFrameIterator;
                 cursor->lineTextStart = -1; // fake we are done
                 cursor->currentSubFrameIterator = 0;
diff --git a/libs/textlayout/KoTextLayoutArea.h b/libs/textlayout/KoTextLayoutArea.h
index ea7fd8e..f9cd084 100644
--- a/libs/textlayout/KoTextLayoutArea.h
+++ b/libs/textlayout/KoTextLayoutArea.h
@@ -233,8 +233,7 @@ private:
     QList<KoTextLayoutArea *> m_preregisteredFootNoteAreas;
     QList<KoTextLayoutArea *> m_footNoteAreas;
     KoTextLayoutEndNotesArea *m_endNotesArea;
-    QList<KoTextLayoutArea *> m_tableOfContentsAreas;
-    QList<KoTextLayoutArea *> m_bibliographyAreas;
+    QList<KoTextLayoutArea *> m_generatedDocAreas;
 };
 
 #endif
diff --git a/libs/textlayout/KoTextLayoutArea_paint.cpp \
b/libs/textlayout/KoTextLayoutArea_paint.cpp index cdee623..6b3e293 100644
--- a/libs/textlayout/KoTextLayoutArea_paint.cpp
+++ b/libs/textlayout/KoTextLayoutArea_paint.cpp
@@ -134,11 +134,11 @@ void KoTextLayoutArea::paint(QPainter *painter, const \
KoTextDocumentLayout::Pain  }
         }
 
-        if (block.blockFormat().hasProperty(KoParagraphStyle::TableOfContentsDocument)) \
{ +        if (block.blockFormat().hasProperty(KoParagraphStyle::GeneratedDocument)) \
                {
             // Possibly paint the selection of the entire Table of Contents
             // but since it's a secondary document we need to create a fake \
                selection
-            QVariant data = \
                block.blockFormat().property(KoParagraphStyle::TableOfContentsDocument);
                
-            QTextDocument *tocDocument = data.value<QTextDocument *>();
+            QVariant data = \
block.blockFormat().property(KoParagraphStyle::GeneratedDocument); +            \
QTextDocument *generatedDocument = data.value<QTextDocument *>();  
             KoTextDocumentLayout::PaintContext tocContext = context;
             tocContext.textContext.selections = \
QVector<QAbstractTextDocumentLayout::Selection>(); @@ -147,17 +147,17 @@ void \
                KoTextLayoutArea::paint(QPainter *painter, const \
                KoTextDocumentLayout::Pain
             foreach(const QAbstractTextDocumentLayout::Selection & selection,   \
                context.textContext.selections) {
                 if (selection.cursor.selectionStart()  <= block.position()
                     && selection.cursor.selectionEnd() >= block.position()) {
-                    \
painter->fillRect(m_tableOfContentsAreas[tocIndex]->boundingRect(), \
selection.format.background()); +                    \
painter->fillRect(m_generatedDocAreas[tocIndex]->boundingRect(), \
selection.format.background());  if (pure) {
                         \
                tocContext.textContext.selections.append(QAbstractTextDocumentLayout::Selection());
                
-                        tocContext.textContext.selections[0].cursor = \
QTextCursor(tocDocument); +                        \
                tocContext.textContext.selections[0].cursor = \
                QTextCursor(generatedDocument);
                         \
tocContext.textContext.selections[0].cursor.movePosition(QTextCursor::End, \
                QTextCursor::KeepAnchor);
                         tocContext.textContext.selections[0].format = \
selection.format;  pure = false;
                     }
                 }
             }
-            m_tableOfContentsAreas[tocIndex]->paint(painter, tocContext);
+            m_generatedDocAreas[tocIndex]->paint(painter, tocContext);
             ++tocIndex;
             continue;
         }
diff --git a/plugins/textshape/ReferencesTool.cpp \
b/plugins/textshape/ReferencesTool.cpp index 0d33e88..b210a35 100644
--- a/plugins/textshape/ReferencesTool.cpp
+++ b/plugins/textshape/ReferencesTool.cpp
@@ -142,7 +142,7 @@ void ReferencesTool::formatTableOfContents()
     QTextBlock firstToCTextBlock;
     for (QTextBlock it = document->begin(); it != document->end(); it = it.next())
     {
-        if (it.blockFormat().hasProperty(KoParagraphStyle::TableOfContentsDocument)) \
{ +        if (it.blockFormat().hasProperty(KoParagraphStyle::TableOfContentsData)) {
             KoTableOfContentsGeneratorInfo *info = \
it.blockFormat().property(KoParagraphStyle::TableOfContentsData).value<KoTableOfContentsGeneratorInfo*>();
  if (i == 0) {
                 firstToCTextBlock = it;
diff --git a/plugins/textshape/dialogs/InsertBibliographyDialog.cpp \
b/plugins/textshape/dialogs/InsertBibliographyDialog.cpp index 30974ab..1d9c9f2 \
                100644
--- a/plugins/textshape/dialogs/InsertBibliographyDialog.cpp
+++ b/plugins/textshape/dialogs/InsertBibliographyDialog.cpp
@@ -46,7 +46,7 @@ void InsertBibliographyDialog::insert()
 {
     m_editor->insertBibliography();
     KoBibliographyInfo *bibInfo = \
m_editor->block().blockFormat().property(KoParagraphStyle::BibliographyData).value<KoBibliographyInfo*>();
                
-    QTextDocument *bibDocument = \
m_editor->block().blockFormat().property(KoParagraphStyle::BibliographyDocument).value<QTextDocument*>();
 +    QTextDocument *bibDocument = \
m_editor->block().blockFormat().property(KoParagraphStyle::GeneratedDocument).value<QTextDocument*>();
  
     bibInfo->m_entryTemplate = \
QMap<QString,BibliographyEntryTemplate>(m_bibInfo->m_entryTemplate);  \
                bibInfo->m_indexTitleTemplate.text = dialog.title->text();
diff --git a/plugins/textshape/dialogs/TableOfContentsPreview.cpp \
b/plugins/textshape/dialogs/TableOfContentsPreview.cpp index 366f568..7b0feaf 100644
--- a/plugins/textshape/dialogs/TableOfContentsPreview.cpp
+++ b/plugins/textshape/dialogs/TableOfContentsPreview.cpp
@@ -72,7 +72,7 @@ void \
TableOfContentsPreview::updatePreview(KoTableOfContentsGeneratorInfo *newTo  // \
info->m_useOutlineLevel = newToCInfo->m_useOutlineLevel;  
     tocFormat.setProperty(KoParagraphStyle::TableOfContentsData, \
                QVariant::fromValue<KoTableOfContentsGeneratorInfo*>(info) );
-    tocFormat.setProperty(KoParagraphStyle::TableOfContentsDocument, \
QVariant::fromValue<QTextDocument*>(tocDocument) ); +    \
tocFormat.setProperty(KoParagraphStyle::GeneratedDocument, \
QVariant::fromValue<QTextDocument*>(tocDocument) );  
     m_textShape = new TextShape(&m_itom);
     m_textShape->setSize(size());


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic