Bug 44516 - label PRINTING misplaced in case of non-symmetrical label forms
Summary: label PRINTING misplaced in case of non-symmetrical label forms
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
(earliest affected)
3.4.4 release
Hardware: Other All
: medium normal
Assignee: Winfried Donkers
Whiteboard: target:3.6.0 target:3.5.3
: 47165 47316 (view as bug list)
Depends on: 36874
  Show dependency treegraph
Reported: 2012-01-05 22:23 UTC by Winfried Donkers
Modified: 2012-03-26 14:16 UTC (History)
6 users (show)

See Also:
Crash report or crash signature:

patch wihout UI-modification (so not yet complete) (1.14 MB, patch)
2012-01-29 07:04 UTC, Winfried Donkers
patch sofar, still dirty and not yet complete (1.19 MB, application/octet-stream)
2012-02-06 03:44 UTC, Winfried Donkers
screendump of modified label dialog (format tab) (30.55 KB, image/png)
2012-02-06 03:46 UTC, Winfried Donkers
patch improved label/BC wizard (1.19 MB, patch)
2012-02-08 22:59 UTC, Winfried Donkers
diff file of Labels.xcu - content changes only (237.52 KB, application/octet-stream)
2012-03-16 02:01 UTC, Winfried Donkers

Note You need to log in before you can comment on or make changes to this bug.
Description Winfried Donkers 2012-01-05 22:23:23 UTC
Bug 36874 solved the problem for 80% of the label forms (the most frequently used labels).
In the case of other 20% (mostly non-symmetrical label forms and label forms with one row or one column) the paper size cannot be calculated from the current label definition.
Therefore the label definition will be enhanced with paper size.
Also the UI of the Label Document wizard can be improved.
Comment 1 Winfried Donkers 2012-01-05 22:56:32 UTC
Initial summary of wishes for UI-improvement:
tab Dimensions):
-paper size should be shown; 
-horizontal and vertical distance are irrelevant and confusing for users with 1 column respectively row. These distance(s) should be disabled with 1 column or 1 row;
-graphic should ideally show label form with all labels on form. Explanation of the term (hor/vert distance, left/top margin, label width/heigth, paper width/height could perhaps be done bij coloured marking instead of dimension lines plus text (current situation).
Comment 2 Winfried Donkers 2012-01-11 07:52:29 UTC
status report:
Of all labels definitions in Labels.xcu (approx. 1400), more than 1150 are single sheet label forms and 235 are continuous forms. There are 240 label definitions of which the paper-format is yet to be checked/corrected, most of which are continuous forms.
Though slowly, the work progresses.
The git diff file is twice as large (1.2MB) as the Labels.xcu itself (0.55MB). I don't know what will be the best way to submit this...

On the coding side, the paper definitions in Labels.xcu are used when creating now label documents. This works well with lots of different labels.
The UI is waiting for the Labels.xcu to be completed.

Apart from the label document wizard, there is also a business card wizard, which uses (a lot of) the same code and the same label definitions. I still have to find the difference between the two, as I cannot change one without changing the other as well.
Comment 3 Winfried Donkers 2012-01-26 23:14:41 UTC
status report:
Labels.xcu has been converted. Some obsolete labels have been removed and the layout is now consistent in the whole file. I have also include a simple legend.

Some label definitions produce a distorted document (not all labels fit on the paper). This is caused by 2 factors:
-rounding errors in the MM100 to TWIP conversion can make that the last frame of a row or column does not fit on the page. I intend to reduce the label width/heigth with 1 TWIP if (leftmargin + ncols*labelwidth + (ncols-1)*hor.labelgap) respectively (uppermargin + nrows*labelheight + (nrows-1)*vert.labelgap) exceeds tha paper width repsectively height.
-an ancient fix(24446, pre 1996) sets borders with respect to unprintable areas on the paper. However, there are lots of labelforms that have labels from edge of paper to edge of paper, i.e. with part of the label in unprintable area. I intend to remove this piece of code.

Once this is done and tested, I want to proceed with the UI. The paper size must be visible and edit-able.
Comment 4 Winfried Donkers 2012-01-29 07:04:10 UTC
Created attachment 56292 [details]
patch wihout UI-modification (so not yet complete)

diff file contains the patch without the UI-modifications, which have to be done yet.
The patch works (still some cases to be tested), also when reading a old custom label definition (i.e. without paper width/height).
The problems described in bug 35104 and bug 41755 are solved.
The code from fix 24446 seems to have no effect on the document, neither positive, nor negative. I have not removed this code as the exact meaning is not completely clear to me.
Comment 5 Winfried Donkers 2012-02-06 03:44:51 UTC
Created attachment 56658 [details]
patch sofar, still dirty and not yet complete

The attached diff file seems to work for (almost) all LibreOffice labels, but there are still some special cases where the created document differs from the label form as it should be.
Comment 6 Winfried Donkers 2012-02-06 03:46:57 UTC
Created attachment 56660 [details]
screendump of modified label dialog (format tab)

I had to add two new texts (Page Width and Page Height) to the dialog.
I don't know how to handle the multi-lingual aspects of these two new texts.
Comment 7 Winfried Donkers 2012-02-08 22:59:41 UTC
Created attachment 56789 [details]
patch improved label/BC wizard

The patch.
Changes made:
-added page width and page height to label definitions, as the definitions were not complete (page size could not be determined from definitions). Removed some obsolete label definitions after consulting the manufacturer. Also added a legend (should anyone wish to add new current label defintions) and made layout consistent throughout the file (Labels.xcu);
-added page width and page size to label wizard and business card wizard and label dimension dialog (all files);
-added conversion of old-style custom label definitions (labelcfg.cxx);
-improved frame calculation - because of rounding off, situations were possible for the labels not to fit on the paper (e.g. 3 labels 70mm wide on a row of A4 paper (210mm wide)resulted in 3 frames of 3969TWIPs (totals 11907TWIPs) on a paper onlt 11906TWIPs wide (applab.cxx);
-improved frame space handling - the gaps between labels are right/lower spaces of the frame, so that frames can be put on the document next to each other when creating the document. However, when the gap between labels is larger than the right/lower margin of the page, the labels will not fit on the page. I removed the right space for the right colum of labels and the lower space for the bottom row of labels. I used 4 different drames for this as I could not make it work with one frame and changing left/lower space attribute. (applab.cxx);
-removed fix24445 as i could not determine any positive effect of this code (applab.cxx).
Comment 8 Jan Holesovsky 2012-02-13 13:45:39 UTC
Thank you for this, pushed :-)  You are the Labels maintainer, so I only basically checked that, and corrected few tabs to spaces, otherwise looked good to me, thank you!

Comment 9 Winfried Donkers 2012-02-14 23:55:24 UTC
committed patch does not behave as tested.
-gaps between labels seem not present when creating a new document.
Comment 10 Winfried Donkers 2012-02-20 02:33:28 UTC
fix for submitted patch submitted.
Attempt to rearrange some lines of code had resulted in unwanted behaviour...
Comment 11 Not Assigned 2012-02-20 09:19:34 UTC
Winfried Donkers committed a patch related to this issue.
It has been pushed to "master":


fdo#44516 final fix for labels with gaps larger than page margin
Comment 12 Christian Lohmaier 2012-02-20 13:22:20 UTC
chance to backport this for 3.5.x as well? 

Comment 13 Winfried Donkers 2012-02-20 23:00:24 UTC
Summary of changes made:
The changes have to do with the addition of page width and height to label definitions and with the creation of a writer document with frames representing labels or business cards.
-the majority of the changes (let's say 98%) regards the addition of members lPWidth and lPHeight to class SwLabItem. The label definition file (Labels.xcu) has had all labels changed and various cxx files have the member added for assigning values to class instances; There is one special case in labelcfg.cxx (lines 120-126) which addresses the possibility that a non-converted (no page width/height defined) is read.
-the page width/height is also shown in the dialog, straightforward code including setting minimum and maximum values that can be entered.
-There are cases where the summed width of the frames exceeds the page width (same for height). Example: an A4 sheet with 3 labels 70mm wide produces a frame width of 3969 twips (total width 3 x 3969 = 11907) whereas the page is only 11906twips wide. In applab.cxx, iResultWidth, iResultHeight, iWidth, iHeight compensate for this.
-Finally there is the case where the horizontal gap between labels is larger than the right margin (same for height). The document is created with frames that have right and lower spaces representing the horizontal/vertical gap. The last frame of the column/row will not fit on the row/column if the right/lower page margin is not big enough. To solve that, I use different frames for the right column and for the bottom row. (applab.cxx, pFmtOERow, pFmtEOCol, pFmtEOColEORow).
Comment 14 Christian Lohmaier 2012-03-15 07:32:17 UTC
*** Bug 47316 has been marked as a duplicate of this bug. ***
Comment 15 Winfried Donkers 2012-03-16 02:01:53 UTC
Created attachment 58543 [details]
diff file of Labels.xcu - content changes only

To simplify reviewing the patch for pushing it to 3.5 branch,

I have done some editing with vi on both the 'old' and the 'new' Labels.xcu:
-remove all leading spaces (:%s/ \{1,\}//g); 
-insert linefeed between '><' (:%s/></>\r</g); 
-remove empty lines (:%s/\n\{2,\}/\r/g)

I made a diff file (diff -a -b), which now shows only changes in contents.
Comment 16 Winfried Donkers 2012-03-16 02:10:19 UTC
(In reply to comment #15)
> -remove all leading spaces (:%s/ \{1,\}//g); 

should have been:
 -remove all leading spaces (:%s/ \{1,\}<//g); 
(only spaces before any xml-labels, not spaces in text)
This was typing error in the comment, not in the editing.
Comment 17 Not Assigned 2012-03-22 20:16:55 UTC
Winfried Donkers committed a patch related to this issue.
It has been pushed to "libreoffice-3-5":


fdo#44516: Improved label/BC wizard - set paper size

It will be available in LibreOffice 3.5.3.
Comment 18 Cor Nouws 2012-03-26 14:16:51 UTC
*** Bug 47165 has been marked as a duplicate of this bug. ***