Re: [fpc-pascal] FPReport: Split text across two or more pages

2024-01-03 Thread Michael Van Canneyt via fpc-pascal




On Tue, 2 Jan 2024, Pique7 via fpc-pascal wrote:


On Tue, 2 Jan 2024 00:02:35 +0100 (CET)
Michael Van Canneyt via fpc-pascal  wrote:




On Mon, 1 Jan 2024, Pique7 via fpc-pascal wrote:


Hello everyone,

I have already asked this and related questions in the Lazarus Forum.

I want to improve FPReport in order to use it for my project - if possible.
Some features are missing for this, e.g. automatic splitting of text across two 
or more pages.

As far as I can judge, the current development status of FPReport does not 
really allow me to extend it without modifying the original classes.


Why do you think so ?


Thanks for your reply.  I am not sure whether I have defined the problem
correctly from my point of view.  I have tried both FPReport and
LazReport.  LazReport is able to create page breaks within a band
automatically (though not always correctly calculated).  This is traceable
by viewing the source code of LazReport.  I haven't found anything similar
in the source code of FPReport and thus considered to implement it myself. 
But I haven't found a straightforward solution.


There is no straightforward solution if you wish to break a memo.

The layouter is not equipped for splitting bands.


What approach do you suggest? Would this be feasible/reasonable at all? I ask 
this because I am new to Lazarus and FPC. I come from Delphi 2007 ...


If you ask me, it's perfectly doable without any changes.

There is a demo that shows how to print a text by splitting it in lines, and
simply printing a band per line. That will have the same effect as what you
seem to need.  Basically, it means using a TStringList as a data source
for a (sub)band instead of using it as the text of a single memo.


Unfortunately I couldn't find the demo program you mention.  I know the
fcl demos in "source\packages\fcl-report\demos".  Admittedly I haven't
examined every single unit yet.  Most of the demo reports get the data
from a TStringList.  Is it this what is meant?


Yes. Normally you'll be using a dataset-based "data loop" (TFPReportData).

But the data loop can be an event-based loop, which uses a TStringList to
define the items in the loop. (an instance of TFPReportUserData is used for 
this)


What you may need to do is to split the text "correctly" over the lines of the
TStringList, but that should be easily doable. All you need is a function to
calculate the length of the text.

I think this is perfectly doable without any changes to the original code.


Okay, probably you're right and I think I understand the basic idea but I
still don't know how to transfer it to my case.  I have a table with
several columns containing multiline text.  The data comes from a TDataSet
descendent.  If one the cells (Memo) content is to large to fit on the
current page, the whole band should be split at the correct position and
continued on the next page, e.g.:

   [PAGE 1 - DATABAND 1 (bottom of page)]
   COL 1-1  COL 2-1
   COL 1-2  COL 2-2
   COL 1-3  COL 2-3

   [PAGE 2 - DATABAND 1 (continued)]
   COL 1-4  COL 2-4
   COL 1-5

I also have one report with one column containing richtext (RTF).  I doubt
that the TStringList solution will be helpful in this case.


If RTF is a requirement, in that case you can desist your efforts: 
RTF is not supported in FPReport. A limited subset of html is.


I don't know if RTF is supported in lazreport. Maybe on windows it is.

FPC comes with an RTF parser, but it would require a large amount of work to
integrate that in FPReport. RTF is a huge subject. 
It would be a nice addition, no doubt.




So in a nutshell, I think I need a function like "Continue (data) band on
the next page if remaining space is insufficient".


At the moment, I don't see how to create this function. 
IMO It would require a major rewrite of the layouter to introduce this.



 If you still think
your suggested approach is suitable, please let me know.  Maybe it is
obvious, but at the moment it seems that I don't make any progress.


Disregarding the RTF for a moment, you'd need to save the contents of the
text fields in a TStringlist instance in the 'afterscroll' event of the dataset.

This instance can then be used to create a data loop for a sub band
(using TFPReportUserData).
The band connected to the dataset (the master band) would not print anything. 
Instead, the child band will print the cell content line by line and split it over pages.



From your drawing, it is not quite clear how you construct your columns,

if you're using columns, I'm not sure how the band will behave.

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Profiling in windows

2024-01-03 Thread James Richters via fpc-pascal
I have a freepascal project for Windows that works really well, but as soon
as I start it, I have high CPU usage, and it stays high, it constantly uses
10% CPU 
while my program is running, even when it's idle waiting for me to make a
selection from its menu.  
 
The main program loop does a few minor things like update the time on the
screen, checks some timers, checks for a keypress, then sleeps until it's
time to do the loop again.
I'm wondering if its getting stuck in some inefficient routine that's
causing all this processor activity.
 
This program only runs under Windows so I'm trying to get a profiler to work
with a windows program.  I came across FPProfiler:
https://wiki.freepascal.org/FPProfiler
 
I'm trying to figure out how it's supposed to work but I haven't made it
very far.  The instructions say to use Lazarus to build the following:
 
.\fpp\fpp.lpi
.\fpp\fppinsert.lpi
.\fpp\fppremove.lpi
.\fppview\fppview.lpi
 
But only .\fpp\fpp.lpi and .\fppview\fppview.lpi  exist, so I compiled those
with Lazarus.
 
I am using the repository at:
http://github.com/graemeg/fpprofiler
 
The svn link doesn't work for me:
http://svn.freepascal.org/cgi-bin/viewvc.cgi/fpprofiler/?root=fpcprojects
 
Also, the instructions say," to compile your project, you pass the same
parameters to FPP as you would to FPC."
I don't use FPC from the command line, I use the FPC textmode IDE. Which I
have set up the way I like it years ago.
Is there some way to know what parameters the text mode IDE is using?  Or
What would the command line be to compile the same way as the IDE?
 
Any advice on how to get this to work, or recommendations on another way I
can profile my program under Windows is greatly appreciated.
 
James
 
 
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal