tdf#150104 Store full printer/driver name in doc's JobSetup
commit11cd74ade59c6b47b25a737775a541fdd6faed44
authorMichael Weghorn <m.weghorn@posteo.de>
Tue, 26 Jul 2022 11:53:17 +0000 (26 13:53 +0200)
committerMichael Weghorn <m.weghorn@posteo.de>
Tue, 26 Jul 2022 20:37:58 +0000 (26 22:37 +0200)
tree9d557f6bb7003b406ff808c6a2ded90d99d6ed9c
parent59cfcd863b483a99491e6f8cd30016386bbff870
tdf#150104 Store full printer/driver name in doc's JobSetup

Printer and driver name have a limited length (64 chars for
the printer name, 32 for the driver name) in the
`ImplOldJobSetupData` struct that is part of what gets
serialized into the "PrinterSetup" config item in
settings.xml when saving printer settings to the document
(s. `WriteJobSetup`). Longer printer and driver names
get truncated, and only the truncated name got restored.

At least for Windows, this scenario would result in the
doc printer settings not getting restored properly,
because `ImplTestSalJobSetup` (in vcl/win/gdi/salprn.cxx)
among others checks that both printer and driver name
match, which isn't the case when one version is truncated.

ODF spec, version 1.3, section 3.1.3.5 says this on settings.xml:

> 3.1.3.5 <office:document-settings>
> The <office:document-settings> root element contains
> implementation-dependent settings. The file within a
> package for the <office:document-settings> element is
> settings.xml.

Since the settings are implementation-dependent,
changing the exact format and content of
the data in "PrinterSetup" is unproblematic,
as long as compatibility with older application versions
is maintained.

Luckily, there is already a way to save variable-length
key-value pairs with `JOBSET_FILE605_SYSTEM`,
added in

    commit 4bd178f6ee60f641b2a6c7fcc9f6e4b6dd01df27
    Date:   Fri Sep 22 11:55:00 2000 +0000

        new feature in JobSetup: additional parameters

Make use of this to save the full printer and
driver name using the "PRINTER_NAME" and "DRIVER_NAME"
keys and restore the values from those if present.

For compatibility with older versions, the (potentially
truncated) values are still written and also used as
fallback on document open.

Change-Id: I55bed58023fa7a078525add79b13f2310aa9a9dd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137454
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
vcl/source/gdi/jobset.cxx