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

List:       kde-commits
Subject:    koffice/kexi/plugins/reportspgz/backend
From:       Adam Pigg <adam () piggz ! co ! uk>
Date:       2008-06-21 21:57:54
Message-ID: 1214085474.377588.30438.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 822897 by piggz:

Move entity position to the KRObjectData class;
Allow primitives in an OROSection to be sorted based on X value
Implement the table type export

 M  +0 -1      common/krbarcodedata.h  
 M  +0 -2      common/krchartdata.h  
 M  +0 -3      common/krfielddata.h  
 M  +0 -1      common/krimagedata.h  
 M  +0 -1      common/krlabeldata.h  
 M  +6 -2      common/krobjectdata.h  
 M  +5 -0      common/krsectiondata.cpp  
 M  +1 -0      common/krsectiondata.h  
 M  +0 -1      common/krshapedata.h  
 M  +1 -1      common/krtextdata.h  
 M  +75 -2     renderer/krhtmlrender.cpp  
 M  +3 -0      renderer/krhtmlrender.h  
 M  +0 -3      renderer/orprintrender.cpp  
 M  +14 -0     renderer/renderobjects.cpp  
 M  +12 -0     renderer/renderobjects.h  


--- trunk/koffice/kexi/plugins/reportspgz/backend/common/krbarcodedata.h \
#822896:822897 @@ -55,7 +55,6 @@
 
 	protected:
 		QRect _rect();
-		KRPos _pos;
 		KRSize _size;	
 		
 		KoProperty::Property * _controlSource;
--- trunk/koffice/kexi/plugins/reportspgz/backend/common/krchartdata.h #822896:822897
@@ -55,8 +55,6 @@
 		void populateData();
 		void setConnection(KexiDB::Connection*);
 	protected:
-		
-		KRPos _pos;
 		KRSize _size;	
 		KoProperty::Property * _dataSource;
 		KoProperty::Property * _font;
--- trunk/koffice/kexi/plugins/reportspgz/backend/common/krfielddata.h #822896:822897
@@ -23,7 +23,6 @@
 #include <QRect>
 #include <qdom.h>
 #include "krsize.h"
