lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] do_compute_column_widths_if_necessary() [Was: Group-quote PDF: whi


From: Greg Chicares
Subject: [lmi] do_compute_column_widths_if_necessary() [Was: Group-quote PDF: whitespace changes, and enhancement]
Date: Sat, 21 Apr 2018 00:57:40 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0

On 2018-03-13 16:47, Vadim Zeitlin wrote:
[...]
>  Please let me know if there are any questions remaining,

Although we got distracted by other things, it's important to resume this
discussion now. To replace XSLT-FOP, we need to
 (1) make each column print properly
 (2) fit all columns in the available width
 (3) fit all lines on a page in the available height
and then do a comprehensive review of the textual contents. Here, let's
address (1), for which
  wx_table_generator::do_compute_column_widths_if_necessary()
is central.

To ensure that nothing previously discussed in mid-March gets lost, I've
copied and pasted the important parts from earlier email into the source.
We can remove these annotations as we resolve all the questions.

Let me present some further questions now, starting with a couple that
are incidental.

Elsewhere in 'wx_table_generator.cpp':

    wxDCFontChanger set_header_font(dc_);
    if(use_bold_headers_)
        {
        set_header_font.Set(get_header_font());
        }

I'm confused because
  set_header_font.Set(get_header_font());
sounds like a no-op:
  set_parameter(get_parameter());
How does that cause a bold font to be used?

Earlier, we had spoken of "PDF pixels"; what exactly are those? AIUI,
the basic PDF device-independent unit is a point = 1/72 inch; and
one pixel is one point at 72 DPI, e.g.; but what DPI does the wxPdfDoc
DC assume? I imagine it's hardcoded somewhere and doesn't depend on
screen resolution--so Kim's screen may be 96 DPI and mine, 192, but we
should generate identical PDFs.

I'm also not sure what the name do_compute_column_widths_if_necessary()
means--specifically the "if necessary" part. Is it unnecessary to call
this function at all in some contexts? Or OTOH is it always necessary
to call this function, but unnecessary to call it again after it has
been called once? (I'm guessing it's the latter, and that the flag
'has_column_widths_' just means that the function has been called once.)

Here:
    if(0 == i.width_)
        {
        num_expand++;
        }
do you really mean to compare width_ to zero, or did you intend
    if(i.is_variable_width_)
instead? AIUI, "variable-width" columns have width zero when constructed,
and 'is_variable_width_' captures that status. However, it seems that
width_ is increased to the width of the column header, before the snippet
above is reached, where I conjecture that (0 == i.width_) may never be true.

Why not remove "hidden" columns before formatting? This would simplify
the code in 'wx_table_generator.cpp', which explicitly skips hidden
columns in multiple places. AFAICT, we could just forbear to add hidden
columns where indicated below.

...in 'ledger_pdf_generator_wx.cpp':
            if(should_show_column(ledger, column++))
                {
                label = i.label;
                }
            //else: Leave the label empty to avoid showing the column.

            table.add_column(label, i.widest_text);

...in 'group_quote_pdf_gen_wx.cpp':
    if(!/* various conditions */)
        {
        // Leave the header empty to hide this column.
        break;
        }
    ...
    table_gen.add_column(header, cd.widest_text_);

The add_column() calls appear right after the only code that seems to
hide columns, so why call add_column() at all for hidden columns?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]