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

List:       koffice-devel
Subject:    Review request: Reports: Fix pageTotal() and post processing in
From:       Dag Andersen <danders () get2net ! dk>
Date:       2010-12-04 14:43:25
Message-ID: 201012041543.25202.danders () get2net ! dk
[Download RAW message or body]

Post processing of fields is not done (regression) so total number of pages 
cannot be displayed in reports.
Reviewd and ok'ed by Adam.

Note: The coding style of the patched files is followed.
-- 
Mvh.
Dag Andersen

["postprocess.diff" (text/x-patch)]

Index: items/field/KoReportItemField.cpp
===================================================================
--- items/field/KoReportItemField.cpp	(revision 1202520)
+++ items/field/KoReportItemField.cpp	(working copy)
@@ -219,9 +219,12 @@
     }
     
     tb->setText(str);
-    if (page)
+    if (page) {
         page->addPrimitive(tb);
-
+        if (tb->requiresPostProcessing()) {
+            page->addNeedsPostProcessing(tb);
+        }
+    }
     if (section) {
         OROPrimitive *clone = tb->clone();
         clone->setPosition(m_pos.toScene());
Index: renderer/KoReportPreRenderer.cpp
===================================================================
--- renderer/KoReportPreRenderer.cpp	(revision 1202520)
+++ renderer/KoReportPreRenderer.cpp	(working copy)
@@ -65,7 +65,6 @@
     int m_recordCount;
 
     KoReportData* m_kodata;
-    QList<OROTextBox*> m_postProcText;
 
     void createNewPage();
     qreal finishCurPage(bool = false);
@@ -105,8 +104,6 @@
         delete m_reportData;
         m_reportData = 0;
     }
-
-    m_postProcText.clear();
 }
 
 void KoReportPreRendererPrivate::createNewPage()
@@ -399,17 +396,7 @@
         
         if (itemHeight > sectionHeight) {
             sectionHeight = itemHeight;
-        }
-        
-#if 0 //!TODO Handle post processing of text data
-        if (ob->type() == OROTextBox::TextBox) {
-            OROTextBox *text = dynamic_cast<OROTextBox*>(ob);
-            if (text->requiresPostProcessing()) {
-                m_postProcText.append(text);
-            }
-
-#endif
- 
+        } 
     }
 
     m_yOffset += sectionHeight;
@@ -614,16 +601,17 @@
     }
     d->finishCurPage(true);
 
-    // _postProcText contains those text boxes that need to be updated
+    // post process primitives that need to be updated
     // with information that wasn't available at the time it was added to the document
     d->m_scriptHandler->setPageTotal(d->m_document->pages());
 
-    for (int i = 0; i < d->m_postProcText.size(); i++) {
-        OROTextBox * tb = d->m_postProcText.at(i);
-
-        d->m_scriptHandler->setPageNumber(tb->page()->page() + 1);
-
-        tb->setText(d->m_scriptHandler->evaluate(tb->text()).toString());
+    foreach (OROPrimitive *p, d->m_document->needsPostProcessing()) {
+        if (p->type() == OROTextBox::TextBox) {
+            // only handles textbox primitives atm
+            OROTextBox *tb = static_cast<OROTextBox*>(p);
+            d->m_scriptHandler->setPageNumber(tb->page()->page() + 1);
+            tb->setText(d->m_scriptHandler->evaluate(tb->text()).toString());
+        }
     }
 
     d->m_scriptHandler->displayErrors();
@@ -631,7 +619,6 @@
     d->m_kodata->close();
     delete d->m_scriptHandler;
     delete d->m_kodata;
-    d->m_postProcText.clear();
 
     ORODocument * pDoc = d->m_document;
     d->m_document = 0;
Index: common/renderobjects.h
===================================================================
--- common/renderobjects.h	(revision 1202520)
+++ common/renderobjects.h	(working copy)
@@ -76,11 +76,16 @@
         return m_pageOptions;
     };
 
+    QList<OROPrimitive*> needsPostProcessing() const;
+    void addNeedsPostProcessing(OROPrimitive *primitive);
+
 protected:
     QString m_title;
     QList<OROPage*> m_pages;
     QList<OROSection*> m_sections;
     ReportPageOptions m_pageOptions;
+
+    QList<OROPrimitive*> m_needsPostProcessing;
 };
 
 //
@@ -109,6 +114,8 @@
     OROPrimitive* primitive(int);
     void addPrimitive(OROPrimitive*, bool = false);
 
+    void addNeedsPostProcessing(OROPrimitive *primitive);
+
 protected:
     ORODocument * m_document;
     QList<OROPrimitive*> m_primitives;
Index: common/renderobjects.cpp
===================================================================
--- common/renderobjects.cpp	(revision 1202520)
+++ common/renderobjects.cpp	(working copy)
@@ -78,6 +78,16 @@
     m_pageOptions = options;
 }
 
+QList<OROPrimitive*> ORODocument::needsPostProcessing() const
+{
+    return m_needsPostProcessing;
+}
+
+void ORODocument::addNeedsPostProcessing(OROPrimitive *primitive)
+{
+    m_needsPostProcessing.append(primitive);
+}
+
 //
 // OROPage
 //
@@ -132,6 +142,13 @@
     }
 }
 
+void OROPage::addNeedsPostProcessing(OROPrimitive *primitive)
+{
+    if (m_document) {
+        m_document->addNeedsPostProcessing(primitive);
+    }
+}
+
 //
 // OROSection
 //


_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


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

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