-#include "krpos.h"
 #include <parsexmlutils.h>
 /**
 	@author 
@@ -61,12 +60,10 @@
 		//QString trackTotalFormat();
 		
 		ORLineStyleData lineStyle();
-		KRPos position(){return _pos;}
 		ORTextStyleData textStyle();
 	protected:
 		
 		QRect _rect;
-		KRPos _pos;
 		KRSize _size;	
 		KoProperty::Property * _controlSource;
 		KoProperty::Property * _hAlignment;
--- trunk/koffice/kexi/plugins/reportspgz/backend/common/krimagedata.h #822896:822897
@@ -62,7 +62,6 @@
 		ORDataData data() {return ORDataData("Data Source", \
_controlSource->value().toString());}  protected:
 		QRect _rect();
-		KRPos _pos;
 		KRSize _size;
 		KoProperty::Property * _controlSource;
 		KoProperty::Property* _resizeMode;
--- trunk/koffice/kexi/plugins/reportspgz/backend/common/krlabeldata.h #822896:822897
@@ -55,7 +55,6 @@
 	protected:
 		QRectF _rect();
 				
-		KRPos _pos;
 		KRSize _size;
 		KoProperty::Property *_text;
 		KoProperty::Property* _hAlignment;
--- trunk/koffice/kexi/plugins/reportspgz/backend/common/krobjectdata.h \
#822896:822897 @@ -20,6 +20,8 @@
 #ifndef KROBJECTDATA_H
 #define KROBJECTDATA_H
 #include <koproperty/property.h>
+#include "krpos.h"
+
 class KRLineData;
 class KRLabelData;
 class KRFieldData;
@@ -69,12 +71,14 @@
 		virtual void createProperties() =0;
 		
 		qreal Z;
-		
+		KRPos position(){return _pos;}
+
 		QString entityName(){return _name->value().toString();}
 	protected:
 		KoProperty::Set *_set;
 		KoProperty::Property *_name;
-		
+		KRPos _pos;
+
 		QString _oldName;
 		
 };
--- trunk/koffice/kexi/plugins/reportspgz/backend/common/krsectiondata.cpp \
#822896:822897 @@ -199,6 +199,11 @@
 	return s1->Z < s2->Z;
 }
 
+bool KRSectionData::xLessThan ( KRObjectData* s1, KRObjectData* s2 )
+{
+  return s1->position().toPoint().x() < s2->position().toPoint().x();
+}
+
 void KRSectionData::createProperties()
 {
 	_set = new KoProperty::Set ( 0, "Section" );
--- trunk/koffice/kexi/plugins/reportspgz/backend/common/krsectiondata.h \
#822896:822897 @@ -107,6 +107,7 @@
 		Section _type;
 		
 		static bool zLessThan(KRObjectData* s1, KRObjectData* s2);
+		static bool xLessThan(KRObjectData* s1, KRObjectData* s2);
 		
 		bool _valid;
 		
--- trunk/koffice/kexi/plugins/reportspgz/backend/common/krshapedata.h #822896:822897
@@ -47,7 +47,6 @@
 	protected:
 		QRectF _rect();
 				
-		KRPos _pos;
 		KRSize _size;
 		KoProperty::Property *_shapeType;
 
--- trunk/koffice/kexi/plugins/reportspgz/backend/common/krtextdata.h #822896:822897
@@ -57,7 +57,7 @@
 		
 	protected:
 		QRect _rect();
-		KRPos _pos;
+
 		KRSize _size;
 		KoProperty::Property * _controlSource;
 		KoProperty::Property* _hAlignment;
--- trunk/koffice/kexi/plugins/reportspgz/backend/renderer/krhtmlrender.cpp \
#822896:822897 @@ -40,6 +40,14 @@
 
 QString KRHtmlRender::render(ORODocument *document, bool css)
 {
+  if (css)
+    return renderCSS(document);
+  else
+    return renderTable(document);
+}
+
+QString KRHtmlRender::renderCSS(ORODocument *document)
+{
 	QString html;
 	QString body;
 	QString style;
@@ -118,14 +126,79 @@
 	html = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \
\"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n";  html += "<style \
type=\"text/css\">";  
-	for (unsigned int i = 0; i < styles.count(); ++i)
+	for (int i = 0; i < styles.count(); ++i)
 	{
 		html += ".style" + QString::number(i) + "{" + styles[i] + "}\n";
 	}
 	
-	html += "</style></head><body>";
+	html += "</style>";
+	html += "<title>" + document->title() + "</title>";
+	html += "<meta name=\"generator\" content=\"Kexi - Kickass open source data \
management\">"; +	html += "</head><body>";
 	html += body;
 	html += "</body></html>";
 
 	return html;
 }
+
+QString KRHtmlRender::renderTable(ORODocument *document)
+{
+	QString html;
+	QString body;
+
+	bool renderedPageHead = false;
+	bool renderedPageFoot = false;
+	// Render Each Section
+
+	body = "<table>\n";
+	for (long s = 0; s < document->sections(); s++ )
+	{
+		OROSection *section = document->section(s);
+		section->sortPrimatives(OROSection::SortX);
+
+		if (section->type() == KRSectionData::GroupHead || 
+			section->type() == KRSectionData::GroupFoot || 
+			section->type() == KRSectionData::Detail || 
+			section->type() == KRSectionData::ReportHead || 
+			section->type() == KRSectionData::ReportFoot || 
+			(section->type() == KRSectionData::PageHeadAny && !renderedPageHead) || 
+			(section->type() == KRSectionData::PageFootAny && !renderedPageFoot && s > \
document->sections() - 2 )) //render the page foot right at the end, it will either \
be the last or second last section if there is a report footer +		{
+			if ( section->type() == KRSectionData::PageHeadAny )
+			  renderedPageHead = true;
+
+			if ( section->type() == KRSectionData::PageFootAny )
+			  renderedPageFoot = true;
+
+			body += "<tr style=\"background-color: " + section->backgroundColor().name() + \
"\">\n"; +			//Render the objects in each section
+			for ( int i = 0; i < section->primitives(); i++ )
+			{
+				OROPrimitive * prim = section->primitive ( i );
+				
+				if ( prim->type() == OROTextBox::TextBox )
+				{
+					OROTextBox * tb = ( OROTextBox* ) prim;
+					
+					body += "<td>";
+					body += tb->text();
+					body += "</td>\n";
+				}
+				else
+				{
+					kDebug() << "unrecognized primitive type" << endl;
+				}
+			}
+			body += "</tr>\n";
+		}
+	}
+	body += "</table>\n";
+	html = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \
\"http://www.w3.org/TR/html4/strict.dtd\">\n<html>\n<head>\n"; +	html += "<title>" + \
document->title() + "</title>"; +	html += "<meta name=\"generator\" content=\"Kexi - \
Kickass open source data management\">"; +	html += "</head><body>";
+	html += body;
+	html += "</body></html>";
+
+	return html;
+}
\ No newline at end of file
--- trunk/koffice/kexi/plugins/reportspgz/backend/renderer/krhtmlrender.h \
#822896:822897 @@ -42,6 +42,9 @@
 
     QString render(ORODocument *, bool=true);
     
+    private:
+      QString renderCSS(ORODocument*);
+      QString renderTable(ORODocument*);
 };
 
 
--- trunk/koffice/kexi/plugins/reportspgz/backend/renderer/orprintrender.cpp \
#822896:822897 @@ -87,9 +87,6 @@
 			return false;
 	}
 
-	qreal xDpi = _printer->logicalDpiX();
-	qreal yDpi = _printer->logicalDpiY();
-
 	int fromPage = _printer->fromPage();
 	if ( fromPage > 0 )
 		fromPage -= 1;
--- trunk/koffice/kexi/plugins/reportspgz/backend/renderer/renderobjects.cpp \
#822896:822897 @@ -204,6 +204,20 @@
 {
   return _backgroundColor;
 }
+
+void OROSection::sortPrimatives(Sort s)
+{
+    if (s == SortX)
+    {
+      qSort(_primitives.begin(), _primitives.end(), xLessThan);
+    }
+}
+
+bool OROSection::xLessThan(OROPrimitive* s1, OROPrimitive* s2)
+{
+  return s1->position().x() < s2->position().x();
+}
+
 //
 // OROPrimitive
 //
--- trunk/koffice/kexi/plugins/reportspgz/backend/renderer/renderobjects.h \
#822896:822897 @@ -112,6 +112,13 @@
   friend class OROPrimitive;
   
   public:
+    enum Sort
+    {
+      SortX = 1,
+      SortY,
+      SortZ
+    };
+    
     OROSection(ORODocument * = 0);
     virtual ~OROSection();
     
@@ -131,6 +138,7 @@
     OROPrimitive* primitive(int);
     void addPrimitive(OROPrimitive*);
     
+    void sortPrimatives(Sort);
   protected:
     ORODocument * _document;
     QList<OROPrimitive*> _primitives;
@@ -138,6 +146,10 @@
     int _height;
     KRSectionData::Section _type;
     QColor _backgroundColor;
+    
+  private:
+  
+    static bool xLessThan(OROPrimitive* s1, OROPrimitive* s2);
 };
 
 


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

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