[Gambas-devel] RFC: component LATEX2

Tobias Boege tobias at ...692...
Fri Aug 23 13:38:59 CEST 2013


On Thu, 22 Aug 2013, Julio Sanchez wrote:
> Hello, my name is Julio Sanchez Berro (jsbsan alia), I attached a
> component that
> I made to create reports. Generates both TEX files (latex) and PDF.
> 
> You can create reports RTF and ODT, gridviews content of queries and
> databases, which can be modified by libreoffice, for example.
> 
> For if it considers, is added in future version gambas3.
> 
> Here you are download links and a short video so you can see what you can
> get with component latex2
> 
> Download:
>      component: https://app.box.com/s/8x4a1k2bjw75cknulmzy
>      test: https://app.box.com/s/mydi385uslwlkxg1v697
> 
> VideoTutorial:
>      http://youtu.be/6fWUFGOT-tQ
> 
> I have two questions:
> 1) When I create a program that makes use of the new component, to create
> the installation package. DEB siquiente get the error:
> https://app.box.com/s/mg75jawunxftlvgsoy8p
> 
> 2) Latex component classes, methods are discussed, to help the user.
> Leaving the
> aid when used. But when added to a new project, that helps not appear:
> https://app.box.com/s/phm89rjjng14pt24gmo9
> https://app.box.com/s/lh5pj2oens064baoezt7
> 
> 
> Best Regards
> 
> Note:
> Forgive my English, but not much and helps me google translate

My comments focus on the LaTeX part mainly as I don't know much about .odt
and don't care about .rtf ;-)

Nice idea. However, there are three things I don't like:

1) The component is only marginally object-oriented, like Fabien already
   pointed out. I mean, the idea to let the user programmatically construct
   a LaTeX document is a pretty good one but you should keep track of the
   document structure and then be able to modify it (to some extent)
   afterwards.
2) You depend on pandoc for the conversions and some LaTeX packages which
   people may not have installed. The least duty you have is to say what
   LaTeX packages one needs. (And man, I just checked out pandoc and it's
   1 GiB when installed under Arch Linux on my machine. Is it worth the
   effort to just create .odt and .rtf? Can't you just export the .tex and
   let the user, if he so desires, convert .tex to .odt or .rtf?)
3) You cannot just save shell scripts under /tmp and execute them. This is a
   security risk (depending on your users' umask). Even though, you Chmod
   them correctly, there is still a race condition involved.

Oh, and I need to say that I didn't understand most of the code because your
naming is spanish (I think). I don't know what most variables signify. While
I'm at naming, don't prepend "Class" before a class name. I.e. you name a
class "_ClassBox.class" but from the file extension, it is already clear
that it is a class, so just name it "_Box" or "_LatexBox" if you fear name
conflicts.

Not to say that the interface needs polishing. Just look at
_ClassBox:MessageBox(). Its 'itype' parameter needs symbolic constants. The
user likes to give

box.MessageBox("some text", box.Oval)

instead of

box.MessageBox("some text", 3)

And the symbols need to follow the Pascal naming convention.

Also some random things I encountered:
- Don't include spanish comments (or comments at all) in the documents your
  component generates (Latex:InitDoc()).
- I don't think functions like Latex:QueryResultTableDB() or
  Latex:TableGridViews() really belong to the LaTeX class. They just make
  your component depend on gb.db and gb.form for some very special tasks.
  latex2 should be usable without databases and a graphical system. So
  instead, take the code out of there and write an example project to show
  how it could be done.
- _ClassVerbatin is clearly mis-named with the "n" at the end. The
  corresponding variable in _ClassEnvironment is also mis-named.
- Not everyone has "evince" installed (LatexHelper:compilePDF()). Just don't
  launch PDF viewers from a component.
- Returning an error string where a file name would be expected is not a
  sane way of reporting errors (again in LatexHelper:compilePDF() and some
  others). Your error message could equivalently well be file names. You'll
  have to use Error.Raise().

IMHO, the component also lacks some generic functions like

Latex.BeginEnvironment(sEnv As String, ...)

where you would then write

\begin{sEnv}[...]

Use the Param class to access the variable argument list.

I hope this isn't too much or too unordered.

Regards,
Tobi





More information about the Devel mailing list