Opened 22 years ago

Closed 21 years ago

Last modified 21 years ago

#490 closed defect (fixed)

Confusing page settings

Reported by: zbian@… Owned by: Juergen Spitzmueller
Priority: high Milestone:
Component: frontend-xforms Version: 1.2.1
Severity: normal Keywords: patch VERIFIED
Cc: voss@…

Description

There is a problem with "Layout/Document/Paper" settings:
If I leave the headheight, headsep, footskip empty, I would assume they are
zero. But they are by default NOT! I do not know the default values.

If I put "0" in there, and generate the ps, the result is correct. But if I
revisit the dialog, the "0" is not displayed there any more!

If I open up the lyx file in a text editor, sometimes there is stuff like
"\headsep 0in". That's after I put "0" "unsucessfully" in the dialog!

Therefore, for empty fields, two different results may appear!

Suggestions for fix:

  1. Display the "0" when zero is specified.
  2. Display "Package/Latex default" when it is not specified.

Attachments (2)

bug490.diff (2.8 KB ) - added by Juergen Spitzmueller 21 years ago.
fix. parking it here since there's no feedback on lyx-devel
bug490-qt.diff (9.5 KB ) - added by Juergen Spitzmueller 21 years ago.
Fix qt too (probably won't apply to current cvs)

Download all attachments as: .zip

Change History (11)

comment:1 by levon, 22 years ago

Cc: voss@… added

Ping our resident latex expert ...

comment:2 by levon, 22 years ago

Severity: majornormal
Version: 1.2.01.2.1

From: juergen.sp@… (Juergen Spitzmueller)

This is a bug. It applies also to the custom margins. If the fields are empty,
then the default margins from geometry are used, which are not "0", but "0"
will be read in as empty field. So it's a rather grave bug.

AFAICS, the bug is in xforms_helpers.C (void updateWidgetsFromLength), line
155 (len.zero()):

if (len.zero()) {

fl_set_input(input, "");
fl_set_choice_text(choice, default_unit.c_str());

} else {

ostringstream buffer;
buffer << len.value();
fl_set_input(input, buffer.str().c_str());


Set the choice to the desired unit, if present in the choice.
Else set the choice to the default unit.
string const unit = subst(stringFromUnit(len.unit()),"%","%%");


vector<string> const vec = getVector(choice);
vector<string>::const_iterator it =

std::find(vec.begin(), vec.end(), unit);

if (it != vec.end()) {

fl_set_choice_text(choice, unit.c_str());

} else {

fl_set_choice_text(choice, default_unit.c_str());

}

}


Obviously, len.zero() does not make a difference between values with "0" and
empty values. This has to be changed. I'm shure it is easy, but I don't know
how. Any hints?

comment:3 by zbian@…, 22 years ago

I guess "empty value" is default to "0". It can be fixed by adding another
variable and function to that LyxLength class.

bool isDefault;
bool isDefault;

If we treat empty fields as defaults, this problem can be avoided. Since only
the default value displays as empty field. zero field is displayed as "0" with
arbitrary unit, in, cm, mm...

if (len.isDefault()) {

fl_set_input(input, "");
fl_set_choice_text(choice, default_unit.c_str());

} else {
.....
Display zero as "0"
....
}

Is this ok?

by Juergen Spitzmueller, 21 years ago

Attachment: bug490.diff added

fix. parking it here since there's no feedback on lyx-devel

by Juergen Spitzmueller, 21 years ago

Attachment: bug490-qt.diff added

Fix qt too (probably won't apply to current cvs)

comment:4 by levon, 21 years ago

Keywords: patch added
Owner: changed from leeming to Juergen Spitzmueller

comment:5 by voss, 21 years ago

Why is it not possible to have a behaviour like:

empty textfield -> nothing is passed to the inset

and vice versa. _Every_ other not empty textfield
is saved in the usual way. Means "0pt" too.

comment:6 by Juergen Spitzmueller, 21 years ago

Why is it not possible to have a behaviour like:
empty textfield -> nothing is passed to the inset

This is the case IMHO. The problem is that a missing lyxlength is interpreted as
"0pt" length by now. The null case is just not possible. You see this when you
load a document with no margin values into LyX: they appear as "0pt"-margins in
the doc dialog. My patch changes this.

and vice versa. _Every_ other not empty textfield
is saved in the usual way. Means "0pt" too.

And this happens now too. "0pt" is of course saved as "0pt", that does not change.

Maybe I miss something. Send a patch then please.

comment:7 by levon, 21 years ago

Your Qt patch is fine with me, with two changes :

1) don't start functions with uppercase letter
2) leave two empty lines between functions

Your other patch also seems fine to me. Update and send
them to lyx-devel again and I'll apply them (and I'll
take the heat if others whine)

Sorry for taking so long to get to this.

comment:8 by levon, 21 years ago

Resolution: fixed
Status: newclosed

fixed

comment:9 by michael.gerz@…, 21 years ago

Keywords: VERIFIED added

Verified.

Note: See TracTickets for help on using tickets.