dabo Commit
Revision 6567
Date: 2011-04-18 09:22:37 -0700 (Mon, 18 Apr 2011)
Author: Paul
Trac: http://trac.dabodev.com/changeset/6567
Changed:
U trunk/dabo/lib/reportWriter.py
U trunk/ide/ReportDesigner.py
Log:
Offer to convert paragraphs to memos when opening a report form in the designer.
Diff:
Modified: trunk/dabo/lib/reportWriter.py
===================================================================
--- trunk/dabo/lib/reportWriter.py 2011-04-15 23:34:02 UTC (rev 6566)
+++ trunk/dabo/lib/reportWriter.py 2011-04-18 16:22:37 UTC (rev 6567)
@@ -1224,6 +1224,49 @@
if self.PrintStatus:
print "Report End."
+
+ def getFramesetCount(self):
+ """Returns the number of framesets in the report."""
+ print self.getFramesets()
+ return len(self.getFramesets())
+
+
+ def getFramesets(self):
+ """Returns a list of (idx, frameset, band) for every frameset
in the report.
+
+ idx is the position in the Objects list for whatever band the
+ frameset is part of.
+ """
+ bands = [b for b in self.Bands if "group" not in b.lower()]
+ bandObjs = []
+ framesets = []
+ for g in self.ReportForm["Groups"]:
+ for b in (g["groupheader"], g["groupfooter"]):
+ bandObjs.append(b)
+ for b in bands:
+ band = self.ReportForm[b]
+ bandObjs.append(band)
+ for b in bandObjs:
+ framesets += [(idx,f,b) for (idx,f) in
enumerate(b["Objects"]) if type(f) == Frameset]
+ return framesets
+
+
+ def convertParagraphsToMemos(self):
+ """Converts all Paragraph objects to Memo objects."""
+ framesets = self.getFramesets()
+ for idx_f_b in framesets:
+ idx, f, b = idx_f_b
+ m = Memo(b)
+ p = f["Objects"][0]
+ for k, v in p.items():
+ m[k] = v
+ for k, v in f.items():
+ if k.lower() not in ("objects",):
+ m[k] = v
+ f.parent[idx] = m
+
+
+
def storeSpanningObject(self, obj, origin=(0,0), group=None):
"""Store the passed spanning object for printing when the group
or
page ends. Pass the group expr to identify group headers, or
None to refer
Modified: trunk/ide/ReportDesigner.py
===================================================================
--- trunk/ide/ReportDesigner.py 2011-04-15 23:34:02 UTC (rev 6566)
+++ trunk/ide/ReportDesigner.py 2011-04-18 16:22:37 UTC (rev 6567)
@@ -2051,6 +2051,15 @@
self._fileName = fileSpec
rdc.ActiveEditor = self
rdc.SelectedObjects = [self._rw.ReportForm]
+ frameset_count = rdc.ReportForm.getFramesetCount()
+ if frameset_count == 1:
+ fs_text = "Frameset"
+ else:
+ fs_text = "%s Framesets" % frameset_count
+ if frameset_count > 0 and dabo.ui.areYouSure("Would you
like to convert the %s"
+ " on this report to the new Memo
object?" % fs_text,
+ cancelButton=False):
+ rdc.ReportForm.convertParagraphsToMemos()
else:
raise ValueError("File %s does not exist." % fileSpec)
return True
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message:
http://leafe.com/archives/byMID/[email protected]