weld PrintDialog

Change-Id: Id4adbe484f88be74f45dab8e7ef426c66e5cbc8b
Reviewed-on: https://gerrit.libreoffice.org/80002
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index 7bd0c3f..be90276 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -131,12 +131,6 @@
    <glade-widget-class title="Table Preview" name="swuilo-AutoFmtPreview"
                        generic-name="Table Preview Window" parent="GtkDrawingArea"
                        icon-name="widget-gtk-drawingarea"/>
    <glade-widget-class title="Print Preview" name="vcllo-PrintPreviewWindow"
                        generic-name="Print Preview" parent="GtkDrawingArea"
                        icon-name="widget-gtk-drawingarea"/>
    <glade-widget-class title="NUP Preview" name="vcllo-ShowNupOrderWindow"
                        generic-name="NUP Preview" parent="GtkDrawingArea"
                        icon-name="widget-gtk-drawingarea"/>

    <glade-widget-class title="Content List Box" name="sfxlo-ContentListBox"
                        generic-name="Content List Box" parent="GtkTreeView"
diff --git a/include/vcl/ivctrl.hxx b/include/vcl/ivctrl.hxx
index e7b89f1b..16bead7 100644
--- a/include/vcl/ivctrl.hxx
+++ b/include/vcl/ivctrl.hxx
@@ -320,6 +320,7 @@ public:
    void SetDeactivatePageHdl( const Link<VerticalTabControl*, bool>& rLink ) { m_aDeactivateHdl = rLink; }

    OUString GetPageText(const OString& rPageId) const;
    void SetPageText(const OString& rPageId, const OUString& rText);

    vcl::Window* GetPageParent() { return m_xBox.get(); }
};
diff --git a/include/vcl/oldprintadaptor.hxx b/include/vcl/oldprintadaptor.hxx
index 53e0d3d..3e8e60bf 100644
--- a/include/vcl/oldprintadaptor.hxx
+++ b/include/vcl/oldprintadaptor.hxx
@@ -23,6 +23,11 @@
#include <memory>
#include <vcl/print.hxx>

namespace weld
{
    class Window;
}

namespace vcl
{
    struct ImplOldStyleAdaptorData;
@@ -30,7 +35,7 @@ namespace vcl
    {
        std::unique_ptr<ImplOldStyleAdaptorData>  mpData;
    public:
        OldStylePrintAdaptor(const VclPtr<Printer>&, const VclPtr<vcl::Window>&);
        OldStylePrintAdaptor(const VclPtr<Printer>&, weld::Window*);
        virtual ~OldStylePrintAdaptor() override;

        void StartPage();
diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index 86d6551..154ee69 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -394,7 +394,7 @@ class VCL_DLLPUBLIC PrinterController
    std::unique_ptr<ImplPrinterControllerData>
                                        mpImplData;
protected:
                                        PrinterController( const VclPtr<Printer>&, const VclPtr<vcl::Window>& );
    PrinterController(const VclPtr<Printer>&, weld::Window*);
public:
    struct MultiPageSetup
    {
@@ -436,7 +436,7 @@ public:
    virtual ~PrinterController();

    const VclPtr<Printer>&              getPrinter() const;
    const VclPtr<vcl::Window>&          getWindow() const;
    weld::Window*                       getWindow() const;

    /** For implementations: get current job properties as changed by e.g. print dialog

diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index afd6266..67050d3 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -334,11 +334,13 @@ protected:

public:
    virtual int get_current_page() const = 0;
    virtual OString get_page_ident(int nPage) const = 0;
    virtual OString get_current_page_ident() const = 0;
    virtual void set_current_page(int nPage) = 0;
    virtual void set_current_page(const OString& rIdent) = 0;
    virtual void remove_page(const OString& rIdent) = 0;
    virtual void append_page(const OString& rIdent, const OUString& rLabel) = 0;
    virtual void set_tab_label_text(const OString& rIdent, const OUString& rLabel) = 0;
    virtual OUString get_tab_label_text(const OString& rIdent) const = 0;
    virtual int get_n_pages() const = 0;
    virtual weld::Container* get_page(const OString& rIdent) const = 0;
diff --git a/sd/uiconfig/sdraw/ui/drawprinteroptions.ui b/sd/uiconfig/sdraw/ui/drawprinteroptions.ui
index c8df16d..605507f 100644
--- a/sd/uiconfig/sdraw/ui/drawprinteroptions.ui
+++ b/sd/uiconfig/sdraw/ui/drawprinteroptions.ui
@@ -108,7 +108,6 @@
                    <property name="xalign">0</property>
                    <property name="active">True</property>
                    <property name="draw_indicator">True</property>
                    <property name="group">grayscale</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
@@ -126,7 +125,7 @@
                    <property name="xalign">0</property>
                    <property name="active">True</property>
                    <property name="draw_indicator">True</property>
                    <property name="group">blackandwhite</property>
                    <property name="group">originalcolors</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
@@ -201,7 +200,6 @@
                    <property name="xalign">0</property>
                    <property name="active">True</property>
                    <property name="draw_indicator">True</property>
                    <property name="group">fittoprintable</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
@@ -219,7 +217,7 @@
                    <property name="xalign">0</property>
                    <property name="active">True</property>
                    <property name="draw_indicator">True</property>
                    <property name="group">distributeonmultiple</property>
                    <property name="group">originalsize</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
@@ -237,7 +235,7 @@
                    <property name="xalign">0</property>
                    <property name="active">True</property>
                    <property name="draw_indicator">True</property>
                    <property name="group">tilesheet</property>
                    <property name="group">originalsize</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
diff --git a/sd/uiconfig/simpress/ui/impressprinteroptions.ui b/sd/uiconfig/simpress/ui/impressprinteroptions.ui
index 15a90c4..8679a74 100644
--- a/sd/uiconfig/simpress/ui/impressprinteroptions.ui
+++ b/sd/uiconfig/simpress/ui/impressprinteroptions.ui
@@ -71,7 +71,7 @@
                  </packing>
                </child>
                <child>
                  <object class="GtkComboBox" id="impressdocument">
                  <object class="GtkComboBoxText" id="impressdocument">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                  </object>
@@ -81,7 +81,7 @@
                  </packing>
                </child>
                <child>
                  <object class="GtkComboBox" id="slidesperpage">
                  <object class="GtkComboBoxText" id="slidesperpage">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                  </object>
@@ -91,7 +91,7 @@
                  </packing>
                </child>
                <child>
                  <object class="GtkComboBox" id="slidesperpageorder">
                  <object class="GtkComboBoxText" id="slidesperpageorder">
                    <property name="visible">True</property>
                    <property name="can_focus">False</property>
                  </object>
@@ -236,7 +236,6 @@
                    <property name="xalign">0</property>
                    <property name="active">True</property>
                    <property name="draw_indicator">True</property>
                    <property name="group">grayscale</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
@@ -254,7 +253,7 @@
                    <property name="xalign">0</property>
                    <property name="active">True</property>
                    <property name="draw_indicator">True</property>
                    <property name="group">blackandwhite</property>
                    <property name="group">originalcolors</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
@@ -329,7 +328,6 @@
                    <property name="xalign">0</property>
                    <property name="active">True</property>
                    <property name="draw_indicator">True</property>
                    <property name="group">fittoprintable</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
@@ -347,7 +345,7 @@
                    <property name="xalign">0</property>
                    <property name="active">True</property>
                    <property name="draw_indicator">True</property>
                    <property name="group">distributeonmultiple</property>
                    <property name="group">originalsize</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
@@ -365,7 +363,7 @@
                    <property name="xalign">0</property>
                    <property name="active">True</property>
                    <property name="draw_indicator">True</property>
                    <property name="group">tilesheet</property>
                    <property name="group">originalsize</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index 73f5e6e..608badc 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -107,7 +107,7 @@ SfxPrinterController::SfxPrinterController( const VclPtr<Printer>& i_rPrinter,
                                            SfxViewShell* pView,
                                            const uno::Sequence< beans::PropertyValue >& rProps
                                          )
    : PrinterController(i_rPrinter, pView ? pView->GetWindow() : nullptr)
    : PrinterController(i_rPrinter, pView ? pView->GetFrameWeld() : nullptr)
    , maCompleteSelection( i_rComplete )
    , maSelection( i_rSelection )
    , mxRenderable( i_xRender )
diff --git a/solenv/bin/native-code.py b/solenv/bin/native-code.py
index 399b2f1..0991a93 100755
--- a/solenv/bin/native-code.py
+++ b/solenv/bin/native-code.py
@@ -491,8 +491,6 @@ custom_widgets = [
    'SdPageObjsTLB',
    'SearchBox',
    'SearchResultsBox',
    'ShowNupOrderWindow',
    'ShowNupOrderWindow',
    'SidebarDialControl',
    'SidebarToolBox',
    'SpacingListBox',
diff --git a/solenv/sanitizers/ui/vcl.suppr b/solenv/sanitizers/ui/vcl.suppr
index 32ada0b6..e5ad013 100644
--- a/solenv/sanitizers/ui/vcl.suppr
+++ b/solenv/sanitizers/ui/vcl.suppr
@@ -4,13 +4,12 @@ vcl/uiconfig/ui/aboutbox.ui://GtkTextView[@id='version'] no-labelled-by
vcl/uiconfig/ui/aboutbox.ui://GtkLabel[@id='description'] orphan-label
vcl/uiconfig/ui/aboutbox.ui://GtkLabel[@id='copyright'] orphan-label
vcl/uiconfig/ui/cupspassworddialog.ui://GtkLabel[@id='text'] orphan-label
vcl/uiconfig/ui/printdialog.ui://GtkSpinButton[@id='pageedit-nospin'] no-labelled-by
vcl/uiconfig/ui/printdialog.ui://GtkEntry[@id='pageedit-nospin'] no-labelled-by
vcl/uiconfig/ui/printdialog.ui://GtkLabel[@id='totalnumpages'] orphan-label
vcl/uiconfig/ui/printdialog.ui://GtkImage[@id='collateimage'] no-labelled-by
vcl/uiconfig/ui/printdialog.ui://vcllo-ShowNupOrderWindow[@id='orderpreview'] no-labelled-by
vcl/uiconfig/ui/printdialog.ui://GtkLabel[@id='pagemargintxt2'] orphan-label
vcl/uiconfig/ui/printdialog.ui://GtkLabel[@id='sheetmargintxt2'] orphan-label
vcl/uiconfig/ui/printdialog.ui://GtkComboBox[@id='scriptdirection'] no-labelled-by
vcl/uiconfig/ui/printdialog.ui://GtkComboBoxText[@id='scriptdirection'] no-labelled-by
vcl/uiconfig/ui/printerdevicepage.ui://GtkEntry[@id='custom'] no-labelled-by
vcl/uiconfig/ui/printprogressdialog.ui://GtkLabel[@id='label'] orphan-label
vcl/uiconfig/ui/printprogressdialog.ui://GtkProgressBar[@id='progressbar'] no-labelled-by
diff --git a/starmath/uiconfig/smath/ui/printeroptions.ui b/starmath/uiconfig/smath/ui/printeroptions.ui
index 24163da..9c500f9 100644
--- a/starmath/uiconfig/smath/ui/printeroptions.ui
+++ b/starmath/uiconfig/smath/ui/printeroptions.ui
@@ -1,7 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<!-- Generated with glade 3.22.1 -->
<interface domain="sm">
  <requires lib="gtk+" version="3.18"/>
  <object class="GtkAdjustment" id="adjustment1">
    <property name="lower">10</property>
    <property name="upper">1000</property>
    <property name="value">100</property>
    <property name="step_increment">1</property>
    <property name="page_increment">10</property>
  </object>
  <object class="GtkBox" id="box">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
@@ -124,7 +131,6 @@
                    <property name="xalign">0</property>
                    <property name="active">True</property>
                    <property name="draw_indicator">True</property>
                    <property name="group">fittopage</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
@@ -141,7 +147,7 @@
                    <property name="use_underline">True</property>
                    <property name="xalign">0</property>
                    <property name="draw_indicator">True</property>
                    <property name="group">scaling</property>
                    <property name="group">originalsize</property>
                  </object>
                  <packing>
                    <property name="expand">False</property>
@@ -175,6 +181,7 @@
                      <object class="GtkSpinButton" id="scalingspin">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="adjustment">adjustment1</property>
                      </object>
                      <packing>
                        <property name="expand">False</property>
diff --git a/sw/uiconfig/swriter/ui/printeroptions.ui b/sw/uiconfig/swriter/ui/printeroptions.ui
index 36f9d87..21e4ad6 100644
--- a/sw/uiconfig/swriter/ui/printeroptions.ui
+++ b/sw/uiconfig/swriter/ui/printeroptions.ui
@@ -126,7 +126,7 @@
                      </packing>
                    </child>
                    <child>
                      <object class="GtkComboBox" id="writercomments">
                      <object class="GtkComboBoxText" id="writercomments">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                      </object>
diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx
index 4aad503..8328b63 100644
--- a/vcl/inc/printdlg.hxx
+++ b/vcl/inc/printdlg.hxx
@@ -20,15 +20,12 @@
#ifndef VCL_INC_NEWPRINTDLG_HXX
#define VCL_INC_NEWPRINTDLG_HXX

#include <vcl/print.hxx>
#include <vcl/dialog.hxx>
#include <vcl/fixed.hxx>
#include <vcl/button.hxx>
#include <vcl/field.hxx>
#include <vcl/layout.hxx>
#include <vcl/tabctrl.hxx>
#include <vcl/bitmapex.hxx>
#include <vcl/gdimtf.hxx>
#include <vcl/print.hxx>
#include <vcl/customweld.hxx>
#include <vcl/weld.hxx>
#include <map>

namespace vcl {
    class PrintDialog;
@@ -38,7 +35,7 @@ namespace vcl
{
    class MoreOptionsDialog : public weld::GenericDialogController
    {
        VclPtr<PrintDialog>                     mpParent;
        PrintDialog*                            mpParent;
        std::unique_ptr<weld::Button>           mxOKButton;
        std::unique_ptr<weld::Button>           mxCancelButton;
        std::unique_ptr<weld::CheckButton>      mxSingleJobsBox;
@@ -47,17 +44,18 @@ namespace vcl

    public:

        MoreOptionsDialog( VclPtr<PrintDialog> i_pParent );
        MoreOptionsDialog(PrintDialog* i_pParent);
        virtual ~MoreOptionsDialog() override;
    };

    class PrintDialog : public ModalDialog
    class PrintDialog : public weld::GenericDialogController
    {
        friend class MoreOptionsDialog;
    public:

        class PrintPreviewWindow : public vcl::Window
        class PrintPreviewWindow : public weld::CustomWidgetController
        {
            PrintDialog*        mpDialog;
            GDIMetaFile         maMtf;
            Size                maOrigSize;
            Size                maPreviewSize;
@@ -65,20 +63,19 @@ namespace vcl
            sal_Int32           mnDPIY;
            BitmapEx            maPreviewBitmap;
            OUString            maReplacementString;
            OUString const      maToolTipString;
            bool                mbGreyscale;
            VclPtr<FixedLine>   maHorzDim;
            VclPtr<FixedLine>   maVertDim;

            OUString            maHorzText;
            OUString            maVertText;

            void preparePreviewBitmap();

        public:
            PrintPreviewWindow( vcl::Window* pParent );
            PrintPreviewWindow(PrintDialog* pDialog);
            virtual ~PrintPreviewWindow() override;
            virtual void dispose() override;

            virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
            virtual void Command( const CommandEvent& ) override;
            virtual bool Command( const CommandEvent& ) override;
            virtual void Resize() override;

            void setPreview( const GDIMetaFile&, const Size& i_rPaperSize,
@@ -89,15 +86,15 @@ namespace vcl
                            );
        };

        class ShowNupOrderWindow : public vcl::Window
        class ShowNupOrderWindow : public weld::CustomWidgetController
        {
            NupOrderType mnOrderMode;
            int mnRows;
            int mnColumns;
        public:
            ShowNupOrderWindow( vcl::Window* pParent );
            ShowNupOrderWindow();

            virtual Size GetOptimalSize() const override;
            virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;

            virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override;

@@ -110,9 +107,8 @@ namespace vcl
            }
        };

        PrintDialog( vcl::Window*, const std::shared_ptr< PrinterController >& );
        PrintDialog(weld::Window*, const std::shared_ptr<PrinterController>&);
        virtual ~PrintDialog() override;
        virtual void dispose() override;

        bool isPrintToFile() const;
        bool isCollate() const;
@@ -127,42 +123,72 @@ namespace vcl

    private:

        std::unique_ptr<VclBuilder>             mpCustomOptionsUIBuilder;
        std::unique_ptr<weld::Builder>          mxCustomOptionsUIBuilder;

        std::shared_ptr<PrinterController>      maPController;

        std::unique_ptr<MoreOptionsDialog>      mxMoreOptionsDlg;

        VclPtr<TabControl>                      mpTabCtrl;
        VclPtr<VclFrame>                        mpPageLayoutFrame;
        VclPtr<ListBox>                         mpPrinters;
        VclPtr<FixedText>                       mpStatusTxt;
        VclPtr<PushButton>                      mpSetupButton;
        std::unique_ptr<weld::Notebook>         mxTabCtrl;
        std::unique_ptr<weld::Frame>            mxPageLayoutFrame;
        std::unique_ptr<weld::ComboBox>         mxPrinters;
        std::unique_ptr<weld::Label>            mxStatusTxt;
        std::unique_ptr<weld::Button>           mxSetupButton;

        std::unique_ptr<weld::SpinButton>       mxCopyCountField;
        std::unique_ptr<weld::CheckButton>      mxCollateBox;
        std::unique_ptr<weld::Image>            mxCollateImage;
        std::unique_ptr<weld::ComboBox>         mxPaperSidesBox;
        std::unique_ptr<weld::CheckButton>      mxReverseOrderBox;

        std::unique_ptr<weld::Button>           mxOKButton;
        std::unique_ptr<weld::Button>           mxCancelButton;
        std::unique_ptr<weld::Button>           mxHelpButton;
        std::unique_ptr<weld::Button>           mxMoreOptionsBtn;

        std::unique_ptr<weld::Button>           mxBackwardBtn;
        std::unique_ptr<weld::Button>           mxForwardBtn;
        std::unique_ptr<weld::Button>           mxFirstBtn;
        std::unique_ptr<weld::Button>           mxLastBtn;

        std::unique_ptr<weld::CheckButton>      mxPreviewBox;
        std::unique_ptr<weld::Label>            mxNumPagesText;
        std::unique_ptr<PrintPreviewWindow>     mxPreview;
        std::unique_ptr<weld::CustomWeld>       mxPreviewWindow;
        std::unique_ptr<weld::Entry>            mxPageEdit;

        std::unique_ptr<weld::RadioButton>      mxPagesBtn;
        std::unique_ptr<weld::RadioButton>      mxBrochureBtn;
        std::unique_ptr<weld::Label>            mxPagesBoxTitleTxt;
        std::unique_ptr<weld::ComboBox>         mxNupPagesBox;

        // controls for "Custom" page mode
        std::unique_ptr<weld::Label>            mxNupNumPagesTxt;
        std::unique_ptr<weld::SpinButton>       mxNupColEdt;
        std::unique_ptr<weld::Label>            mxNupTimesTxt;
        std::unique_ptr<weld::SpinButton>       mxNupRowsEdt;
        std::unique_ptr<weld::Label>            mxPageMarginTxt1;
        std::unique_ptr<weld::MetricSpinButton> mxPageMarginEdt;
        std::unique_ptr<weld::Label>            mxPageMarginTxt2;
        std::unique_ptr<weld::Label>            mxSheetMarginTxt1;
        std::unique_ptr<weld::MetricSpinButton> mxSheetMarginEdt;
        std::unique_ptr<weld::Label>            mxSheetMarginTxt2;
        std::unique_ptr<weld::ComboBox>         mxPaperSizeBox;
        std::unique_ptr<weld::ComboBox>         mxOrientationBox;

        // page order ("left to right, then down")
        std::unique_ptr<weld::Label>            mxNupOrderTxt;
        std::unique_ptr<weld::ComboBox>         mxNupOrderBox;
        std::unique_ptr<ShowNupOrderWindow>     mxNupOrder;
        std::unique_ptr<weld::CustomWeld>       mxNupOrderWin;
        /// border around each page
        std::unique_ptr<weld::CheckButton>      mxBorderCB;
        std::unique_ptr<weld::Widget>           mxCustom;

        OUString const                          maPrintToFileText;
        OUString                                maPrintText;
        OUString const                          maDefPrtText;

        VclPtr<NumericField>                    mpCopyCountField;
        VclPtr<CheckBox>                        mpCollateBox;
        VclPtr<FixedImage>                      mpCollateImage;
        VclPtr<ListBox>                         mpPaperSidesBox;
        VclPtr<CheckBox>                        mpReverseOrderBox;

        VclPtr<OKButton>                        mpOKButton;
        VclPtr<CancelButton>                    mpCancelButton;
        VclPtr<HelpButton>                      mpHelpButton;
        VclPtr<PushButton>                      mpMoreOptionsBtn;

        VclPtr<PushButton>                      mpBackwardBtn;
        VclPtr<PushButton>                      mpForwardBtn;
        VclPtr<PushButton>                      mpFirstBtn;
        VclPtr<PushButton>                      mpLastBtn;

        VclPtr<CheckBox>                        mpPreviewBox;
        VclPtr<FixedText>                       mpNumPagesText;
        VclPtr<PrintPreviewWindow>              mpPreviewWindow;
        VclPtr<NumericField>                    mpPageEdit;

        OUString                                maPageStr;
        OUString const                          maNoPageStr;
        OUString const                          maNoPreviewStr;
@@ -171,37 +197,14 @@ namespace vcl

        bool                                    mbCollateAlwaysOff;

        VclPtr<RadioButton>                     mpPagesBtn;
        VclPtr<RadioButton>                     mpBrochureBtn;
        VclPtr<FixedText>                       mpPagesBoxTitleTxt;
        VclPtr<ListBox>                         mpNupPagesBox;
        std::vector<std::unique_ptr<weld::Widget>>
                                                maExtraControls;

        // controls for "Custom" page mode
        VclPtr<FixedText>                       mpNupNumPagesTxt;
        VclPtr<NumericField>                    mpNupColEdt;
        VclPtr<FixedText>                       mpNupTimesTxt;
        VclPtr<NumericField>                    mpNupRowsEdt;
        VclPtr<FixedText>                       mpPageMarginTxt1;
        VclPtr<MetricField>                     mpPageMarginEdt;
        VclPtr<FixedText>                       mpPageMarginTxt2;
        VclPtr<FixedText>                       mpSheetMarginTxt1;
        VclPtr<MetricField>                     mpSheetMarginEdt;
        VclPtr<FixedText>                       mpSheetMarginTxt2;
        VclPtr<ListBox>                         mpPaperSizeBox;
        VclPtr<ListBox>                         mpOrientationBox;

        // page order ("left to right, then down")
        VclPtr<FixedText>                       mpNupOrderTxt;
        VclPtr<ListBox>                         mpNupOrderBox;
        VclPtr<ShowNupOrderWindow>              mpNupOrderWin;
        /// border around each page
        VclPtr<CheckBox>                        mpBorderCB;

        std::map< VclPtr<vcl::Window>, OUString >
        std::map<weld::Widget*, OUString>
                                                maControlToPropertyMap;
        std::map< OUString, std::vector< VclPtr<vcl::Window> > >
        std::map<OUString, std::vector<weld::Widget*>>
                                                maPropertyToWindowMap;
        std::map< VclPtr<vcl::Window>, sal_Int32 >
        std::map<weld::Widget*, sal_Int32>
                                                maControlToNumValMap;

        Size                                    maNupPortraitSize;
@@ -214,18 +217,21 @@ namespace vcl

        Paper                                   mePaper;

        DECL_LINK( ClickHdl, Button*, void );
        DECL_LINK( SelectHdl, ListBox&, void );
        DECL_LINK( ModifyHdl, Edit&, void );
        DECL_LINK( ToggleHdl, CheckBox&, void );
        DECL_LINK( ToggleRadioHdl, RadioButton&, void );
        DECL_LINK( ClickHdl, weld::Button&, void );
        DECL_LINK( SelectHdl, weld::ComboBox&, void );
        DECL_LINK( ActivateHdl, weld::Entry&, bool );
        DECL_LINK( FocusOutHdl, weld::Widget&, void );
        DECL_LINK( SpinModifyHdl, weld::SpinButton&, void );
        DECL_LINK( MetricSpinModifyHdl, weld::MetricSpinButton&, void );
        DECL_LINK( ToggleHdl, weld::ToggleButton&, void );

        DECL_LINK( UIOption_CheckHdl, CheckBox&, void );
        DECL_LINK( UIOption_RadioHdl, RadioButton&, void );
        DECL_LINK( UIOption_SelectHdl, ListBox&, void );
        DECL_LINK( UIOption_ModifyHdl, Edit&, void );
        DECL_LINK( UIOption_CheckHdl, weld::ToggleButton&, void );
        DECL_LINK( UIOption_RadioHdl, weld::ToggleButton&, void );
        DECL_LINK( UIOption_SelectHdl, weld::ComboBox&, void );
        DECL_LINK( UIOption_SpinModifyHdl, weld::SpinButton&, void );
        DECL_LINK( UIOption_EntryModifyHdl, weld::Entry&, void );

        css::beans::PropertyValue* getValueForWindow( vcl::Window* ) const;
        css::beans::PropertyValue* getValueForWindow(weld::Widget*) const;

        void preparePreview( bool i_bMayUseCache );
        void setupPaperSidesBox();
@@ -239,7 +245,7 @@ namespace vcl
        void updatePrinterText();
        void checkControlDependencies();
        void checkOptionalControlDependencies();
        void makeEnabled( vcl::Window* );
        void makeEnabled( weld::Widget* );
        void updateWindowFromProperty( const OUString& );
        void initFromMultiPageSetup( const vcl::PrinterController::MultiPageSetup& );
        void showAdvancedControls( bool );
diff --git a/vcl/inc/strings.hrc b/vcl/inc/strings.hrc
index e00f386..c561de7 100644
--- a/vcl/inc/strings.hrc
+++ b/vcl/inc/strings.hrc
@@ -116,7 +116,6 @@
#define SV_PRINT_NOPREVIEW                           NC_("SV_PRINT_NOPREVIEW", "Preview is disabled")
#define SV_PRINT_TOFILE_TXT                          NC_("SV_PRINT_TOFILE_TXT", "Print to File...")
#define SV_PRINT_DEFPRT_TXT                          NC_("SV_PRINT_DEFPRT_TXT", "Default printer")
#define SV_PRINT_PRINTPREVIEW_TXT                    NC_("SV_PRINT_PRINTPREVIEW_TXT", "Print preview")
#define SV_PRINT_QUERYFAXNUMBER_TXT                  NC_("SV_PRINT_QUERYFAXNUMBER_TXT", "Please enter the fax number")
#define SV_PRINT_INVALID_TXT                         NC_("SV_PRINT_INVALID_TXT", "<ignore>")
#define SV_PRINT_CUSTOM_TXT                          NC_("SV_PRINT_CUSTOM_TXT", "Custom")
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 0dabf4b..2d9193d 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -2020,6 +2020,11 @@ public:
        return m_xNotebook->GetPagePos(m_xNotebook->GetCurPageId());
    }

    virtual OString get_page_ident(int nPage) const override
    {
        return m_xNotebook->GetPageName(m_xNotebook->GetPageId(nPage));
    }

    virtual OString get_current_page_ident() const override
    {
        return m_xNotebook->GetPageName(m_xNotebook->GetCurPageId());
@@ -2083,6 +2088,11 @@ public:
        return m_xNotebook->GetPageText(m_xNotebook->GetPageId(rIdent));
    }

    virtual void set_tab_label_text(const OString& rIdent, const OUString& rText) override
    {
        return m_xNotebook->SetPageText(m_xNotebook->GetPageId(rIdent), rText);
    }

    virtual ~SalInstanceNotebook() override
    {
        for (auto &rGrid : m_aAddedGrids)
@@ -2127,6 +2137,11 @@ public:
        return m_xNotebook->GetPagePos(m_xNotebook->GetCurPageId());
    }

    virtual OString get_page_ident(int nPage) const override
    {
        return m_xNotebook->GetPageId(nPage);
    }

    virtual OString get_current_page_ident() const override
    {
        return m_xNotebook->GetCurPageId();
@@ -2173,6 +2188,11 @@ public:
        return m_xNotebook->GetPageCount();
    }

    virtual void set_tab_label_text(const OString& rIdent, const OUString& rText) override
    {
        return m_xNotebook->SetPageText(rIdent, rText);
    }

    virtual OUString get_tab_label_text(const OString& rIdent) const override
    {
        return m_xNotebook->GetPageText(rIdent);
diff --git a/vcl/source/control/ivctrl.cxx b/vcl/source/control/ivctrl.cxx
index a096ce6..8cef33b 100644
--- a/vcl/source/control/ivctrl.cxx
+++ b/vcl/source/control/ivctrl.cxx
@@ -611,4 +611,12 @@ OUString VerticalTabControl::GetPageText(const OString& rPageId) const
    return pData->pEntry->GetText();
}

void VerticalTabControl::SetPageText(const OString& rPageId, const OUString& rText)
{
    VerticalTabPageData* pData = GetPageData(rPageId);
    if (!pData)
        return;
    pData->pEntry->SetText(rText);
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/oldprintadaptor.cxx b/vcl/source/gdi/oldprintadaptor.cxx
index 8636034..ad5cb82 100644
--- a/vcl/source/gdi/oldprintadaptor.cxx
+++ b/vcl/source/gdi/oldprintadaptor.cxx
@@ -44,8 +44,8 @@ namespace vcl
    };
}

OldStylePrintAdaptor::OldStylePrintAdaptor(const VclPtr<Printer>& i_xPrinter, const VclPtr<vcl::Window>& i_xWindow)
    : PrinterController(i_xPrinter, i_xWindow)
OldStylePrintAdaptor::OldStylePrintAdaptor(const VclPtr<Printer>& i_xPrinter, weld::Window* i_pWindow)
    : PrinterController(i_xPrinter, i_pWindow)
    , mpData(new ImplOldStyleAdaptorData)
{
}
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index 89d0a40..50b2093 100644
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -138,7 +138,7 @@ public:
    typedef std::unordered_map< OUString, css::uno::Sequence< sal_Bool > > ChoiceDisableMap;

    VclPtr< Printer >                                           mxPrinter;
    VclPtr<vcl::Window>                                         mxWindow;
    weld::Window*                                               mpWindow;
    css::uno::Sequence< css::beans::PropertyValue >             maUIOptions;
    std::vector< css::beans::PropertyValue >                    maUIProperties;
    std::vector< bool >                                         maUIPropertyEnabled;
@@ -183,6 +183,7 @@ public:
    // history suggests this is intentional...

    ImplPrinterControllerData() :
        mpWindow( nullptr ),
        mbFirstPage( true ),
        mbLastPage( false ),
        mbReversePageOrder( false ),
@@ -219,11 +220,11 @@ public:
    void resetPaperToLastConfigured();
};

PrinterController::PrinterController(const VclPtr<Printer>& i_xPrinter, const VclPtr<vcl::Window>& i_xWindow)
PrinterController::PrinterController(const VclPtr<Printer>& i_xPrinter, weld::Window* i_pWindow)
    : mpImplData( new ImplPrinterControllerData )
{
    mpImplData->mxPrinter = i_xPrinter;
    mpImplData->mxWindow = i_xWindow;
    mpImplData->mpWindow = i_pWindow;
}

static OUString queryFile( Printer const * pPrinter )
@@ -316,8 +317,7 @@ bool Printer::PreparePrintJob(std::shared_ptr<PrinterController> xController,
    {
        if (xController->isShowDialogs())
        {
            VclPtr<vcl::Window> xParent = xController->getWindow();
            std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(xParent ? xParent->GetFrameWeld() : nullptr, "vcl/ui/errornoprinterdialog.ui"));
            std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(xController->getWindow(), "vcl/ui/errornoprinterdialog.ui"));
            std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog("ErrorNoPrinterDialog"));
            xBox->run();
        }
@@ -467,8 +467,7 @@ bool Printer::PreparePrintJob(std::shared_ptr<PrinterController> xController,
    {
        if( xController->getFilteredPageCount() == 0 )
        {
            VclPtr<vcl::Window> xParent = xController->getWindow();
            std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(xParent ? xParent->GetFrameWeld() : nullptr, "vcl/ui/errornocontentdialog.ui"));
            std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(xController->getWindow(), "vcl/ui/errornocontentdialog.ui"));
            std::unique_ptr<weld::MessageDialog> xBox(xBuilder->weld_message_dialog("ErrorNoContentDialog"));
            xBox->run();
            return false;
@@ -484,14 +483,13 @@ bool Printer::PreparePrintJob(std::shared_ptr<PrinterController> xController,
    {
        try
        {
            VclPtr<vcl::Window> xParent = xController->getWindow();
            ScopedVclPtrInstance< PrintDialog > aDlg( xParent, xController );
            if( ! aDlg->Execute() )
            PrintDialog aDlg(xController->getWindow(), xController);
            if (!aDlg.run())
            {
                xController->abortJob();
                return false;
            }
            if( aDlg->isPrintToFile() )
            if (aDlg.isPrintToFile())
            {
                OUString aFile = queryFile( xController->getPrinter().get() );
                if( aFile.isEmpty() )
@@ -502,7 +500,7 @@ bool Printer::PreparePrintJob(std::shared_ptr<PrinterController> xController,
                xController->setValue( "LocalFileName",
                                       css::uno::makeAny( aFile ) );
            }
            else if( aDlg->isSingleJobs() )
            else if (aDlg.isSingleJobs())
            {
                xController->setValue( "PrintCollateAsSingleJobs",
                                        css::uno::makeAny( true ) );
@@ -775,9 +773,9 @@ const VclPtr<Printer>& PrinterController::getPrinter() const
    return mpImplData->mxPrinter;
}

const VclPtr<vcl::Window>& PrinterController::getWindow() const
weld::Window* PrinterController::getWindow() const
{
    return mpImplData->mxWindow;
    return mpImplData->mpWindow;
}

void PrinterController::setPrinter( const VclPtr<Printer>& i_rPrinter )
@@ -1693,8 +1691,7 @@ void PrinterController::createProgressDialog()

        if( bShow && ! Application::IsHeadlessModeEnabled() )
        {
            VclPtr<vcl::Window> xParent = getWindow();
            mpImplData->mxProgress.reset(new PrintProgressDialog(xParent ? xParent->GetFrameWeld() : nullptr, getPageCountProtected()));
            mpImplData->mxProgress.reset(new PrintProgressDialog(getWindow(), getPageCountProtected()));
            weld::DialogController::runAsync(mpImplData->mxProgress, [](sal_Int32 /*nResult*/){});
        }
    }
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index 3289e2e..4b417f7 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -57,20 +57,6 @@ enum
    ORIENTATION_LANDSCAPE
};

extern "C" SAL_DLLPUBLIC_EXPORT void makePrintPreviewWindow(VclPtr<vcl::Window> & rRet, const VclPtr<vcl::Window> & pParent, VclBuilder::stringmap &)
{
    static_assert(std::is_same_v<std::remove_pointer_t<VclBuilder::customMakeWidget>,
                                 decltype(makePrintPreviewWindow)>);
    rRet = VclPtr<PrintDialog::PrintPreviewWindow>::Create(pParent);
}

extern "C" SAL_DLLPUBLIC_EXPORT void makeShowNupOrderWindow(VclPtr<vcl::Window> & rRet, const VclPtr<vcl::Window> & pParent, VclBuilder::stringmap &)
{
    static_assert(std::is_same_v<std::remove_pointer_t<VclBuilder::customMakeWidget>,
                                 decltype(makeShowNupOrderWindow)>);
    rRet = VclPtr<PrintDialog::ShowNupOrderWindow>::Create(pParent);
}

namespace {
   bool lcl_ListBoxCompare( const OUString& rStr1, const OUString& rStr2 )
   {
@@ -78,8 +64,8 @@ namespace {
   }
}

MoreOptionsDialog::MoreOptionsDialog(VclPtr<PrintDialog> i_pParent)
    : GenericDialogController(i_pParent->GetFrameWeld(), "vcl/ui/moreoptionsdialog.ui", "MoreOptionsDialog")
MoreOptionsDialog::MoreOptionsDialog(PrintDialog* i_pParent)
    : GenericDialogController(i_pParent->getDialog(), "vcl/ui/moreoptionsdialog.ui", "MoreOptionsDialog")
    , mpParent( i_pParent )
    , mxOKButton(m_xBuilder->weld_button("ok"))
    , mxCancelButton(m_xBuilder->weld_button("cancel"))
@@ -108,8 +94,8 @@ IMPL_LINK (MoreOptionsDialog, ClickHdl, weld::Button&, rButton, void)
    }
}

PrintDialog::PrintPreviewWindow::PrintPreviewWindow( vcl::Window* i_pParent )
    : Window( i_pParent, 0 )
PrintDialog::PrintPreviewWindow::PrintPreviewWindow(PrintDialog* pDialog)
    : mpDialog(pDialog)
    , maMtf()
    , maOrigSize( 10, 10 )
    , maPreviewSize()
@@ -117,36 +103,18 @@ PrintDialog::PrintPreviewWindow::PrintPreviewWindow( vcl::Window* i_pParent )
    , mnDPIY(Application::GetDefaultDevice()->GetDPIY())
    , maPreviewBitmap()
    , maReplacementString()
    , maToolTipString(VclResId( SV_PRINT_PRINTPREVIEW_TXT))
    , mbGreyscale( false )
    , maHorzDim(VclPtr<FixedLine>::Create(this, WB_HORZ | WB_CENTER))
    , maVertDim(VclPtr<FixedLine>::Create(this, WB_VERT | WB_VCENTER))
{
    SetPaintTransparent( true );
    SetBackground();
    maHorzDim->Show();
    maVertDim->Show();

    maHorzDim->SetText( "2.0in" );
    maVertDim->SetText( "2.0in" );
}

PrintDialog::PrintPreviewWindow::~PrintPreviewWindow()
{
    disposeOnce();
}

void PrintDialog::PrintPreviewWindow::dispose()
{
    maHorzDim.disposeAndClear();
    maVertDim.disposeAndClear();
    Window::dispose();
}

void PrintDialog::PrintPreviewWindow::Resize()
{
    Size aNewSize( GetSizePixel() );
    long nTextHeight = maHorzDim->GetTextHeight();
    Size aNewSize(GetOutputSizePixel());
    long nTextHeight = GetDrawingArea()->get_text_height();
    // leave small space for decoration
    aNewSize.AdjustWidth( -(nTextHeight + 2) );
    aNewSize.AdjustHeight( -(nTextHeight + 2) );
@@ -176,36 +144,71 @@ void PrintDialog::PrintPreviewWindow::Resize()

    maPreviewSize = aScaledSize;

    // position dimension lines
    Point aRef( nTextHeight + (aNewSize.Width() - maPreviewSize.Width())/2,
                nTextHeight + (aNewSize.Height() - maPreviewSize.Height())/2 );
    maHorzDim->SetPosSizePixel( Point( aRef.X(), aRef.Y() - nTextHeight ),
                               Size( maPreviewSize.Width(), nTextHeight ) );
    maVertDim->SetPosSizePixel( Point( aRef.X() - nTextHeight, aRef.Y() ),
                               Size( nTextHeight, maPreviewSize.Height() ) );

    // check and evtl. recreate preview bitmap
    preparePreviewBitmap();
}

void PrintDialog::PrintPreviewWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&)
{
    long nTextHeight = maHorzDim->GetTextHeight();
    Size aSize(GetSizePixel());
    rRenderContext.Push();
    if (vcl::Window* pDefaultDevice = dynamic_cast<vcl::Window*>(Application::GetDefaultDevice()))
    {
        Font aFont(rRenderContext.GetSettings().GetStyleSettings().GetLabelFont());
        pDefaultDevice->SetPointFont(rRenderContext, aFont);
    }

    rRenderContext.SetBackground(Wallpaper(Application::GetSettings().GetStyleSettings().GetDialogColor()));
    rRenderContext.Erase();

    auto nTextHeight = rRenderContext.GetTextHeight();
    Size aSize(GetOutputSizePixel());
    Point aOffset((aSize.Width()  - maPreviewSize.Width()  + nTextHeight) / 2,
                  (aSize.Height() - maPreviewSize.Height() + nTextHeight) / 2);

    // horizontal line
    {
        auto nTop = aOffset.Y() - nTextHeight;

        auto nWidth = rRenderContext.GetTextWidth(maHorzText);

        auto nStart = aOffset.X() + (maPreviewSize.Width() - nWidth) / 2;
        rRenderContext.DrawText(Point(nStart, aOffset.Y() - nTextHeight), maHorzText, 0, maHorzText.getLength());

        DecorationView aDecoView(&rRenderContext);
        nTop = aOffset.Y() - (nTextHeight / 2);
        aDecoView.DrawSeparator(Point(aOffset.X(), nTop), Point(nStart - 2, nTop), false);
        aDecoView.DrawSeparator(Point(nStart + nWidth + 2, nTop), Point(aOffset.X() + maPreviewSize.Width(), nTop), false);
    }

    // vertical line
    {
        rRenderContext.Push(PushFlags::FONT);
        vcl::Font aFont(rRenderContext.GetFont());
        aFont.SetOrientation(900);
        rRenderContext.SetFont(aFont);

        auto nLeft = aOffset.X() - nTextHeight;

        auto nWidth = rRenderContext.GetTextWidth(maVertText);
        auto nStart = aOffset.Y() + (maPreviewSize.Height() + nWidth) / 2;

        rRenderContext.DrawText(Point(nLeft, nStart), maVertText, 0, maVertText.getLength());

        DecorationView aDecoView(&rRenderContext);
        nLeft = aOffset.X() - (nTextHeight / 2);
        aDecoView.DrawSeparator(Point(nLeft, aOffset.Y()), Point(nLeft, nStart - nWidth - 2), true);
        aDecoView.DrawSeparator(Point(nLeft, nStart + 2), Point(nLeft, aOffset.Y() + maPreviewSize.Height()), true);

        rRenderContext.Pop();
    }

    if (!maReplacementString.isEmpty())
    {
        // replacement is active
        rRenderContext.Push();
        Font aFont(rRenderContext.GetSettings().GetStyleSettings().GetLabelFont());
        SetZoomedPointFont(rRenderContext, aFont);
        tools::Rectangle aTextRect(aOffset + Point(2, 2), Size(maPreviewSize.Width() - 4, maPreviewSize.Height() - 4));
        rRenderContext.DrawText(aTextRect, maReplacementString,
                                DrawTextFlags::Center | DrawTextFlags::VCenter |
                                DrawTextFlags::WordBreak | DrawTextFlags::MultiLine);
        rRenderContext.Pop();
    }
    else
    {
@@ -222,22 +225,22 @@ void PrintDialog::PrintPreviewWindow::Paint(vcl::RenderContext& rRenderContext, 
    tools::Rectangle aFrameRect(aOffset + Point(-1, -1), Size(maPreviewSize.Width() + 2, maPreviewSize.Height() + 2));
    DecorationView aDecorationView(&rRenderContext);
    aDecorationView.DrawFrame(aFrameRect, DrawFrameStyle::Group);

    rRenderContext.Pop();
}

void PrintDialog::PrintPreviewWindow::Command( const CommandEvent& rEvt )
bool PrintDialog::PrintPreviewWindow::Command( const CommandEvent& rEvt )
{
    if( rEvt.GetCommand() == CommandEventId::Wheel )
    {
        const CommandWheelData* pWheelData = rEvt.GetWheelData();
        PrintDialog* pDlg = dynamic_cast<PrintDialog*>(GetParentDialog());
        if( pDlg )
        {
            if( pWheelData->GetDelta() > 0 )
                pDlg->previewForward();
            else if( pWheelData->GetDelta() < 0 )
                pDlg->previewBackward();
        }
        if(pWheelData->GetDelta() > 0)
            mpDialog->previewForward();
        else if (pWheelData->GetDelta() < 0)
            mpDialog->previewBackward();
        return true;
    }
    return CustomWidgetController::Command(rEvt);
}

void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPreview,
@@ -249,9 +252,6 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi
                                                  bool i_bGreyscale
                                                 )
{
    OUStringBuffer aBuf( 256 );
    aBuf.append( maToolTipString );
    SetQuickHelpText( aBuf.makeStringAndClear() );
    maMtf = i_rNewPreview;
    mnDPIX = i_nDPIX;
    mnDPIY = i_nDPIY;
@@ -260,7 +260,7 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi
    mbGreyscale = i_bGreyscale;

    // use correct measurements
    const LocaleDataWrapper& rLocWrap( GetSettings().GetLocaleDataWrapper() );
    const LocaleDataWrapper& rLocWrap(Application::GetSettings().GetLocaleDataWrapper());
    MapUnit eUnit = MapUnit::MapMM;
    int nDigits = 0;
    if( rLocWrap.getMeasurementSystemEnum() == MeasurementSystem::US )
@@ -268,8 +268,9 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi
        eUnit = MapUnit::Map100thInch;
        nDigits = 2;
    }
    Size aLogicPaperSize( LogicToLogic( i_rOrigSize, MapMode( MapUnit::Map100thMM ), MapMode( eUnit ) ) );
    Size aLogicPaperSize(OutputDevice::LogicToLogic(i_rOrigSize, MapMode(MapUnit::Map100thMM), MapMode(eUnit)));
    OUString aNumText( rLocWrap.getNum( aLogicPaperSize.Width(), nDigits ) );
    OUStringBuffer aBuf;
    aBuf.append( aNumText )
        .append( u' ' );
    aBuf.appendAscii( eUnit == MapUnit::MapMM ? "mm" : "in" );
@@ -279,13 +280,13 @@ void PrintDialog::PrintPreviewWindow::setPreview( const GDIMetaFile& i_rNewPrevi
        aBuf.append( i_rPaperName );
        aBuf.append( ')' );
    }
    maHorzDim->SetText( aBuf.makeStringAndClear() );
    maHorzText = aBuf.makeStringAndClear();

    aNumText = rLocWrap.getNum( aLogicPaperSize.Height(), nDigits );
    aBuf.append( aNumText )
        .append( u' ' );
    aBuf.appendAscii( eUnit == MapUnit::MapMM ? "mm" : "in" );
    maVertDim->SetText( aBuf.makeStringAndClear() );
    maVertText = aBuf.makeStringAndClear();

    // We have a new Metafile and evtl. a new page, so we need to reset
    // the PreviewBitmap to force new creation
@@ -418,7 +419,6 @@ void PrintDialog::PrintPreviewWindow::preparePreviewBitmap()

    pPrerenderVDev->Pop();

    SetMapMode(MapMode(MapUnit::MapPixel));
    pPrerenderVDev->SetMapMode(MapMode(MapUnit::MapPixel));

    maPreviewBitmap = pPrerenderVDev->GetBitmapEx(Point(0, 0), aVDevSize);
@@ -426,24 +426,23 @@ void PrintDialog::PrintPreviewWindow::preparePreviewBitmap()
    pPrerenderVDev->SetDrawMode( nOldDrawMode );
}

PrintDialog::ShowNupOrderWindow::ShowNupOrderWindow( vcl::Window* i_pParent )
    : Window( i_pParent, WB_NOBORDER )
    , mnOrderMode( NupOrderType::LRTB )
PrintDialog::ShowNupOrderWindow::ShowNupOrderWindow()
    : mnOrderMode( NupOrderType::LRTB )
    , mnRows( 1 )
    , mnColumns( 1 )
{
    SetBackground( Wallpaper( GetSettings().GetStyleSettings().GetFieldColor() ) );
}

Size PrintDialog::ShowNupOrderWindow::GetOptimalSize() const
void PrintDialog::ShowNupOrderWindow::SetDrawingArea(weld::DrawingArea* pDrawingArea)
{
    return Size(70, 70);
    Size aSize(70, 70);
    pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
    CustomWidgetController::SetDrawingArea(pDrawingArea);
    SetOutputSizePixel(aSize);
}

void PrintDialog::ShowNupOrderWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& i_rRect)
void PrintDialog::ShowNupOrderWindow::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*i_rRect*/)
{
    Window::Paint(rRenderContext, i_rRect);

    rRenderContext.SetMapMode(MapMode(MapUnit::MapPixel));
    rRenderContext.SetTextColor(rRenderContext.GetSettings().GetStyleSettings().GetFieldTextColor());

@@ -512,103 +511,97 @@ Size const & PrintDialog::getJobPageSize()
    return maFirstPageSize;
}

PrintDialog::PrintDialog(vcl::Window* i_pWindow, const std::shared_ptr<PrinterController>& i_rController)
: ModalDialog(i_pWindow, "PrintDialog", "vcl/ui/printdialog.ui")
, maPController( i_rController )
, maPrintToFileText( VclResId( SV_PRINT_TOFILE_TXT ) )
, maDefPrtText( VclResId( SV_PRINT_DEFPRT_TXT ) )
, maNoPageStr( VclResId( SV_PRINT_NOPAGES ) )
, maNoPreviewStr( VclResId( SV_PRINT_NOPREVIEW ) )
, mnCurPage( 0 )
, mnCachedPages( 0 )
, mbCollateAlwaysOff(false)
, mbShowLayoutFrame( true )
, mbSingleJobs( false )
PrintDialog::PrintDialog(weld::Window* i_pWindow, const std::shared_ptr<PrinterController>& i_rController)
    : GenericDialogController(i_pWindow, "vcl/ui/printdialog.ui", "PrintDialog")
    , maPController( i_rController )
    , mxTabCtrl(m_xBuilder->weld_notebook("tabcontrol"))
    , mxPageLayoutFrame(m_xBuilder->weld_frame("layoutframe"))
    , mxPrinters(m_xBuilder->weld_combo_box("printersbox"))
    , mxStatusTxt(m_xBuilder->weld_label("status"))
    , mxSetupButton(m_xBuilder->weld_button("setup"))
    , mxCopyCountField(m_xBuilder->weld_spin_button("copycount"))
    , mxCollateBox(m_xBuilder->weld_check_button("collate"))
    , mxCollateImage(m_xBuilder->weld_image("collateimage"))
    , mxPaperSidesBox(m_xBuilder->weld_combo_box("sidesbox"))
    , mxReverseOrderBox(m_xBuilder->weld_check_button("reverseorder"))
    , mxOKButton(m_xBuilder->weld_button("ok"))
    , mxCancelButton(m_xBuilder->weld_button("cancel"))
    , mxHelpButton(m_xBuilder->weld_button("help"))
    , mxMoreOptionsBtn(m_xBuilder->weld_button("moreoptionsbtn"))
    , mxBackwardBtn(m_xBuilder->weld_button("backward"))
    , mxForwardBtn(m_xBuilder->weld_button("forward"))
    , mxFirstBtn(m_xBuilder->weld_button("btnFirst"))
    , mxLastBtn(m_xBuilder->weld_button("btnLast"))
    , mxPreviewBox(m_xBuilder->weld_check_button("previewbox"))
    , mxNumPagesText(m_xBuilder->weld_label("totalnumpages"))
    , mxPreview(new PrintPreviewWindow(this))
    , mxPreviewWindow(new weld::CustomWeld(*m_xBuilder, "preview", *mxPreview))
    , mxPageEdit(m_xBuilder->weld_entry("pageedit-nospin"))
    , mxPagesBtn(m_xBuilder->weld_radio_button("pagespersheetbtn"))
    , mxBrochureBtn(m_xBuilder->weld_radio_button("brochure"))
    , mxPagesBoxTitleTxt(m_xBuilder->weld_label("pagespersheettxt"))
    , mxNupPagesBox(m_xBuilder->weld_combo_box("pagespersheetbox"))
    , mxNupNumPagesTxt(m_xBuilder->weld_label("pagestxt"))
    , mxNupColEdt(m_xBuilder->weld_spin_button("pagecols"))
    , mxNupTimesTxt(m_xBuilder->weld_label("by"))
    , mxNupRowsEdt(m_xBuilder->weld_spin_button("pagerows"))
    , mxPageMarginTxt1(m_xBuilder->weld_label("pagemargintxt1"))
    , mxPageMarginEdt(m_xBuilder->weld_metric_spin_button("pagemarginsb", FieldUnit::MM))
    , mxPageMarginTxt2(m_xBuilder->weld_label("pagemargintxt2"))
    , mxSheetMarginTxt1(m_xBuilder->weld_label("sheetmargintxt1"))
    , mxSheetMarginEdt(m_xBuilder->weld_metric_spin_button("sheetmarginsb", FieldUnit::MM))
    , mxSheetMarginTxt2(m_xBuilder->weld_label("sheetmargintxt2"))
    , mxPaperSizeBox(m_xBuilder->weld_combo_box("papersizebox"))
    , mxOrientationBox(m_xBuilder->weld_combo_box("pageorientationbox"))
    , mxNupOrderTxt(m_xBuilder->weld_label("labelorder"))
    , mxNupOrderBox(m_xBuilder->weld_combo_box("orderbox"))
    , mxNupOrder(new ShowNupOrderWindow)
    , mxNupOrderWin(new weld::CustomWeld(*m_xBuilder, "orderpreview", *mxNupOrder))
    , mxBorderCB(m_xBuilder->weld_check_button("bordercb"))
    , mxCustom(m_xBuilder->weld_widget("customcontents"))
    , maPrintToFileText( VclResId( SV_PRINT_TOFILE_TXT ) )
    , maDefPrtText( VclResId( SV_PRINT_DEFPRT_TXT ) )
    , maNoPageStr( VclResId( SV_PRINT_NOPAGES ) )
    , maNoPreviewStr( VclResId( SV_PRINT_NOPREVIEW ) )
    , mnCurPage( 0 )
    , mnCachedPages( 0 )
    , mbCollateAlwaysOff(false)
    , mbShowLayoutFrame( true )
    , mbSingleJobs( false )
{
    get(mpOKButton, "ok");
    get(mpCancelButton, "cancel");
    get(mpHelpButton, "help");
    get(mpMoreOptionsBtn, "moreoptionsbtn");
    get(mpTabCtrl, "tabcontrol");
    get(mpPageLayoutFrame, "layoutframe");
    get(mpForwardBtn, "forward");
    get(mpBackwardBtn, "backward");
    get(mpFirstBtn, "btnFirst");
    get(mpLastBtn, "btnLast");
    get(mpNumPagesText, "totalnumpages");
    get(mpPageEdit, "pageedit-nospin");
    get(mpPreviewWindow, "preview");
    get(mpPreviewBox, "previewbox");
    get(mpPrinters, "printersbox");
    get(mpSetupButton, "setup");
    get(mpStatusTxt, "status");
    get(mpCollateBox, "collate");
    get(mpCollateImage, "collateimage");
    get(mpPaperSidesBox, "sidesbox");
    get(mpReverseOrderBox, "reverseorder");
    get(mpCopyCountField, "copycount");
    get(mpNupOrderWin, "orderpreview");
    get(mpNupPagesBox, "pagespersheetbox");
    get(mpOrientationBox, "pageorientationbox");
    get(mpNupOrderTxt, "labelorder");
    get(mpPaperSizeBox, "papersizebox");
    get(mpNupOrderBox, "orderbox");
    get(mpPagesBtn, "pagespersheetbtn");
    get(mpBrochureBtn, "brochure");
    get(mpPagesBoxTitleTxt, "pagespersheettxt");
    get(mpNupNumPagesTxt, "pagestxt");
    get(mpNupColEdt, "pagecols");
    get(mpNupTimesTxt, "by");
    get(mpNupRowsEdt, "pagerows");
    get(mpPageMarginTxt1, "pagemargintxt1");
    get(mpPageMarginEdt, "pagemarginsb");
    get(mpPageMarginTxt2, "pagemargintxt2");
    get(mpSheetMarginTxt1, "sheetmargintxt1");
    get(mpSheetMarginEdt, "sheetmarginsb");
    get(mpSheetMarginTxt2, "sheetmargintxt2");
    get(mpBorderCB, "bordercb");

    // save printbutton text, gets exchanged occasionally with print to file
    maPrintText = mpOKButton->GetText();
    maPrintText = mxOKButton->get_label();

    // setup preview controls
    mpForwardBtn->SetStyle( mpForwardBtn->GetStyle() | WB_BEVELBUTTON );
    mpBackwardBtn->SetStyle( mpBackwardBtn->GetStyle() | WB_BEVELBUTTON );
    mpFirstBtn->SetStyle( mpFirstBtn->GetStyle() | WB_BEVELBUTTON );
    mpLastBtn->SetStyle( mpLastBtn->GetStyle() | WB_BEVELBUTTON );

    maPageStr = mpNumPagesText->GetText();
    maPageStr = mxNumPagesText->get_label();

    Printer::updatePrinters();

    mpPrinters->InsertEntry( maPrintToFileText );
    mxPrinters->append_text(maPrintToFileText);
    // fill printer listbox
    std::vector< OUString > rQueues( Printer::GetPrinterQueues() );
    std::sort( rQueues.begin(), rQueues.end(), lcl_ListBoxCompare );
    for( const auto& rQueue : rQueues )
    {
        mpPrinters->InsertEntry( rQueue );
        mxPrinters->append_text(rQueue);
    }
    // select current printer
    if( mpPrinters->GetEntryPos( maPController->getPrinter()->GetName() ) != LISTBOX_ENTRY_NOTFOUND )
    {
        mpPrinters->SelectEntry( maPController->getPrinter()->GetName() );
    }
    if (mxPrinters->find_text(maPController->getPrinter()->GetName()) != -1)
        mxPrinters->set_active_text(maPController->getPrinter()->GetName());
    else
    {
        // fall back to last printer
        SettingsConfigItem* pItem = SettingsConfigItem::get();
        OUString aValue( pItem->getValue( "PrintDialog",
                                        "LastPrinter" ) );
        if( mpPrinters->GetEntryPos( aValue ) != LISTBOX_ENTRY_NOTFOUND )
        if (mxPrinters->find_text(aValue) != -1)
        {
            mpPrinters->SelectEntry( aValue );
            mxPrinters->set_active_text(aValue);
            maPController->setPrinter( VclPtrInstance<Printer>( aValue ) );
        }
        else
        {
            // fall back to default printer
            mpPrinters->SelectEntry( Printer::GetDefaultPrinterName() );
            mxPrinters->set_active_text(Printer::GetDefaultPrinterName());
            maPController->setPrinter( VclPtrInstance<Printer>( Printer::GetDefaultPrinterName() ) );
        }
    }
@@ -629,8 +622,8 @@ PrintDialog::PrintDialog(vcl::Window* i_pWindow, const std::shared_ptr<PrinterCo
    setupPaperSidesBox();

    // set initial focus to "Number of copies"
    mpCopyCountField->GrabFocus();
    mpCopyCountField->SetSelection( Selection(0, 0xFFFF) );
    mxCopyCountField->grab_focus();
    mxCopyCountField->select_region(0, -1);

    // setup sizes for N-Up
    Size aNupSize( maPController->getPrinter()->PixelToLogic(
@@ -652,44 +645,45 @@ PrintDialog::PrintDialog(vcl::Window* i_pWindow, const std::shared_ptr<PrinterCo
    setupOptionalUI();

    // hide layout frame if unwanted
    mpPageLayoutFrame->Show( mbShowLayoutFrame );
    mxPageLayoutFrame->set_visible(mbShowLayoutFrame);

    // restore settings from last run
    readFromSettings();

    // setup click hdl
    mpOKButton->SetClickHdl(LINK(this, PrintDialog, ClickHdl));
    mpCancelButton->SetClickHdl(LINK(this, PrintDialog, ClickHdl));
    mpHelpButton->SetClickHdl(LINK(this, PrintDialog, ClickHdl));
    mpSetupButton->SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
    mpMoreOptionsBtn->SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
    mpBackwardBtn->SetClickHdl(LINK(this, PrintDialog, ClickHdl));
    mpForwardBtn->SetClickHdl(LINK(this, PrintDialog, ClickHdl));
    mpFirstBtn->SetClickHdl(LINK(this, PrintDialog, ClickHdl));
    mpLastBtn->SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
    mpPreviewBox->SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
    mpBorderCB->SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
    mxOKButton->connect_clicked(LINK(this, PrintDialog, ClickHdl));
    mxCancelButton->connect_clicked(LINK(this, PrintDialog, ClickHdl));
    mxHelpButton->connect_clicked(LINK(this, PrintDialog, ClickHdl));
    mxSetupButton->connect_clicked( LINK( this, PrintDialog, ClickHdl ) );
    mxMoreOptionsBtn->connect_clicked( LINK( this, PrintDialog, ClickHdl ) );
    mxBackwardBtn->connect_clicked(LINK(this, PrintDialog, ClickHdl));
    mxForwardBtn->connect_clicked(LINK(this, PrintDialog, ClickHdl));
    mxFirstBtn->connect_clicked(LINK(this, PrintDialog, ClickHdl));
    mxLastBtn->connect_clicked( LINK( this, PrintDialog, ClickHdl ) );
    mxPreviewBox->connect_clicked( LINK( this, PrintDialog, ClickHdl ) );
    mxBorderCB->connect_clicked( LINK( this, PrintDialog, ClickHdl ) );

    // setup toggle hdl
    mpReverseOrderBox->SetToggleHdl( LINK( this, PrintDialog, ToggleHdl ) );
    mpCollateBox->SetToggleHdl( LINK( this, PrintDialog, ToggleHdl ) );
    mpPagesBtn->SetToggleHdl( LINK( this, PrintDialog, ToggleRadioHdl ) );
    mxReverseOrderBox->connect_toggled( LINK( this, PrintDialog, ToggleHdl ) );
    mxCollateBox->connect_toggled( LINK( this, PrintDialog, ToggleHdl ) );
    mxPagesBtn->connect_toggled( LINK( this, PrintDialog, ToggleHdl ) );

    // setup select hdl
    mpPrinters->SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) );
    mpPaperSidesBox->SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) );
    mpNupPagesBox->SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) );
    mpOrientationBox->SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) );
    mpNupOrderBox->SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) );
    mpPaperSizeBox->SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) );
    mxPrinters->connect_changed( LINK( this, PrintDialog, SelectHdl ) );
    mxPaperSidesBox->connect_changed( LINK( this, PrintDialog, SelectHdl ) );
    mxNupPagesBox->connect_changed( LINK( this, PrintDialog, SelectHdl ) );
    mxOrientationBox->connect_changed( LINK( this, PrintDialog, SelectHdl ) );
    mxNupOrderBox->connect_changed( LINK( this, PrintDialog, SelectHdl ) );
    mxPaperSizeBox->connect_changed( LINK( this, PrintDialog, SelectHdl ) );

    // setup modify hdl
    mpPageEdit->SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) );
    mpCopyCountField->SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) );
    mpNupColEdt->SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) );
    mpNupRowsEdt->SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) );
    mpPageMarginEdt->SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) );
    mpSheetMarginEdt->SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) );
    mxPageEdit->connect_activate( LINK( this, PrintDialog, ActivateHdl ) );
    mxPageEdit->connect_focus_out( LINK( this, PrintDialog, FocusOutHdl ) );
    mxCopyCountField->connect_value_changed( LINK( this, PrintDialog, SpinModifyHdl ) );
    mxNupColEdt->connect_value_changed( LINK( this, PrintDialog, SpinModifyHdl ) );
    mxNupRowsEdt->connect_value_changed( LINK( this, PrintDialog, SpinModifyHdl ) );
    mxPageMarginEdt->connect_value_changed( LINK( this, PrintDialog, MetricSpinModifyHdl ) );
    mxSheetMarginEdt->connect_value_changed( LINK( this, PrintDialog, MetricSpinModifyHdl ) );

    updateNupFromPages();
}
@@ -697,59 +691,6 @@ PrintDialog::PrintDialog(vcl::Window* i_pWindow, const std::shared_ptr<PrinterCo

PrintDialog::~PrintDialog()
{
    disposeOnce();
}

void PrintDialog::dispose()
{
    mpCustomOptionsUIBuilder.reset();
    mpTabCtrl.clear();
    mpPageLayoutFrame.clear();
    mpPreviewWindow.clear();
    mpPageEdit.clear();
    mpNumPagesText.clear();
    mpBackwardBtn.clear();
    mpForwardBtn.clear();
    mpFirstBtn.clear();
    mpLastBtn.clear();
    mpPreviewBox.clear();
    mpOKButton.clear();
    mpCancelButton.clear();
    mpHelpButton.clear();
    mpMoreOptionsBtn.clear();
    maPController.reset();
    maControlToPropertyMap.clear();
    maControlToNumValMap.clear();
    mpPrinters.clear();
    mpStatusTxt.clear();
    mpSetupButton.clear();
    mpCopyCountField.clear();
    mpCollateBox.clear();
    mpCollateImage.clear();
    mpPaperSidesBox.clear();
    mpReverseOrderBox.clear();
    mpPagesBtn.clear();
    mpBrochureBtn.clear();
    mpPagesBoxTitleTxt.clear();
    mpNupPagesBox.clear();
    mpNupNumPagesTxt.clear();
    mpNupColEdt.clear();
    mpNupTimesTxt.clear();
    mpNupRowsEdt.clear();
    mpPageMarginTxt1.clear();
    mpPageMarginEdt.clear();
    mpPageMarginTxt2.clear();
    mpSheetMarginTxt1.clear();
    mpSheetMarginEdt.clear();
    mpSheetMarginTxt2.clear();
    mpPaperSizeBox.clear();
    mpOrientationBox.clear();
    mpNupOrderBox.clear();
    mpNupOrderWin.clear();
    mpNupOrderTxt.clear();
    mpBorderCB.clear();
    mxMoreOptionsDlg.reset();
    ModalDialog::dispose();
}

void PrintDialog::setupPaperSidesBox()
@@ -758,13 +699,13 @@ void PrintDialog::setupPaperSidesBox()

    if ( eDuplex == DuplexMode::Unknown || isPrintToFile() )
    {
        mpPaperSidesBox->SelectEntryPos( 0 );
        mpPaperSidesBox->Enable( false );
        mxPaperSidesBox->set_active( 0 );
        mxPaperSidesBox->set_sensitive( false );
    }
    else
    {
        mpPaperSidesBox->SelectEntryPos( static_cast<sal_Int32>(eDuplex) - 1 );
        mpPaperSidesBox->Enable( true );
        mxPaperSidesBox->set_active( static_cast<sal_Int32>(eDuplex) - 1 );
        mxPaperSidesBox->set_sensitive( true );
    }
}

@@ -775,23 +716,23 @@ void PrintDialog::storeToSettings()
    pItem->setValue( "PrintDialog",
                     "LastPrinter",
                      isPrintToFile() ? Printer::GetDefaultPrinterName()
                                      : mpPrinters->GetSelectedEntry() );
                                      : mxPrinters->get_active_text() );

    pItem->setValue( "PrintDialog",
                     "LastPage",
                     mpTabCtrl->GetPageText( mpTabCtrl->GetCurPageId() ) );
                     mxTabCtrl->get_tab_label_text(mxTabCtrl->get_current_page_ident()));

    pItem->setValue( "PrintDialog",
                     "WindowState",
                     OStringToOUString( GetWindowState(), RTL_TEXTENCODING_UTF8 ) );
                     OStringToOUString(m_xDialog->get_window_state(WindowStateMask::All), RTL_TEXTENCODING_UTF8) );

    pItem->setValue( "PrintDialog",
                     "CopyCount",
                     mpCopyCountField->GetText() );
                     mxCopyCountField->get_text() );

    pItem->setValue( "PrintDialog",
                     "Collate",
                     mpCollateBox->IsChecked() ? OUString("true") :
                     mxCollateBox->get_active() ? OUString("true") :
                                                 OUString("false") );

    pItem->setValue( "PrintDialog",
@@ -814,14 +755,13 @@ void PrintDialog::readFromSettings()
    // read last selected tab page; if it exists, activate it
    OUString aValue = pItem->getValue( "PrintDialog",
                              "LastPage" );
    sal_uInt16 nCount = mpTabCtrl->GetPageCount();
    for( sal_uInt16 i = 0; i < nCount; i++ )
    sal_uInt16 nCount = mxTabCtrl->get_n_pages();
    for (sal_uInt16 i = 0; i < nCount; ++i)
    {
        sal_uInt16 nPageId = mpTabCtrl->GetPageId( i );

        if( aValue == mpTabCtrl->GetPageText( nPageId ) )
        OString sPageId = mxTabCtrl->get_page_ident(i);
        if (aValue == mxTabCtrl->get_tab_label_text(sPageId))
        {
            mpTabCtrl->SelectTabPage( nPageId );
            mxTabCtrl->set_current_page(sPageId);
            break;
        }
    }
@@ -829,8 +769,8 @@ void PrintDialog::readFromSettings()
    // persistent window state
    aValue = pItem->getValue( "PrintDialog",
                              "WindowState" );
    if( !aValue.isEmpty() )
        SetWindowState( OUStringToOString( aValue, RTL_TEXTENCODING_UTF8 ) );
    if (!aValue.isEmpty())
        m_xDialog->set_window_state(OUStringToOString(aValue, RTL_TEXTENCODING_UTF8));

    // collate
    aValue = pItem->getValue( "PrintDialog",
@@ -838,15 +778,15 @@ void PrintDialog::readFromSettings()
    if( aValue.equalsIgnoreAsciiCase("alwaysoff") )
    {
        mbCollateAlwaysOff = true;
        mpCollateBox->Check( false );
        mpCollateBox->Enable( false );
        mxCollateBox->set_active( false );
        mxCollateBox->set_sensitive( false );
    }
    else
    {
        mbCollateAlwaysOff = false;
        aValue = pItem->getValue( "PrintDialog",
                                  "Collate" );
        mpCollateBox->Check( aValue.equalsIgnoreAsciiCase("true") );
        mxCollateBox->set_active( aValue.equalsIgnoreAsciiCase("true") );
    }

    // collate single jobs
@@ -861,22 +801,22 @@ void PrintDialog::readFromSettings()
    aValue = pItem->getValue( "PrintDialog",
                              "HasPreview" );
    if ( aValue.equalsIgnoreAsciiCase("false") )
        mpPreviewBox->Check( false );
        mxPreviewBox->set_active( false );
    else
        mpPreviewBox->Check( true );
        mxPreviewBox->set_active( true );

}

void PrintDialog::setPaperSizes()
{
    mpPaperSizeBox->Clear();
    mxPaperSizeBox->clear();

    VclPtr<Printer> aPrt( maPController->getPrinter() );
    mePaper = aPrt->GetPaper();

    if ( isPrintToFile() )
    {
        mpPaperSizeBox->Enable( false );
        mxPaperSizeBox->set_sensitive( false );
    }
    else
    {
@@ -886,7 +826,7 @@ void PrintDialog::setPaperSizes()
            aInfo.doSloppyFit();
            Paper ePaper = aInfo.getPaper();

            const LocaleDataWrapper& rLocWrap( GetSettings().GetLocaleDataWrapper() );
            const LocaleDataWrapper& rLocWrap(Application::GetSettings().GetLocaleDataWrapper());
            MapUnit eUnit = MapUnit::MapMM;
            int nDigits = 0;
            if( rLocWrap.getMeasurementSystemEnum() == MeasurementSystem::US )
@@ -895,45 +835,45 @@ void PrintDialog::setPaperSizes()
                nDigits = 2;
            }
            Size aSize = aPrt->GetPaperSize( nPaper );
            Size aLogicPaperSize( LogicToLogic( aSize, MapMode( MapUnit::Map100thMM ), MapMode( eUnit ) ) );
            Size aLogicPaperSize( OutputDevice::LogicToLogic( aSize, MapMode( MapUnit::Map100thMM ), MapMode( eUnit ) ) );

            OUString aWidth( rLocWrap.getNum( aLogicPaperSize.Width(), nDigits ) );
            OUString aHeight( rLocWrap.getNum( aLogicPaperSize.Height(), nDigits ) );
            OUString aUnit = eUnit == MapUnit::MapMM ? OUString("mm") : OUString("in");
            OUString aPaperName = Printer::GetPaperName( ePaper ) + " " + aWidth + aUnit + " x " + aHeight + aUnit;

            mpPaperSizeBox->InsertEntry( aPaperName );
            mxPaperSizeBox->append_text(aPaperName);

            if ( ePaper == mePaper )
                mpPaperSizeBox->SelectEntryPos( nPaper );
                mxPaperSizeBox->set_active( nPaper );
        }

        mpPaperSizeBox->Enable( true );
        mxPaperSizeBox->set_sensitive( true );
    }
}

void PrintDialog::updatePrinterText()
{
    const OUString aDefPrt( Printer::GetDefaultPrinterName() );
    const QueueInfo* pInfo = Printer::GetQueueInfo( mpPrinters->GetSelectedEntry(), true );
    const QueueInfo* pInfo = Printer::GetQueueInfo( mxPrinters->get_active_text(), true );
    if( pInfo )
    {
        // FIXME: status text
        OUString aStatus;
        if( aDefPrt == pInfo->GetPrinterName() )
            aStatus = maDefPrtText;
        mpStatusTxt->SetText( aStatus );
        mxStatusTxt->set_label( aStatus );
    }
    else
    {
        mpStatusTxt->SetText( OUString() );
        mxStatusTxt->set_label( OUString() );
    }
}

void PrintDialog::setPreviewText()
{
    OUString aNewText( maPageStr.replaceFirst( "%n", OUString::number( mnCachedPages ) ) );
    mpNumPagesText->SetText( aNewText );
    mxNumPagesText->set_label( aNewText );
}

void PrintDialog::preparePreview( bool i_bMayUseCache )
@@ -946,26 +886,23 @@ void PrintDialog::preparePreview( bool i_bMayUseCache )
    sal_Int32 nPages = maPController->getFilteredPageCount();
    mnCachedPages = nPages;

    mpPageEdit->SetMin( 1 );
    mpPageEdit->SetMax( nPages );

    setPreviewText();

    if ( !hasPreview() )
    {
        mpPreviewWindow->setPreview( aMtf, aCurPageSize,
        mxPreview->setPreview( aMtf, aCurPageSize,
                            Printer::GetPaperName( mePaper ),
                            maNoPreviewStr,
                            aPrt->GetDPIX(), aPrt->GetDPIY(),
                            aPrt->GetPrinterOptions().IsConvertToGreyscales()
                            );

        mpForwardBtn->Enable( false );
        mpBackwardBtn->Enable( false );
        mpFirstBtn->Enable( false );
        mpLastBtn->Enable( false );
        mxForwardBtn->set_sensitive( false );
        mxBackwardBtn->set_sensitive( false );
        mxFirstBtn->set_sensitive( false );
        mxLastBtn->set_sensitive( false );

        mpPageEdit->Enable( false );
        mxPageEdit->set_sensitive( false );

        return;
    }
@@ -988,18 +925,18 @@ void PrintDialog::preparePreview( bool i_bMayUseCache )
        }
    }

    mpPreviewWindow->setPreview( aMtf, aCurPageSize,
    mxPreview->setPreview( aMtf, aCurPageSize,
                                Printer::GetPaperName( mePaper ),
                                nPages > 0 ? OUString() : maNoPageStr,
                                aPrt->GetDPIX(), aPrt->GetDPIY(),
                                aPrt->GetPrinterOptions().IsConvertToGreyscales()
                               );

    mpForwardBtn->Enable( mnCurPage < nPages-1 );
    mpBackwardBtn->Enable( mnCurPage != 0 );
    mpFirstBtn->Enable( mnCurPage != 0 );
    mpLastBtn->Enable( mnCurPage < nPages-1 );
    mpPageEdit->Enable( nPages > 1 );
    mxForwardBtn->set_sensitive( mnCurPage < nPages-1 );
    mxBackwardBtn->set_sensitive( mnCurPage != 0 );
    mxFirstBtn->set_sensitive( mnCurPage != 0 );
    mxLastBtn->set_sensitive( mnCurPage < nPages-1 );
    mxPageEdit->set_sensitive( nPages > 1 );
}

void PrintDialog::updateOrientationBox( const bool bAutomatic )
@@ -1007,17 +944,17 @@ void PrintDialog::updateOrientationBox( const bool bAutomatic )
    if ( !bAutomatic )
    {
        Orientation eOrientation = maPController->getPrinter()->GetOrientation();
        mpOrientationBox->SelectEntryPos( static_cast<sal_Int32>(eOrientation) + 1 );
        mxOrientationBox->set_active( static_cast<sal_Int32>(eOrientation) + 1 );
    }
    else if ( hasOrientationChanged() )
    {
        mpOrientationBox->SelectEntryPos( ORIENTATION_AUTOMATIC );
        mxOrientationBox->set_active( ORIENTATION_AUTOMATIC );
    }
}

bool PrintDialog::hasOrientationChanged() const
{
    const int nOrientation = mpOrientationBox->GetSelectedEntryPos();
    const int nOrientation = mxOrientationBox->get_active();
    const Orientation eOrientation = maPController->getPrinter()->GetOrientation();

    return (nOrientation == ORIENTATION_LANDSCAPE && eOrientation == Orientation::Portrait)
@@ -1057,23 +994,18 @@ void PrintDialog::setPaperOrientation( Orientation eOrientation )

void PrintDialog::checkControlDependencies()
{

    if( mpCopyCountField->GetValue() > 1 )
        mpCollateBox->Enable( !mbCollateAlwaysOff );
    if (mxCopyCountField->get_value() > 1)
        mxCollateBox->set_sensitive( !mbCollateAlwaysOff );
    else
        mpCollateBox->Enable( false );
        mxCollateBox->set_sensitive( false );

    Image aImg(StockImage::Yes, mpCollateBox->IsChecked() ? OUString(SV_PRINT_COLLATE_BMP) : OUString(SV_PRINT_NOCOLLATE_BMP));
    OUString aImg(mxCollateBox->get_active() ? OUString(SV_PRINT_COLLATE_BMP) : OUString(SV_PRINT_NOCOLLATE_BMP));

    Size aImgSize( aImg.GetSizePixel() );

    // adjust size of image
    mpCollateImage->SetSizePixel( aImgSize );
    mpCollateImage->SetImage( aImg );
    mxCollateImage->set_from_icon_name(aImg);

    // enable setup button only for printers that can be setup
    bool bHaveSetup = maPController->getPrinter()->HasSupport( PrinterSupport::SetupDialog );
    mpSetupButton->Enable(bHaveSetup);
    mxSetupButton->set_sensitive(bHaveSetup);
}

void PrintDialog::checkOptionalControlDependencies()
@@ -1082,7 +1014,7 @@ void PrintDialog::checkOptionalControlDependencies()
    {
        bool bShouldbeEnabled = maPController->isUIOptionEnabled( rEntry.second );

        if( bShouldbeEnabled && dynamic_cast<RadioButton*>(rEntry.first.get()) )
        if (bShouldbeEnabled && dynamic_cast<weld::RadioButton*>(rEntry.first))
        {
            auto r_it = maControlToNumValMap.find( rEntry.first );
            if( r_it != maControlToNumValMap.end() )
@@ -1091,21 +1023,21 @@ void PrintDialog::checkOptionalControlDependencies()
            }
        }

        bool bIsEnabled = rEntry.first->IsEnabled();
        bool bIsEnabled = rEntry.first->get_sensitive();
        // Enable does not do a change check first, so can be less cheap than expected
        if( bShouldbeEnabled != bIsEnabled )
            rEntry.first->Enable( bShouldbeEnabled );
        if (bShouldbeEnabled != bIsEnabled)
            rEntry.first->set_sensitive( bShouldbeEnabled );
    }
}

void PrintDialog::initFromMultiPageSetup( const vcl::PrinterController::MultiPageSetup& i_rMPS )
{
    mpNupOrderWin->Show();
    mpPagesBtn->Check();
    mpBrochureBtn->Show( false );
    mxNupOrderWin->show();
    mxPagesBtn->set_active(true);
    mxBrochureBtn->hide();

    // setup field units for metric fields
    const LocaleDataWrapper& rLocWrap( mpPageMarginEdt->GetLocaleDataWrapper() );
    const LocaleDataWrapper& rLocWrap(Application::GetSettings().GetLocaleDataWrapper());
    FieldUnit eUnit = FieldUnit::MM;
    sal_uInt16 nDigits = 0;
    if( rLocWrap.getMeasurementSystemEnum() == MeasurementSystem::US )
@@ -1114,33 +1046,33 @@ void PrintDialog::initFromMultiPageSetup( const vcl::PrinterController::MultiPag
        nDigits = 2;
    }
    // set units
    mpPageMarginEdt->SetUnit( eUnit );
    mpSheetMarginEdt->SetUnit( eUnit );
    mxPageMarginEdt->set_unit( eUnit );
    mxSheetMarginEdt->set_unit( eUnit );

    // set precision
    mpPageMarginEdt->SetDecimalDigits( nDigits );
    mpSheetMarginEdt->SetDecimalDigits( nDigits );
    mxPageMarginEdt->set_digits( nDigits );
    mxSheetMarginEdt->set_digits( nDigits );

    mpSheetMarginEdt->SetValue( mpSheetMarginEdt->Normalize( i_rMPS.nLeftMargin ), FieldUnit::MM_100TH );
    mpPageMarginEdt->SetValue( mpPageMarginEdt->Normalize( i_rMPS.nHorizontalSpacing ), FieldUnit::MM_100TH );
    mpBorderCB->Check( i_rMPS.bDrawBorder );
    mpNupRowsEdt->SetValue( i_rMPS.nRows );
    mpNupColEdt->SetValue( i_rMPS.nColumns );
    mpNupOrderBox->SelectEntryPos( static_cast<sal_Int32>(i_rMPS.nOrder) );
    mxSheetMarginEdt->set_value( mxSheetMarginEdt->normalize( i_rMPS.nLeftMargin ), FieldUnit::MM_100TH );
    mxPageMarginEdt->set_value( mxPageMarginEdt->normalize( i_rMPS.nHorizontalSpacing ), FieldUnit::MM_100TH );
    mxBorderCB->set_active( i_rMPS.bDrawBorder );
    mxNupRowsEdt->set_value( i_rMPS.nRows );
    mxNupColEdt->set_value( i_rMPS.nColumns );
    mxNupOrderBox->set_active( static_cast<sal_Int32>(i_rMPS.nOrder) );
    if( i_rMPS.nRows != 1 || i_rMPS.nColumns != 1 )
    {
        mpNupPagesBox->SelectEntryPos( mpNupPagesBox->GetEntryCount()-1 );
        mxNupPagesBox->set_active( mxNupPagesBox->get_count()-1 );
        showAdvancedControls( true );
        mpNupOrderWin->setValues( i_rMPS.nOrder, i_rMPS.nColumns, i_rMPS.nRows );
        mxNupOrder->setValues( i_rMPS.nOrder, i_rMPS.nColumns, i_rMPS.nRows );
    }
}

void PrintDialog::updateNup( bool i_bMayUseCache )
{
    int nRows         = int(mpNupRowsEdt->GetValue());
    int nCols         = int(mpNupColEdt->GetValue());
    long nPageMargin  = mpPageMarginEdt->Denormalize(mpPageMarginEdt->GetValue( FieldUnit::MM_100TH ));
    long nSheetMargin = mpSheetMarginEdt->Denormalize(mpSheetMarginEdt->GetValue( FieldUnit::MM_100TH ));
    int nRows         = mxNupRowsEdt->get_value();
    int nCols         = mxNupColEdt->get_value();
    long nPageMargin  = mxPageMarginEdt->denormalize(mxPageMarginEdt->get_value( FieldUnit::MM_100TH ));
    long nSheetMargin = mxSheetMarginEdt->denormalize(mxSheetMarginEdt->get_value( FieldUnit::MM_100TH ));

    PrinterController::MultiPageSetup aMPS;
    aMPS.nRows         = nRows;
@@ -1153,11 +1085,11 @@ void PrintDialog::updateNup( bool i_bMayUseCache )
    aMPS.nHorizontalSpacing =
    aMPS.nVerticalSpacing   = nPageMargin;

    aMPS.bDrawBorder        = mpBorderCB->IsChecked();
    aMPS.bDrawBorder        = mxBorderCB->get_active();

    aMPS.nOrder = static_cast<NupOrderType>(mpNupOrderBox->GetSelectedEntryPos());
    aMPS.nOrder = static_cast<NupOrderType>(mxNupOrderBox->get_active());

    int nOrientationMode = mpOrientationBox->GetSelectedEntryPos();
    int nOrientationMode = mxOrientationBox->get_active();
    if( nOrientationMode == ORIENTATION_LANDSCAPE )
        aMPS.aPaperSize = maNupLandscapeSize;
    else if( nOrientationMode == ORIENTATION_PORTRAIT )
@@ -1183,18 +1115,18 @@ void PrintDialog::updateNup( bool i_bMayUseCache )

    maPController->setMultipage( aMPS );

    mpNupOrderWin->setValues( aMPS.nOrder, nCols, nRows );
    mxNupOrder->setValues( aMPS.nOrder, nCols, nRows );

    preparePreview( i_bMayUseCache );
}

void PrintDialog::updateNupFromPages( bool i_bMayUseCache )
{
    sal_IntPtr nPages = sal_IntPtr(mpNupPagesBox->GetSelectedEntryData());
    int nRows   = int(mpNupRowsEdt->GetValue());
    int nCols   = int(mpNupColEdt->GetValue());
    long nPageMargin  = mpPageMarginEdt->Denormalize(mpPageMarginEdt->GetValue( FieldUnit::MM_100TH ));
    long nSheetMargin = mpSheetMarginEdt->Denormalize(mpSheetMarginEdt->GetValue( FieldUnit::MM_100TH ));
    int nPages = mxNupPagesBox->get_active_id().toInt32();
    int nRows   = mxNupRowsEdt->get_value();
    int nCols   = mxNupColEdt->get_value();
    long nPageMargin  = mxPageMarginEdt->denormalize(mxPageMarginEdt->get_value( FieldUnit::MM_100TH ));
    long nSheetMargin = mxSheetMarginEdt->denormalize(mxSheetMarginEdt->get_value( FieldUnit::MM_100TH ));
    bool bCustom = false;

    if( nPages == 1 )
@@ -1258,8 +1190,8 @@ void PrintDialog::updateNupFromPages( bool i_bMayUseCache )
        if( nSheetMargin > nVertMax )
            nSheetMargin = nVertMax;

        mpSheetMarginEdt->SetMax(
                  mpSheetMarginEdt->Normalize(
        mxSheetMarginEdt->set_max(
                  mxSheetMarginEdt->normalize(
                           std::min(nHorzMax, nVertMax) ), FieldUnit::MM_100TH );

        // maximum page distance
@@ -1275,15 +1207,15 @@ void PrintDialog::updateNupFromPages( bool i_bMayUseCache )
        if( nPageMargin > nVertMax )
            nPageMargin = nVertMax;

        mpPageMarginEdt->SetMax(
                 mpSheetMarginEdt->Normalize(
        mxPageMarginEdt->set_max(
                 mxSheetMarginEdt->normalize(
                           std::min(nHorzMax, nVertMax ) ), FieldUnit::MM_100TH );
    }

    mpNupRowsEdt->SetValue( nRows );
    mpNupColEdt->SetValue( nCols );
    mpPageMarginEdt->SetValue( mpPageMarginEdt->Normalize( nPageMargin ), FieldUnit::MM_100TH );
    mpSheetMarginEdt->SetValue( mpSheetMarginEdt->Normalize( nSheetMargin ), FieldUnit::MM_100TH );
    mxNupRowsEdt->set_value( nRows );
    mxNupColEdt->set_value( nCols );
    mxPageMarginEdt->set_value( mxPageMarginEdt->normalize( nPageMargin ), FieldUnit::MM_100TH );
    mxSheetMarginEdt->set_value( mxSheetMarginEdt->normalize( nSheetMargin ), FieldUnit::MM_100TH );

    showAdvancedControls( bCustom );
    updateNup( i_bMayUseCache );
@@ -1291,51 +1223,51 @@ void PrintDialog::updateNupFromPages( bool i_bMayUseCache )

void PrintDialog::enableNupControls( bool bEnable )
{
    mpNupPagesBox->Enable( bEnable );
    mpNupNumPagesTxt->Enable( bEnable );
    mpNupColEdt->Enable( bEnable );
    mpNupTimesTxt->Enable( bEnable );
    mpNupRowsEdt->Enable( bEnable );
    mpPageMarginTxt1->Enable( bEnable );
    mpPageMarginEdt->Enable( bEnable );
    mpPageMarginTxt2->Enable( bEnable );
    mpSheetMarginTxt1->Enable( bEnable );
    mpSheetMarginEdt->Enable( bEnable );
    mpSheetMarginTxt2->Enable( bEnable );
    mpNupOrderTxt->Enable( bEnable );
    mpNupOrderBox->Enable( bEnable );
    mpNupOrderWin->Enable( bEnable );
    mpBorderCB->Enable( bEnable );
    mxNupPagesBox->set_sensitive( bEnable );
    mxNupNumPagesTxt->set_sensitive( bEnable );
    mxNupColEdt->set_sensitive( bEnable );
    mxNupTimesTxt->set_sensitive( bEnable );
    mxNupRowsEdt->set_sensitive( bEnable );
    mxPageMarginTxt1->set_sensitive( bEnable );
    mxPageMarginEdt->set_sensitive( bEnable );
    mxPageMarginTxt2->set_sensitive( bEnable );
    mxSheetMarginTxt1->set_sensitive( bEnable );
    mxSheetMarginEdt->set_sensitive( bEnable );
    mxSheetMarginTxt2->set_sensitive( bEnable );
    mxNupOrderTxt->set_sensitive( bEnable );
    mxNupOrderBox->set_sensitive( bEnable );
    mxNupOrderWin->set_sensitive( bEnable );
    mxBorderCB->set_sensitive( bEnable );
}

void PrintDialog::showAdvancedControls( bool i_bShow )
{
    mpNupNumPagesTxt->Show( i_bShow );
    mpNupColEdt->Show( i_bShow );
    mpNupTimesTxt->Show( i_bShow );
    mpNupRowsEdt->Show( i_bShow );
    mpPageMarginTxt1->Show( i_bShow );
    mpPageMarginEdt->Show( i_bShow );
    mpPageMarginTxt2->Show( i_bShow );
    mpSheetMarginTxt1->Show( i_bShow );
    mpSheetMarginEdt->Show( i_bShow );
    mpSheetMarginTxt2->Show( i_bShow );
    mxNupNumPagesTxt->set_visible( i_bShow );
    mxNupColEdt->set_visible( i_bShow );
    mxNupTimesTxt->set_visible( i_bShow );
    mxNupRowsEdt->set_visible( i_bShow );
    mxPageMarginTxt1->set_visible( i_bShow );
    mxPageMarginEdt->set_visible( i_bShow );
    mxPageMarginTxt2->set_visible( i_bShow );
    mxSheetMarginTxt1->set_visible( i_bShow );
    mxSheetMarginEdt->set_visible( i_bShow );
    mxSheetMarginTxt2->set_visible( i_bShow );
}

namespace
{
    void setHelpId( vcl::Window* i_pWindow, const Sequence< OUString >& i_rHelpIds, sal_Int32 i_nIndex )
    void setHelpId( weld::Widget* i_pWindow, const Sequence< OUString >& i_rHelpIds, sal_Int32 i_nIndex )
    {
        if( i_nIndex >= 0 && i_nIndex < i_rHelpIds.getLength() )
            i_pWindow->SetHelpId( OUStringToOString( i_rHelpIds.getConstArray()[i_nIndex], RTL_TEXTENCODING_UTF8 ) );
            i_pWindow->set_help_id( OUStringToOString( i_rHelpIds.getConstArray()[i_nIndex], RTL_TEXTENCODING_UTF8 ) );
    }

    void setHelpText( vcl::Window* i_pWindow, const Sequence< OUString >& i_rHelpTexts, sal_Int32 i_nIndex )
    void setHelpText( weld::Widget* i_pWindow, const Sequence< OUString >& i_rHelpTexts, sal_Int32 i_nIndex )
    {
        // without a help text set and the correct smartID,
        // help texts will be retrieved from the online help system
        if( i_nIndex >= 0 && i_nIndex < i_rHelpTexts.getLength() )
            i_pWindow->SetHelpText( i_rHelpTexts.getConstArray()[i_nIndex] );
            i_pWindow->set_tooltip_text(i_rHelpTexts.getConstArray()[i_nIndex]);
    }
}

@@ -1348,12 +1280,9 @@ void PrintDialog::setupOptionalUI()
        {
            OUString sOptionsUIFile;
            rOption.Value >>= sOptionsUIFile;

            vcl::Window *pCustom = get<vcl::Window>("customcontents");

            mpCustomOptionsUIBuilder.reset(new VclBuilder(pCustom, getUIRootDir(), sOptionsUIFile));
            vcl::Window *pWindow = mpCustomOptionsUIBuilder->get_widget_root();
            pWindow->Show();
            mxCustomOptionsUIBuilder.reset(Application::CreateBuilder(mxCustom.get(), sOptionsUIFile));
            std::unique_ptr<weld::Container> xWindow = mxCustomOptionsUIBuilder->weld_container("box");
            xWindow->show();
            continue;
        }

@@ -1458,96 +1387,110 @@ void PrintDialog::setupOptionalUI()
            }
        }

        if (aCtrlType == "Group" && !aID.isEmpty())
        if (aCtrlType == "Group")
        {
            TabPage *pPage = get<TabPage>(aID);
            if (!pPage && mpCustomOptionsUIBuilder)
                pPage = mpCustomOptionsUIBuilder->get<TabPage>(aID);
            aID = "custom";

            weld::Container* pPage = mxTabCtrl->get_page(aID);
            if (!pPage)
                continue;

            sal_uInt16 nPageId = mpTabCtrl->GetPageId(*pPage);

            mpTabCtrl->SetPageText(nPageId, aText);
            mxTabCtrl->set_tab_label_text(aID, aText);

            // set help id
            if (aHelpIds.hasElements())
                mpTabCtrl->SetHelpId(nPageId, OUStringToOString(aHelpIds.getConstArray()[0], RTL_TEXTENCODING_UTF8));
                pPage->set_help_id(OUStringToOString(aHelpIds.getConstArray()[0], RTL_TEXTENCODING_UTF8));

            // set help text
            if (aHelpTexts.hasElements())
                mpTabCtrl->SetHelpText(nPageId, aHelpTexts.getConstArray()[0]);
                pPage->set_tooltip_text(aHelpTexts.getConstArray()[0]);

            pPage->Show();
            pPage->show();
        }
        else if (aCtrlType == "Subgroup" && !aID.isEmpty())
        {
            vcl::Window *pFrame = get<vcl::Window>(aID);
            if (!pFrame && mpCustomOptionsUIBuilder)
                pFrame = mpCustomOptionsUIBuilder->get<vcl::Window>(aID);
            std::unique_ptr<weld::Widget> xWidget;
            // since 'New Print Dialog Design' fromwhich in calc is not a frame anymore
            if (aID == "fromwhich")
            {
                std::unique_ptr<weld::Label> xLabel = m_xBuilder->weld_label(aID);
                xLabel->set_label(aText);
                xWidget = std::move(xLabel);
            }
            else
            {
                std::unique_ptr<weld::Frame> xFrame = m_xBuilder->weld_frame(aID);
                if (!xFrame && mxCustomOptionsUIBuilder)
                    xFrame = mxCustomOptionsUIBuilder->weld_frame(aID);
                if (xFrame)
                {
                    xFrame->set_label(aText);
                    xWidget = std::move(xFrame);
                }
            }

            if (!pFrame)
            if (!xWidget)
                continue;

            pFrame->SetText(aText);

            // set help id
            setHelpId(pFrame, aHelpIds, 0);
            setHelpId(xWidget.get(), aHelpIds, 0);
            // set help text
            setHelpText(pFrame, aHelpTexts, 0);
            setHelpText(xWidget.get(), aHelpTexts, 0);

            pFrame->Show();
            xWidget->show();
        }
        // EVIL
        else if( aCtrlType == "Bool" && aGroupingHint == "LayoutPage" && aPropertyName == "PrintProspect" )
        {
            mpBrochureBtn->SetText( aText );
            mpBrochureBtn->Show();
            mxBrochureBtn->set_label(aText);
            mxBrochureBtn->show();

            bool bVal = false;
            PropertyValue* pVal = maPController->getValue( aPropertyName );
            if( pVal )
                pVal->Value >>= bVal;
            mpBrochureBtn->Check( bVal );
            mpBrochureBtn->Enable( maPController->isUIOptionEnabled( aPropertyName ) && pVal != nullptr );
            mpBrochureBtn->SetToggleHdl( LINK( this, PrintDialog, ToggleRadioHdl ) );
            mxBrochureBtn->set_active( bVal );
            mxBrochureBtn->set_sensitive( maPController->isUIOptionEnabled( aPropertyName ) && pVal != nullptr );
            mxBrochureBtn->connect_toggled( LINK( this, PrintDialog, ToggleHdl ) );

            maPropertyToWindowMap[ aPropertyName ].emplace_back(mpBrochureBtn );
            maControlToPropertyMap[mpBrochureBtn] = aPropertyName;
            maPropertyToWindowMap[aPropertyName].emplace_back(mxBrochureBtn.get());
            maControlToPropertyMap[mxBrochureBtn.get()] = aPropertyName;

            // set help id
            setHelpId( mpBrochureBtn, aHelpIds, 0 );
            setHelpId( mxBrochureBtn.get(), aHelpIds, 0 );
            // set help text
            setHelpText( mpBrochureBtn, aHelpTexts, 0 );
            setHelpText( mxBrochureBtn.get(), aHelpTexts, 0 );
        }
        else if (aCtrlType == "Bool")
        {
            // add a check box
            CheckBox* pNewBox = get<CheckBox>(aID);
            if (!pNewBox && mpCustomOptionsUIBuilder)
                pNewBox = mpCustomOptionsUIBuilder->get<CheckBox>(aID);

            if (!pNewBox)
            std::unique_ptr<weld::CheckButton> xNewBox = m_xBuilder->weld_check_button(aID);
            if (!xNewBox && mxCustomOptionsUIBuilder)
                xNewBox = mxCustomOptionsUIBuilder->weld_check_button(aID);
            if (!xNewBox)
                continue;

            pNewBox->SetText( aText );
            pNewBox->Show();
            xNewBox->set_label( aText );
            xNewBox->show();

            bool bVal = false;
            PropertyValue* pVal = maPController->getValue( aPropertyName );
            if( pVal )
                pVal->Value >>= bVal;
            pNewBox->Check( bVal );
            pNewBox->SetToggleHdl( LINK( this, PrintDialog, UIOption_CheckHdl ) );
            xNewBox->set_active( bVal );
            xNewBox->connect_toggled( LINK( this, PrintDialog, UIOption_CheckHdl ) );

            maPropertyToWindowMap[ aPropertyName ].emplace_back(pNewBox );
            maControlToPropertyMap[pNewBox] = aPropertyName;
            maExtraControls.emplace_back(std::move(xNewBox));

            weld::Widget* pWidget = maExtraControls.back().get();

            maPropertyToWindowMap[aPropertyName].emplace_back(pWidget);
            maControlToPropertyMap[pWidget] = aPropertyName;

            // set help id
            setHelpId( pNewBox, aHelpIds, 0 );
            setHelpId(pWidget, aHelpIds, 0);
            // set help text
            setHelpText( pNewBox, aHelpTexts, 0 );
            setHelpText(pWidget, aHelpTexts, 0);
        }
        else if (aCtrlType == "Radio")
        {
@@ -1561,116 +1504,125 @@ void PrintDialog::setupOptionalUI()
            for( sal_Int32 m = 0; m < aChoices.getLength(); m++ )
            {
                aID = OUStringToOString(aIDs[m], RTL_TEXTENCODING_UTF8);
                RadioButton* pBtn = get<RadioButton>(aID);
                if (!pBtn && mpCustomOptionsUIBuilder)
                    pBtn = mpCustomOptionsUIBuilder->get<RadioButton>(aID);

                if (!pBtn)
                std::unique_ptr<weld::RadioButton> xBtn = m_xBuilder->weld_radio_button(aID);
                if (!xBtn && mxCustomOptionsUIBuilder)
                    xBtn = mxCustomOptionsUIBuilder->weld_radio_button(aID);
                if (!xBtn)
                    continue;

                pBtn->SetText( aChoices[m] );
                pBtn->Check( m == nSelectVal );
                pBtn->SetToggleHdl( LINK( this, PrintDialog, UIOption_RadioHdl ) );
                xBtn->set_label( aChoices[m] );
                xBtn->set_active( m == nSelectVal );
                xBtn->connect_toggled( LINK( this, PrintDialog, UIOption_RadioHdl ) );
                if( aChoicesDisabled.getLength() > m && aChoicesDisabled[m] )
                    pBtn->Enable( false );
                pBtn->Show();
                maPropertyToWindowMap[ aPropertyName ].emplace_back(pBtn );
                maControlToPropertyMap[pBtn] = aPropertyName;
                maControlToNumValMap[pBtn] = m;
                    xBtn->set_sensitive( false );
                xBtn->show();

                maExtraControls.emplace_back(std::move(xBtn));

                weld::Widget* pWidget = maExtraControls.back().get();

                maPropertyToWindowMap[ aPropertyName ].emplace_back(pWidget);
                maControlToPropertyMap[pWidget] = aPropertyName;
                maControlToNumValMap[pWidget] = m;

                // set help id
                setHelpId( pBtn, aHelpIds, nCurHelpText );
                setHelpId( pWidget, aHelpIds, nCurHelpText );
                // set help text
                setHelpText( pBtn, aHelpTexts, nCurHelpText );
                setHelpText( pWidget, aHelpTexts, nCurHelpText );
                nCurHelpText++;
            }
        }
        else if ( aCtrlType == "List" )
        {
            ListBox* pList = get<ListBox>(aID);
            if (!pList && mpCustomOptionsUIBuilder)
                pList = mpCustomOptionsUIBuilder->get<ListBox>(aID);

            if (!pList)
            std::unique_ptr<weld::ComboBox> xList = m_xBuilder->weld_combo_box(aID);
            if (!xList && mxCustomOptionsUIBuilder)
                xList = mxCustomOptionsUIBuilder->weld_combo_box(aID);
            if (!xList)
                continue;

            // iterate options
            for( const auto& rChoice : std::as_const(aChoices) )
            {
                pList->InsertEntry( rChoice );
            }
                xList->append_text(rChoice);

            sal_Int32 nSelectVal = 0;
            PropertyValue* pVal = maPController->getValue( aPropertyName );
            if( pVal && pVal->Value.hasValue() )
                pVal->Value >>= nSelectVal;
            pList->SelectEntryPos( static_cast<sal_uInt16>(nSelectVal) );
            pList->SetSelectHdl( LINK( this, PrintDialog, UIOption_SelectHdl ) );
            pList->SetDropDownLineCount( static_cast<sal_uInt16>(aChoices.getLength()) );
            pList->Show();
            xList->set_active(nSelectVal);
            xList->connect_changed( LINK( this, PrintDialog, UIOption_SelectHdl ) );
            xList->show();

            maExtraControls.emplace_back(std::move(xList));

            weld::Widget* pWidget = maExtraControls.back().get();

            maPropertyToWindowMap[ aPropertyName ].emplace_back(pWidget);
            maControlToPropertyMap[pWidget] = aPropertyName;

            // set help id
            setHelpId( pList, aHelpIds, 0 );
            setHelpId( pWidget, aHelpIds, 0 );
            // set help text
            setHelpText( pList, aHelpTexts, 0 );

            maPropertyToWindowMap[ aPropertyName ].emplace_back(pList );
            maControlToPropertyMap[pList] = aPropertyName;
            setHelpText( pWidget, aHelpTexts, 0 );
        }
        else if ( aCtrlType == "Range" )
        {
            NumericField* pField = get<NumericField>(aID);
            if (!pField && mpCustomOptionsUIBuilder)
                pField = mpCustomOptionsUIBuilder->get<NumericField>(aID);

            if (!pField)
            std::unique_ptr<weld::SpinButton> xField = m_xBuilder->weld_spin_button(aID);
            if (!xField && mxCustomOptionsUIBuilder)
                xField = mxCustomOptionsUIBuilder->weld_spin_button(aID);
            if (!xField)
                continue;

            // set min/max and current value
            if( nMinValue != nMaxValue )
            {
                pField->SetMin( nMinValue );
                pField->SetMax( nMaxValue );
            }
            if(nMinValue != nMaxValue)
                xField->set_range(nMinValue, nMaxValue);

            sal_Int64 nCurVal = 0;
            PropertyValue* pVal = maPController->getValue( aPropertyName );
            if( pVal && pVal->Value.hasValue() )
                pVal->Value >>= nCurVal;
            pField->SetValue( nCurVal );
            pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) );
            pField->Show();
            xField->set_value( nCurVal );
            xField->connect_value_changed( LINK( this, PrintDialog, UIOption_SpinModifyHdl ) );
            xField->show();

            maExtraControls.emplace_back(std::move(xField));

            weld::Widget* pWidget = maExtraControls.back().get();

            maPropertyToWindowMap[ aPropertyName ].emplace_back(pWidget);
            maControlToPropertyMap[pWidget] = aPropertyName;

            // set help id
            setHelpId( pField, aHelpIds, 0 );
            setHelpId( pWidget, aHelpIds, 0 );
            // set help text
            setHelpText( pField, aHelpTexts, 0 );

            maPropertyToWindowMap[ aPropertyName ].emplace_back(pField );
            maControlToPropertyMap[pField] = aPropertyName;
            setHelpText( pWidget, aHelpTexts, 0 );
        }
        else if (aCtrlType == "Edit")
        {
            Edit *pField = get<Edit>(aID);
            if (!pField && mpCustomOptionsUIBuilder)
                pField = mpCustomOptionsUIBuilder->get<Edit>(aID);

            if (!pField)
            std::unique_ptr<weld::Entry> xField = m_xBuilder->weld_entry(aID);
            if (!xField && mxCustomOptionsUIBuilder)
                xField = mxCustomOptionsUIBuilder->weld_entry(aID);
            if (!xField)
                continue;

            OUString aCurVal;
            PropertyValue* pVal = maPController->getValue( aPropertyName );
            if( pVal && pVal->Value.hasValue() )
                pVal->Value >>= aCurVal;
            pField->SetText( aCurVal );
            pField->SetModifyHdl( LINK( this, PrintDialog, UIOption_ModifyHdl ) );
            pField->Show();
            xField->set_text( aCurVal );
            xField->connect_changed( LINK( this, PrintDialog, UIOption_EntryModifyHdl ) );
            xField->show();

            maExtraControls.emplace_back(std::move(xField));

            weld::Widget* pWidget = maExtraControls.back().get();

            maPropertyToWindowMap[ aPropertyName ].emplace_back(pWidget);
            maControlToPropertyMap[pWidget] = aPropertyName;

            // set help id
            setHelpId( pField, aHelpIds, 0 );
            setHelpId( pWidget, aHelpIds, 0 );
            // set help text
            setHelpText( pField, aHelpTexts, 0 );

            maPropertyToWindowMap[ aPropertyName ].emplace_back(pField );
            maControlToPropertyMap[pField] = aPropertyName;
            setHelpText( pWidget, aHelpTexts, 0 );
        }
        else
        {
@@ -1680,33 +1632,33 @@ void PrintDialog::setupOptionalUI()

    // #i106506# if no brochure button, then the singular Pages radio button
    // makes no sense, so replace it by a FixedText label
    if (!mpBrochureBtn->IsVisible() && mpPagesBtn->IsVisible())
    if (!mxBrochureBtn->get_visible() && mxPagesBtn->get_visible())
    {
        mpPagesBoxTitleTxt->SetText( mpPagesBtn->GetText() );
        mpPagesBoxTitleTxt->Show();
        mpPagesBtn->Show( false );
        mxPagesBoxTitleTxt->set_label(mxPagesBtn->get_label());
        mxPagesBoxTitleTxt->show();
        mxPagesBtn->hide();

        mpPagesBoxTitleTxt->SetAccessibleRelationLabelFor(mpNupPagesBox);
        mpNupPagesBox->SetAccessibleRelationLabeledBy(mpPagesBoxTitleTxt);
        mpPagesBtn->SetAccessibleRelationLabelFor(nullptr);
        mxPagesBoxTitleTxt->set_accessible_relation_label_for(mxNupPagesBox.get());
        mxNupPagesBox->set_accessible_relation_labeled_by(mxPagesBoxTitleTxt.get());
        mxPagesBtn->set_accessible_relation_label_for(nullptr);
    }

    // update enable states
    checkOptionalControlDependencies();

    vcl::Window *pPageRange = get<vcl::Window>("pagerange");
    std::unique_ptr<weld::Widget> xPageRange = m_xBuilder->weld_widget("pagerange");

    // print range not shown (currently math only) -> hide spacer line and reverse order
    if (!pPageRange || !pPageRange->IsVisible())
    if (!xPageRange || !xPageRange->get_visible())
    {
        mpReverseOrderBox->Show( false );
        mxReverseOrderBox->hide();
    }

    if (!mpCustomOptionsUIBuilder)
        mpTabCtrl->RemovePage(mpTabCtrl->GetPageId(1));
    if (!mxCustomOptionsUIBuilder)
        mxTabCtrl->remove_page(mxTabCtrl->get_page_ident(1));
}

void PrintDialog::makeEnabled( vcl::Window* i_pWindow )
void PrintDialog::makeEnabled( weld::Widget* i_pWindow )
{
    auto it = maControlToPropertyMap.find( i_pWindow );
    if( it != maControlToPropertyMap.end() )
@@ -1723,7 +1675,7 @@ void PrintDialog::updateWindowFromProperty( const OUString& i_rProperty )
    auto it = maPropertyToWindowMap.find( i_rProperty );
    if( pValue && it != maPropertyToWindowMap.end() )
    {
        const std::vector< VclPtr<vcl::Window> >& rWindows( it->second );
        const auto& rWindows( it->second );
        if( ! rWindows.empty() )
        {
            bool bVal = false;
@@ -1731,18 +1683,18 @@ void PrintDialog::updateWindowFromProperty( const OUString& i_rProperty )
            if( pValue->Value >>= bVal )
            {
                // we should have a CheckBox for this one
                CheckBox* pBox = dynamic_cast< CheckBox* >( rWindows.front().get() );
                weld::CheckButton* pBox = dynamic_cast<weld::CheckButton*>(rWindows.front());
                if( pBox )
                {
                    pBox->Check( bVal );
                    pBox->set_active( bVal );
                }
                else if ( i_rProperty == "PrintProspect" )
                {
                    // EVIL special case
                    if( bVal )
                        mpBrochureBtn->Check();
                        mxBrochureBtn->set_active(true);
                    else
                        mpPagesBtn->Check();
                        mxPagesBtn->set_active(true);
                }
                else
                {
@@ -1752,17 +1704,17 @@ void PrintDialog::updateWindowFromProperty( const OUString& i_rProperty )
            else if( pValue->Value >>= nVal )
            {
                // this could be a ListBox or a RadioButtonGroup
                ListBox* pList = dynamic_cast< ListBox* >( rWindows.front().get() );
                weld::ComboBox* pList = dynamic_cast<weld::ComboBox*>(rWindows.front());
                if( pList )
                {
                    pList->SelectEntryPos( static_cast< sal_uInt16 >(nVal) );
                    pList->set_active( static_cast< sal_uInt16 >(nVal) );
                }
                else if( nVal >= 0 && nVal < sal_Int32(rWindows.size() ) )
                {
                    RadioButton* pBtn = dynamic_cast< RadioButton* >( rWindows[nVal].get() );
                    weld::RadioButton* pBtn = dynamic_cast<weld::RadioButton*>(rWindows[nVal]);
                    SAL_WARN_IF( !pBtn, "vcl", "unexpected control for property" );
                    if( pBtn )
                        pBtn->Check();
                        pBtn->set_active(true);
                }
            }
        }
@@ -1771,20 +1723,20 @@ void PrintDialog::updateWindowFromProperty( const OUString& i_rProperty )

bool PrintDialog::isPrintToFile() const
{
    return ( mpPrinters->GetSelectedEntryPos() == 0 );
    return ( mxPrinters->get_active() == 0 );
}

bool PrintDialog::isCollate() const
{
    return mpCopyCountField->GetValue() > 1 && mpCollateBox->IsChecked();
    return mxCopyCountField->get_value() > 1 && mxCollateBox->get_active();
}

bool PrintDialog::hasPreview() const
{
    return mpPreviewBox->IsChecked();
    return mxPreviewBox->get_active();
}

PropertyValue* PrintDialog::getValueForWindow( vcl::Window* i_pWindow ) const
PropertyValue* PrintDialog::getValueForWindow( weld::Widget* i_pWindow ) const
{
    PropertyValue* pVal = nullptr;
    auto it = maControlToPropertyMap.find( i_pWindow );
@@ -1800,58 +1752,53 @@ PropertyValue* PrintDialog::getValueForWindow( vcl::Window* i_pWindow ) const
    return pVal;
}

IMPL_LINK( PrintDialog, ToggleHdl, CheckBox&, rButton, void )
IMPL_LINK(PrintDialog, ToggleHdl, weld::ToggleButton&, rButton, void)
{
    ClickHdl(&rButton);
    ClickHdl(rButton);
}

IMPL_LINK( PrintDialog, ToggleRadioHdl, RadioButton&, rButton, void )
IMPL_LINK(PrintDialog, ClickHdl, weld::Button&, rButton, void)
{
    ClickHdl(static_cast<Button*>(&rButton));
}

IMPL_LINK ( PrintDialog, ClickHdl, Button*, pButton, void )
{
    if( pButton == mpOKButton || pButton == mpCancelButton )
    if (&rButton == mxOKButton.get() || &rButton == mxCancelButton.get())
    {
        storeToSettings();
        EndDialog( pButton == mpOKButton ? RET_OK : RET_CANCEL );
        m_xDialog->response(&rButton == mxOKButton.get() ? RET_OK : RET_CANCEL);
    }
    else if( pButton == mpHelpButton )
    else if( &rButton == mxHelpButton.get() )
    {
        // start help system
        Help* pHelp = Application::GetHelp();
        if( pHelp )
        {
            pHelp->Start( "vcl/ui/printdialog", mpOKButton );
            pHelp->Start("vcl/ui/printdialog", mxOKButton.get());
        }
    }
    else if ( pButton == mpPreviewBox )
    else if ( &rButton == mxPreviewBox.get() )
    {
        preparePreview( true );
    }
    else if( pButton == mpForwardBtn )
    else if( &rButton == mxForwardBtn.get() )
    {
        previewForward();
    }
    else if( pButton == mpBackwardBtn )
    else if( &rButton == mxBackwardBtn.get() )
    {
        previewBackward();
    }
    else if( pButton == mpFirstBtn )
    else if( &rButton == mxFirstBtn.get() )
    {
        previewFirst();
    }
    else if( pButton == mpLastBtn )
    else if( &rButton == mxLastBtn.get() )
    {
        previewLast();
    }
    else if( pButton == mpBrochureBtn )
    else if( &rButton == mxBrochureBtn.get() )
    {
        PropertyValue* pVal = getValueForWindow( pButton );
        PropertyValue* pVal = getValueForWindow( &rButton );
        if( pVal )
        {
            bool bVal = mpBrochureBtn->IsChecked();
            bool bVal = mxBrochureBtn->get_active();
            pVal->Value <<= bVal;

            checkOptionalControlDependencies();
@@ -1859,51 +1806,51 @@ IMPL_LINK ( PrintDialog, ClickHdl, Button*, pButton, void )
            // update preview and page settings
            preparePreview(false);
        }
        if( mpBrochureBtn->IsChecked() )
        if( mxBrochureBtn->get_active() )
        {
            mpOrientationBox->Enable( false );
            mpOrientationBox->SelectEntryPos( ORIENTATION_LANDSCAPE );
            mpNupPagesBox->SelectEntryPos( 0 );
            mxOrientationBox->set_sensitive( false );
            mxOrientationBox->set_active( ORIENTATION_LANDSCAPE );
            mxNupPagesBox->set_active( 0 );
            updateNupFromPages();
            showAdvancedControls( false );
            enableNupControls( false );
        }
    }
    else if( pButton == mpPagesBtn )
    else if( &rButton == mxPagesBtn.get() )
    {
        mpOrientationBox->Enable( true );
        mpOrientationBox->SelectEntryPos( ORIENTATION_AUTOMATIC );
        mxOrientationBox->set_sensitive( true );
        mxOrientationBox->set_active( ORIENTATION_AUTOMATIC );
        enableNupControls( true );
        updateNupFromPages();
    }
    else if( pButton == mpCollateBox )
    else if( &rButton == mxCollateBox.get() )
    {
        maPController->setValue( "Collate",
                                 makeAny( isCollate() ) );
        checkControlDependencies();
    }
    else if( pButton == mpReverseOrderBox )
    else if( &rButton == mxReverseOrderBox.get() )
    {
        bool bChecked = mpReverseOrderBox->IsChecked();
        bool bChecked = mxReverseOrderBox->get_active();
        maPController->setReversePrint( bChecked );
        maPController->setValue( "PrintReverse",
                                 makeAny( bChecked ) );
        preparePreview( true );
    }
    else if( pButton == mpBorderCB )
    else if( &rButton == mxBorderCB.get() )
    {
        updateNup();
    }
    else if ( pButton == mpMoreOptionsBtn )
    else if ( &rButton == mxMoreOptionsBtn.get() )
    {
        mxMoreOptionsDlg.reset(new MoreOptionsDialog(this));
        mxMoreOptionsDlg->run();
    }
    else
    {
        if( pButton == mpSetupButton )
        if( &rButton == mxSetupButton.get() )
        {
            maPController->setupPrinter(GetFrameWeld());
            maPController->setupPrinter(m_xDialog.get());

            if ( !isPrintToFile() )
            {
@@ -1918,7 +1865,7 @@ IMPL_LINK ( PrintDialog, ClickHdl, Button*, pButton, void )

                    if ( mePaper == ePaper )
                    {
                        mpPaperSizeBox->SelectEntryPos( nPaper );
                        mxPaperSizeBox->set_active( nPaper );
                        break;
                    }
                }
@@ -1934,13 +1881,13 @@ IMPL_LINK ( PrintDialog, ClickHdl, Button*, pButton, void )

}

IMPL_LINK( PrintDialog, SelectHdl, ListBox&, rBox, void )
IMPL_LINK( PrintDialog, SelectHdl, weld::ComboBox&, rBox, void )
{
    if(  &rBox == mpPrinters )
    if (&rBox == mxPrinters.get())
    {
        if ( !isPrintToFile() )
        {
            OUString aNewPrinter( rBox.GetSelectedEntry() );
            OUString aNewPrinter(rBox.get_active_text());
            // set new printer
            maPController->setPrinter( VclPtrInstance<Printer>( aNewPrinter ) );
            maPController->resetPrinterOptions( false  );
@@ -1948,7 +1895,7 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox&, rBox, void )
            updateOrientationBox();

            // update text fields
            mpOKButton->SetText( maPrintText );
            mxOKButton->set_label(maPrintText);
            updatePrinterText();
            setPaperSizes();
            preparePreview(false);
@@ -1957,7 +1904,7 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox&, rBox, void )
        {
            // use the default printer or FIXME: the last used one?
            maPController->setPrinter( VclPtrInstance<Printer>( Printer::GetDefaultPrinterName() ) );
            mpOKButton->SetText( maPrintToFileText );
            mxOKButton->set_label(maPrintToFileText);
            maPController->resetPrinterOptions( true );

            setPaperSizes();
@@ -1967,33 +1914,33 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox&, rBox, void )

        setupPaperSidesBox();
    }
    else if ( &rBox == mpPaperSidesBox )
    else if ( &rBox == mxPaperSidesBox.get() )
    {
        DuplexMode eDuplex = static_cast<DuplexMode>(mpPaperSidesBox->GetSelectedEntryPos() + 1);
        DuplexMode eDuplex = static_cast<DuplexMode>(mxPaperSidesBox->get_active() + 1);
        maPController->getPrinter()->SetDuplexMode( eDuplex );
    }
    else if( &rBox == mpOrientationBox )
    else if( &rBox == mxOrientationBox.get() )
    {
        int nOrientation = mpOrientationBox->GetSelectedEntryPos();
        int nOrientation = mxOrientationBox->get_active();
        if ( nOrientation != ORIENTATION_AUTOMATIC )
            setPaperOrientation( static_cast<Orientation>( nOrientation - 1 ) );

        updateNup( false );
    }
    else if ( &rBox == mpNupOrderBox )
    else if ( &rBox == mxNupOrderBox.get() )
    {
        updateNup();
    }
    else if( &rBox == mpNupPagesBox )
    else if( &rBox == mxNupPagesBox.get() )
    {
        if( !mpPagesBtn->IsChecked() )
            mpPagesBtn->Check();
        if( !mxPagesBtn->get_active() )
            mxPagesBtn->set_active(true);
        updateNupFromPages( false );
    }
    else if ( &rBox == mpPaperSizeBox )
    else if ( &rBox == mxPaperSizeBox.get() )
    {
        VclPtr<Printer> aPrt( maPController->getPrinter() );
        PaperInfo aInfo = aPrt->GetPaperInfo( rBox.GetSelectedEntryPos() );
        PaperInfo aInfo = aPrt->GetPaperInfo( rBox.get_active() );
        aInfo.doSloppyFit();
        mePaper = aInfo.getPaper();

@@ -2010,37 +1957,63 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox&, rBox, void )
    }
}

IMPL_LINK( PrintDialog, ModifyHdl, Edit&, rEdit, void )
IMPL_LINK_NOARG(PrintDialog, MetricSpinModifyHdl, weld::MetricSpinButton&, void)
{
    checkControlDependencies();
    if( &rEdit == mpNupRowsEdt || &rEdit == mpNupColEdt ||
       &rEdit == mpSheetMarginEdt || &rEdit == mpPageMarginEdt
      )
    updateNupFromPages();
}

IMPL_LINK_NOARG(PrintDialog, FocusOutHdl, weld::Widget&, void)
{
    ActivateHdl(*mxPageEdit);
}

IMPL_LINK_NOARG(PrintDialog, ActivateHdl, weld::Entry&, bool)
{
    sal_Int32 nPage = mxPageEdit->get_text().toInt32();
    if (nPage < 1)
    {
        nPage = 1;
        mxPageEdit->set_text("1");
    }
    else if (nPage > mnCachedPages)
    {
        nPage = mnCachedPages;
        mxPageEdit->set_text(OUString::number(mnCachedPages));
    }
    int nNewCurPage = nPage - 1;
    if (nNewCurPage != mnCurPage)
    {
        mnCurPage = nNewCurPage;
        preparePreview(true);
    }
    return true;
}

IMPL_LINK( PrintDialog, SpinModifyHdl, weld::SpinButton&, rEdit, void )
{
    checkControlDependencies();
    if (&rEdit == mxNupRowsEdt.get() || &rEdit == mxNupColEdt.get())
    {
       updateNupFromPages();
    }
    else if( &rEdit == mpPageEdit )
    {
        mnCurPage = sal_Int32( mpPageEdit->GetValue() - 1 );
        preparePreview( true );
    }
    else if( &rEdit == mpCopyCountField )
    else if( &rEdit == mxCopyCountField.get() )
    {
        maPController->setValue( "CopyCount",
                               makeAny( sal_Int32(mpCopyCountField->GetValue()) ) );
                               makeAny( sal_Int32(mxCopyCountField->get_value()) ) );
        maPController->setValue( "Collate",
                               makeAny( isCollate() ) );
    }
}

IMPL_LINK( PrintDialog, UIOption_CheckHdl, CheckBox&, i_rBox, void )
IMPL_LINK( PrintDialog, UIOption_CheckHdl, weld::ToggleButton&, i_rBox, void )
{
    PropertyValue* pVal = getValueForWindow( &i_rBox );
    if( pVal )
    {
        makeEnabled( &i_rBox );

        bool bVal = i_rBox.IsChecked();
        bool bVal = i_rBox.get_active();
        pVal->Value <<= bVal;

        checkOptionalControlDependencies();
@@ -2050,12 +2023,12 @@ IMPL_LINK( PrintDialog, UIOption_CheckHdl, CheckBox&, i_rBox, void )
    }
}

IMPL_LINK( PrintDialog, UIOption_RadioHdl, RadioButton&, i_rBtn, void )
IMPL_LINK( PrintDialog, UIOption_RadioHdl, weld::ToggleButton&, i_rBtn, void )
{
    // this handler gets called for all radiobuttons that get unchecked, too
    // however we only want one notification for the new value (that is for
    // the button that gets checked)
    if( i_rBtn.IsChecked() )
    if( i_rBtn.get_active() )
    {
        PropertyValue* pVal = getValueForWindow( &i_rBtn );
        auto it = maControlToNumValMap.find( &i_rBtn );
@@ -2080,14 +2053,14 @@ IMPL_LINK( PrintDialog, UIOption_RadioHdl, RadioButton&, i_rBtn, void )
    }
}

IMPL_LINK( PrintDialog, UIOption_SelectHdl, ListBox&, i_rBox, void )
IMPL_LINK( PrintDialog, UIOption_SelectHdl, weld::ComboBox&, i_rBox, void )
{
    PropertyValue* pVal = getValueForWindow( &i_rBox );
    if( pVal )
    {
        makeEnabled( &i_rBox );

        sal_Int32 nVal( i_rBox.GetSelectedEntryPos() );
        sal_Int32 nVal( i_rBox.get_active() );
        pVal->Value <<= nVal;

        //If we are in impress we start in print slides mode and get a
@@ -2105,30 +2078,32 @@ IMPL_LINK( PrintDialog, UIOption_SelectHdl, ListBox&, i_rBox, void )
    }
}

IMPL_LINK( PrintDialog, UIOption_ModifyHdl, Edit&, i_rBox, void )
IMPL_LINK( PrintDialog, UIOption_SpinModifyHdl, weld::SpinButton&, i_rBox, void )
{
    PropertyValue* pVal = getValueForWindow( &i_rBox );
    if( pVal )
    {
        makeEnabled( &i_rBox );

        NumericField* pNum = dynamic_cast<NumericField*>(&i_rBox);
        MetricField* pMetric = dynamic_cast<MetricField*>(&i_rBox);
        if( pNum )
        {
            sal_Int64 nVal = pNum->GetValue();
            pVal->Value <<= nVal;
        }
        else if( pMetric )
        {
            sal_Int64 nVal = pMetric->GetValue();
            pVal->Value <<= nVal;
        }
        else
        {
            OUString aVal( i_rBox.GetText() );
            pVal->Value <<= aVal;
        }
        sal_Int64 nVal = i_rBox.get_value();
        pVal->Value <<= nVal;

        checkOptionalControlDependencies();

        // update preview and page settings
        preparePreview(false);
    }
}

IMPL_LINK( PrintDialog, UIOption_EntryModifyHdl, weld::Entry&, i_rBox, void )
{
    PropertyValue* pVal = getValueForWindow( &i_rBox );
    if( pVal )
    {
        makeEnabled( &i_rBox );

        OUString aVal( i_rBox.get_text() );
        pVal->Value <<= aVal;

        checkOptionalControlDependencies();

@@ -2139,22 +2114,34 @@ IMPL_LINK( PrintDialog, UIOption_ModifyHdl, Edit&, i_rBox, void )

void PrintDialog::previewForward()
{
    mpPageEdit->Up();
    sal_Int32 nValue = mxPageEdit->get_text().toInt32() + 1;
    if (nValue <= mnCachedPages)
    {
        mxPageEdit->set_text(OUString::number(nValue));
        ActivateHdl(*mxPageEdit);
    }
}

void PrintDialog::previewBackward()
{
    mpPageEdit->Down();
    sal_Int32 nValue = mxPageEdit->get_text().toInt32() - 1;
    if (nValue >= 1)
    {
        mxPageEdit->set_text(OUString::number(nValue));
        ActivateHdl(*mxPageEdit);
    }
}

void PrintDialog::previewFirst()
{
    mpPageEdit->First();
    mxPageEdit->set_text("1");
    ActivateHdl(*mxPageEdit);
}

void PrintDialog::previewLast()
{
    mpPageEdit->Last();
    mxPageEdit->set_text(OUString::number(mnCachedPages));
    ActivateHdl(*mxPageEdit);
}

// PrintProgressDialog
@@ -2213,3 +2200,5 @@ void PrintProgressDialog::tick()
    if( mnCur < mnMax )
        setProgress( ++mnCur );
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/uiconfig/ui/printdialog.ui b/vcl/uiconfig/ui/printdialog.ui
index 2fbd6a6..ec2d41b 100644
--- a/vcl/uiconfig/ui/printdialog.ui
+++ b/vcl/uiconfig/ui/printdialog.ui
@@ -2,7 +2,6 @@
<!-- Generated with glade 3.22.1 -->
<interface domain="vcl">
  <requires lib="gtk+" version="3.18"/>
  <requires lib="LibreOffice" version="1.0"/>
  <object class="GtkAdjustment" id="adjustment1">
    <property name="lower">10</property>
    <property name="upper">200</property>
@@ -17,6 +16,28 @@
    <property name="step_increment">1</property>
    <property name="page_increment">10</property>
  </object>
  <object class="GtkAdjustment" id="adjustment3">
    <property name="lower">1</property>
    <property name="upper">1000</property>
    <property name="step_increment">1</property>
    <property name="page_increment">10</property>
  </object>
  <object class="GtkAdjustment" id="adjustment4">
    <property name="lower">1</property>
    <property name="upper">1000</property>
    <property name="step_increment">1</property>
    <property name="page_increment">10</property>
  </object>
  <object class="GtkAdjustment" id="adjustment5">
    <property name="upper">1000</property>
    <property name="step_increment">1</property>
    <property name="page_increment">10</property>
  </object>
  <object class="GtkAdjustment" id="adjustment6">
    <property name="upper">1000</property>
    <property name="step_increment">1</property>
    <property name="page_increment">10</property>
  </object>
  <object class="GtkImage" id="imgBack">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
@@ -39,102 +60,13 @@
    <property name="can_focus">False</property>
    <property name="stock">gtk-goto-last</property>
  </object>
  <object class="GtkListStore" id="liststore1">
    <columns>
      <!-- column-name gchararray -->
      <column type="gchararray"/>
      <!-- column-name gint -->
      <column type="gint"/>
    </columns>
    <data>
      <row>
        <col id="0" context="printdialog|liststore1">1</col>
        <col id="1">1</col>
      </row>
      <row>
        <col id="0" context="printdialog|liststore1">2</col>
        <col id="1">2</col>
      </row>
      <row>
        <col id="0" context="printdialog|liststore1">4</col>
        <col id="1">4</col>
      </row>
      <row>
        <col id="0" context="printdialog|liststore1">6</col>
        <col id="1">6</col>
      </row>
      <row>
        <col id="0" context="printdialog|liststore1">9</col>
        <col id="1">9</col>
      </row>
      <row>
        <col id="0" context="printdialog|liststore1">16</col>
        <col id="1">16</col>
      </row>
      <row>
        <col id="0" translatable="yes" context="printdialog|liststore1">Custom</col>
        <col id="1">65535</col>
      </row>
    </data>
  </object>
  <object class="GtkListStore" id="liststore2">
    <columns>
      <!-- column-name gchararray -->
      <column type="gchararray"/>
    </columns>
    <data>
      <row>
        <col id="0" translatable="yes" context="printdialog|liststore2">Left to right, then down</col>
      </row>
      <row>
        <col id="0" translatable="yes" context="printdialog|liststore2">Top to bottom, then right</col>
      </row>
      <row>
        <col id="0" translatable="yes" context="printdialog|liststore2">Top to bottom, then left</col>
      </row>
      <row>
        <col id="0" translatable="yes" context="printdialog|liststore2">Right to left, then down</col>
      </row>
    </data>
  </object>
  <object class="GtkListStore" id="liststore3">
    <columns>
      <!-- column-name gchararray -->
      <column type="gchararray"/>
    </columns>
    <data>
      <row>
        <col id="0" translatable="yes" context="printdialog|liststore3">Automatic</col>
      </row>
      <row>
        <col id="0" translatable="yes" context="printdialog|liststore3">Portrait</col>
      </row>
      <row>
        <col id="0" translatable="yes" context="printdialog|liststore3">Landscape</col>
      </row>
    </data>
  </object>
  <object class="GtkListStore" id="liststore4">
    <columns>
      <!-- column-name gchararray -->
      <column type="gchararray"/>
    </columns>
    <data>
      <row>
        <col id="0" translatable="yes" context="printdialog|liststore4">Print only in one side</col>
      </row>
      <row>
        <col id="0" translatable="yes" context="printdialog|liststore4">Print in both sides (long edge)</col>
      </row>
      <row>
        <col id="0" translatable="yes" context="printdialog|liststore4">Print in both sides (short edge)</col>
      </row>
    </data>
  </object>
  <object class="GtkDialog" id="PrintDialog">
    <property name="can_focus">False</property>
    <property name="border_width">6</property>
    <property name="title" translatable="yes" context="printdialog|PrintDialog">Print</property>
    <property name="modal">True</property>
    <property name="default_width">0</property>
    <property name="default_height">0</property>
    <property name="type_hint">dialog</property>
    <child>
      <placeholder/>
@@ -143,7 +75,7 @@
      <object class="GtkBox" id="PrintDialogBox">
        <property name="can_focus">False</property>
        <property name="orientation">vertical</property>
        <property name="spacing">2</property>
        <property name="spacing">12</property>
        <child internal-child="action_area">
          <object class="GtkButtonBox" id="internalarea">
            <property name="can_focus">False</property>
@@ -182,6 +114,7 @@
                <property name="label">gtk-ok</property>
                <property name="visible">True</property>
                <property name="can_focus">True</property>
                <property name="can_default">True</property>
                <property name="has_default">True</property>
                <property name="receives_default">True</property>
                <property name="use_stock">True</property>
@@ -234,11 +167,13 @@
                        <property name="can_focus">False</property>
                        <property name="orientation">vertical</property>
                        <child>
                          <object class="vcllo-PrintPreviewWindow" id="preview">
                          <object class="GtkDrawingArea" id="preview">
                            <property name="width_request">500</property>
                            <property name="height_request">700</property>
                            <property name="visible">True</property>
                            <property name="can_focus">False</property>
                            <property name="events">GDK_STRUCTURE_MASK | GDK_SCROLL_MASK</property>
                            <property name="tooltip_text" translatable="yes" context="printdialog|printpreview">Print preview</property>
                          </object>
                          <packing>
                            <property name="expand">True</property>
@@ -257,7 +192,6 @@
                      <object class="GtkBox" id="box3">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="spacing">30</property>
                        <child>
                          <object class="GtkBox" id="box14">
                            <property name="visible">True</property>
@@ -308,9 +242,11 @@
                              </packing>
                            </child>
                            <child>
                              <object class="GtkSpinButton" id="pageedit-nospin">
                              <object class="GtkEntry" id="pageedit-nospin">
                                <property name="visible">True</property>
                                <property name="can_focus">True</property>
                                <property name="width_chars">3</property>
                                <property name="text" translatable="no">1</property>
                              </object>
                              <packing>
                                <property name="expand">False</property>
@@ -422,815 +358,807 @@
                    <property name="scrollable">True</property>
                    <property name="enable_popup">True</property>
                    <child>
                      <object class="GtkScrolledWindow">
                      <object class="GtkBox" id="box11">
                        <property name="visible">True</property>
                        <property name="can_focus">True</property>
                        <property name="hexpand">True</property>
                        <property name="vexpand">True</property>
                        <property name="shadow_type">in</property>
                        <property name="min_content_width">1076</property>
                        <property name="min_content_height">600</property>
                        <property name="can_focus">False</property>
                        <property name="border_width">6</property>
                        <property name="orientation">vertical</property>
                        <property name="spacing">12</property>
                        <child>
                          <object class="GtkViewport">
                          <object class="GtkFrame" id="frPrinterName">
                            <property name="visible">True</property>
                            <property name="can_focus">False</property>
                            <property name="label_xalign">0</property>
                            <property name="shadow_type">none</property>
                            <child>
                              <object class="GtkBox" id="box11">
                              <object class="GtkAlignment" id="alignment">
                                <property name="visible">True</property>
                                <property name="can_focus">False</property>
                                <property name="margin_left">6</property>
                                <property name="margin_right">6</property>
                                <property name="margin_top">6</property>
                                <property name="margin_bottom">6</property>
                                <property name="orientation">vertical</property>
                                <property name="spacing">12</property>
                                <property name="top_padding">6</property>
                                <property name="left_padding">12</property>
                                <child>
                                  <object class="GtkFrame" id="frPrinterName">
                                  <object class="GtkBox" id="box5">
                                    <property name="visible">True</property>
                                    <property name="can_focus">False</property>
                                    <property name="margin_left">6</property>
                                    <property name="margin_right">6</property>
                                    <property name="label_xalign">0</property>
                                    <property name="shadow_type">none</property>
                                    <property name="orientation">vertical</property>
                                    <property name="spacing">6</property>
                                    <child>
                                      <object class="GtkAlignment" id="alignment">
                                      <object class="GtkComboBoxText" id="printersbox">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="top_padding">6</property>
                                        <property name="left_padding">12</property>
                                      </object>
                                      <packing>
                                        <property name="expand">False</property>
                                        <property name="fill">True</property>
                                        <property name="position">0</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkBox" id="box6">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="spacing">6</property>
                                        <child>
                                          <object class="GtkBox" id="box5">
                                          <object class="GtkLabel" id="labelstatus">
                                            <property name="visible">True</property>
                                            <property name="can_focus">False</property>
                                            <property name="orientation">vertical</property>
                                            <property name="spacing">6</property>
                                            <child>
                                              <object class="GtkComboBox" id="printersbox">
                                                <property name="visible">True</property>
                                                <property name="can_focus">False</property>
                                              </object>
                                              <packing>
                                                <property name="expand">False</property>
                                                <property name="fill">True</property>
                                                <property name="position">0</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkBox" id="box6">
                                                <property name="visible">True</property>
                                                <property name="can_focus">False</property>
                                                <property name="spacing">6</property>
                                                <child>
                                                  <object class="GtkLabel" id="labelstatus">
                                                    <property name="visible">True</property>
                                                    <property name="can_focus">False</property>
                                                    <property name="label" translatable="yes" context="printdialog|labelstatus">Status:</property>
                                                    <accessibility>
                                                      <relation type="label-for" target="status"/>
                                                    </accessibility>
                                                  </object>
                                                  <packing>
                                                    <property name="expand">False</property>
                                                    <property name="fill">True</property>
                                                    <property name="position">0</property>
                                                  </packing>
                                                </child>
                                                <child>
                                                  <object class="GtkLabel" id="status">
                                                    <property name="visible">True</property>
                                                    <property name="can_focus">False</property>
                                                    <property name="label" translatable="yes" context="printdialog|status">Default Printer</property>
                                                    <accessibility>
                                                      <relation type="labelled-by" target="labelstatus"/>
                                                    </accessibility>
                                                  </object>
                                                  <packing>
                                                    <property name="expand">False</property>
                                                    <property name="fill">True</property>
                                                    <property name="position">1</property>
                                                  </packing>
                                                </child>
                                                <child>
                                                  <object class="GtkButton" id="setup">
                                                    <property name="label" translatable="yes" context="printdialog|setup">Properties...</property>
                                                    <property name="visible">True</property>
                                                    <property name="can_focus">True</property>
                                                    <property name="receives_default">True</property>
                                                    <property name="halign">end</property>
                                                  </object>
                                                  <packing>
                                                    <property name="expand">False</property>
                                                    <property name="fill">True</property>
                                                    <property name="pack_type">end</property>
                                                    <property name="position">2</property>
                                                  </packing>
                                                </child>
                                              </object>
                                              <packing>
                                                <property name="expand">False</property>
                                                <property name="fill">True</property>
                                                <property name="position">1</property>
                                              </packing>
                                            </child>
                                            <property name="label" translatable="yes" context="printdialog|labelstatus">Status:</property>
                                            <accessibility>
                                              <relation type="label-for" target="status"/>
                                            </accessibility>
                                          </object>
                                          <packing>
                                            <property name="expand">False</property>
                                            <property name="fill">True</property>
                                            <property name="position">0</property>
                                          </packing>
                                        </child>
                                      </object>
                                    </child>
                                    <child type="label">
                                      <object class="GtkLabel" id="labelprinter">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="label" translatable="yes" context="printdialog|labelprinter">Printer</property>
                                        <property name="use_underline">True</property>
                                        <property name="mnemonic_widget">printersbox</property>
                                        <attributes>
                                          <attribute name="weight" value="bold"/>
                                        </attributes>
                                      </object>
                                    </child>
                                  </object>
                                  <packing>
                                    <property name="expand">False</property>
                                    <property name="fill">True</property>
                                    <property name="position">0</property>
                                  </packing>
                                </child>
                                <child>
                                  <object class="GtkFrame" id="frPrintRange">
                                    <property name="visible">True</property>
                                    <property name="can_focus">False</property>
                                    <property name="margin_left">6</property>
                                    <property name="margin_right">6</property>
                                    <property name="label_xalign">0</property>
                                    <property name="shadow_type">none</property>
                                    <child>
                                      <object class="GtkAlignment" id="alPrintRange">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="top_padding">6</property>
                                        <property name="left_padding">12</property>
                                        <child>
                                          <object class="GtkGrid" id="grid1">
                                          <object class="GtkLabel" id="status">
                                            <property name="visible">True</property>
                                            <property name="can_focus">False</property>
                                            <property name="row_spacing">2</property>
                                            <property name="column_spacing">6</property>
                                            <child>
                                              <object class="GtkRadioButton" id="rbAllPages">
                                                <property name="label" translatable="yes" context="printdialog|rbAllPages">_All pages</property>
                                                <property name="visible">True</property>
                                                <property name="can_focus">True</property>
                                                <property name="receives_default">False</property>
                                                <property name="halign">start</property>
                                                <property name="margin_bottom">2</property>
                                                <property name="active">True</property>
                                                <property name="draw_indicator">True</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">0</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkRadioButton" id="rbRangePages">
                                                <property name="label" translatable="yes" context="printdialog|rbPageRange">_Pages:</property>
                                                <property name="visible">True</property>
                                                <property name="can_focus">True</property>
                                                <property name="receives_default">False</property>
                                                <property name="halign">start</property>
                                                <property name="margin_top">2</property>
                                                <property name="margin_bottom">2</property>
                                                <property name="active">True</property>
                                                <property name="draw_indicator">True</property>
                                                <property name="group">rbAllPages</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">1</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkEntry" id="pagerange">
                                                <property name="visible">True</property>
                                                <property name="can_focus">True</property>
                                                <property name="hexpand">True</property>
                                                <property name="activates_default">True</property>
                                                <property name="placeholder_text" translatable="yes" context="printdialog|pagerange">e.g.: 1, 3-5, 7, 9</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">1</property>
                                                <property name="top_attach">1</property>
                                                <property name="width">2</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkRadioButton" id="rbEvenPages">
                                                <property name="label" translatable="yes" context="printdialog|rmEvenPages">_Even pages</property>
                                                <property name="visible">True</property>
                                                <property name="can_focus">True</property>
                                                <property name="receives_default">False</property>
                                                <property name="halign">start</property>
                                                <property name="margin_top">2</property>
                                                <property name="margin_bottom">2</property>
                                                <property name="active">True</property>
                                                <property name="draw_indicator">True</property>
                                                <property name="group">rbAllPages</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">2</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkRadioButton" id="rbOddPages">
                                                <property name="label" translatable="yes" context="printdialog|rbOddPages">_Odd pages</property>
                                                <property name="visible">True</property>
                                                <property name="can_focus">True</property>
                                                <property name="receives_default">False</property>
                                                <property name="halign">start</property>
                                                <property name="margin_top">2</property>
                                                <property name="margin_bottom">2</property>
                                                <property name="active">True</property>
                                                <property name="draw_indicator">True</property>
                                                <property name="group">rbAllPages</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">3</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkLabel" id="fromwhich">
                                                <property name="can_focus">False</property>
                                                <property name="halign">start</property>
                                                <property name="label" translatable="yes" context="printdialog|fromwhich">_From which print:</property>
                                                <property name="use_underline">True</property>
                                                <property name="mnemonic_widget">printextrabox</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">6</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkComboBox" id="printextrabox">
                                                <property name="can_focus">False</property>
                                                <property name="hexpand">True</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">1</property>
                                                <property name="top_attach">6</property>
                                                <property name="width">2</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkLabel" id="labelpapersides">
                                                <property name="visible">True</property>
                                                <property name="can_focus">False</property>
                                                <property name="halign">start</property>
                                                <property name="label" translatable="yes" context="printdialog|labelpapersides">Paper _sides:</property>
                                                <property name="use_underline">True</property>
                                                <property name="mnemonic_widget">sidesbox</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">7</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkComboBox" id="sidesbox">
                                                <property name="visible">True</property>
                                                <property name="can_focus">False</property>
                                                <property name="hexpand">True</property>
                                                <property name="model">liststore4</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">1</property>
                                                <property name="top_attach">7</property>
                                                <property name="width">2</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkLabel" id="labelcopies">
                                                <property name="visible">True</property>
                                                <property name="can_focus">False</property>
                                                <property name="halign">start</property>
                                                <property name="label" translatable="yes" context="printdialog|labelcopies">_Number of copies:</property>
                                                <property name="use_underline">True</property>
                                                <property name="mnemonic_widget">copycount</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">8</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkSpinButton" id="copycount">
                                                <property name="visible">True</property>
                                                <property name="can_focus">True</property>
                                                <property name="valign">center</property>
                                                <property name="hexpand">True</property>
                                                <property name="activates_default">True</property>
                                                <property name="adjustment">adjustment2</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">1</property>
                                                <property name="top_attach">8</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkCheckButton" id="reverseorder">
                                                <property name="label" translatable="yes" context="printdialog|reverseorder">Print in _reverse order</property>
                                                <property name="visible">True</property>
                                                <property name="can_focus">True</property>
                                                <property name="receives_default">False</property>
                                                <property name="halign">start</property>
                                                <property name="use_underline">True</property>
                                                <property name="draw_indicator">True</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">1</property>
                                                <property name="top_attach">9</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkBox" id="box9">
                                                <property name="visible">True</property>
                                                <property name="can_focus">False</property>
                                                <property name="halign">end</property>
                                                <property name="spacing">4</property>
                                                <child>
                                                  <object class="GtkCheckButton" id="collate">
                                                    <property name="label" translatable="yes" context="printdialog|collate">_Collate</property>
                                                    <property name="visible">True</property>
                                                    <property name="can_focus">True</property>
                                                    <property name="receives_default">False</property>
                                                    <property name="use_underline">True</property>
                                                    <property name="draw_indicator">True</property>
                                                  </object>
                                                  <packing>
                                                    <property name="expand">False</property>
                                                    <property name="fill">True</property>
                                                    <property name="position">0</property>
                                                  </packing>
                                                </child>
                                                <child>
                                                  <object class="GtkImage" id="collateimage">
                                                    <property name="visible">True</property>
                                                    <property name="can_focus">False</property>
                                                    <property name="stock">gtk-missing-image</property>
                                                  </object>
                                                  <packing>
                                                    <property name="expand">False</property>
                                                    <property name="fill">True</property>
                                                    <property name="position">1</property>
                                                  </packing>
                                                </child>
                                              </object>
                                              <packing>
                                                <property name="left_attach">2</property>
                                                <property name="top_attach">8</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkLabel" id="cbPrintOrder">
                                                <property name="visible">True</property>
                                                <property name="can_focus">False</property>
                                                <property name="halign">start</property>
                                                <property name="label" translatable="yes" context="printdialog|cbPrintOrder">_Order:</property>
                                                <property name="use_underline">True</property>
                                                <property name="mnemonic_widget">reverseorder</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">9</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkSeparator">
                                                <property name="visible">True</property>
                                                <property name="can_focus">False</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">5</property>
                                                <property name="width">3</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkRadioButton" id="rbRangeSelection">
                                                <property name="label" translatable="yes" context="printdialog|rbRangeSelection">_Selection</property>
                                                <property name="can_focus">True</property>
                                                <property name="receives_default">False</property>
                                                <property name="halign">start</property>
                                                <property name="margin_top">2</property>
                                                <property name="draw_indicator">True</property>
                                                <property name="group">rbAllPages</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">4</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <placeholder/>
                                            </child>
                                            <child>
                                              <placeholder/>
                                            </child>
                                            <child>
                                              <placeholder/>
                                            </child>
                                            <child>
                                              <placeholder/>
                                            </child>
                                            <child>
                                              <placeholder/>
                                            </child>
                                            <child>
                                              <placeholder/>
                                            </child>
                                            <child>
                                              <placeholder/>
                                            </child>
                                            <child>
                                              <placeholder/>
                                            </child>
                                            <child>
                                              <placeholder/>
                                            </child>
                                            <property name="label" translatable="yes" context="printdialog|status">Default Printer</property>
                                            <accessibility>
                                              <relation type="labelled-by" target="labelstatus"/>
                                            </accessibility>
                                          </object>
                                          <packing>
                                            <property name="expand">False</property>
                                            <property name="fill">True</property>
                                            <property name="position">1</property>
                                          </packing>
                                        </child>
                                      </object>
                                    </child>
                                    <child type="label">
                                      <object class="GtkLabel" id="label2">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="label" translatable="yes" context="printdialog|label2">Range and Copies</property>
                                        <property name="mnemonic_widget">grid1</property>
                                        <attributes>
                                          <attribute name="weight" value="bold"/>
                                        </attributes>
                                      </object>
                                    </child>
                                  </object>
                                  <packing>
                                    <property name="expand">False</property>
                                    <property name="fill">True</property>
                                    <property name="position">1</property>
                                  </packing>
                                </child>
                                <child>
                                  <object class="GtkFrame" id="layoutframe">
                                    <property name="visible">True</property>
                                    <property name="can_focus">False</property>
                                    <property name="margin_left">6</property>
                                    <property name="margin_right">6</property>
                                    <property name="label_xalign">0</property>
                                    <property name="shadow_type">none</property>
                                    <child>
                                      <object class="GtkAlignment" id="alignment3">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="top_padding">6</property>
                                        <property name="left_padding">12</property>
                                        <child>
                                          <object class="GtkGrid" id="grid3">
                                          <object class="GtkButton" id="setup">
                                            <property name="label" translatable="yes" context="printdialog|setup">Properties...</property>
                                            <property name="visible">True</property>
                                            <property name="can_focus">False</property>
                                            <property name="row_spacing">6</property>
                                            <property name="column_spacing">6</property>
                                            <child>
                                              <object class="GtkLabel" id="labelorientation">
                                                <property name="visible">True</property>
                                                <property name="can_focus">False</property>
                                                <property name="halign">start</property>
                                                <property name="label" translatable="yes" context="printdialog|labelorientation">Orientation:</property>
                                                <property name="use_underline">True</property>
                                                <property name="mnemonic_widget">pageorientationbox</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">1</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkLabel" id="labelsize">
                                                <property name="visible">True</property>
                                                <property name="can_focus">False</property>
                                                <property name="halign">start</property>
                                                <property name="label" translatable="yes" context="printdialog|labelsize">Paper size:</property>
                                                <property name="use_underline">True</property>
                                                <property name="mnemonic_widget">papersizebox</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">0</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkLabel" id="labelorder">
                                                <property name="visible">True</property>
                                                <property name="can_focus">False</property>
                                                <property name="halign">start</property>
                                                <property name="label" translatable="yes" context="printdialog|labelorder">Order:</property>
                                                <property name="use_underline">True</property>
                                                <property name="mnemonic_widget">orderbox</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">6</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkComboBox" id="orderbox">
                                                <property name="visible">True</property>
                                                <property name="can_focus">False</property>
                                                <property name="hexpand">True</property>
                                                <property name="model">liststore2</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">1</property>
                                                <property name="top_attach">6</property>
                                                <property name="width">3</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="vcllo-ShowNupOrderWindow" id="orderpreview">
                                                <property name="visible">True</property>
                                                <property name="can_focus">False</property>
                                                <property name="halign">center</property>
                                                <property name="valign">start</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">4</property>
                                                <property name="top_attach">2</property>
                                                <property name="height">7</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkComboBox" id="pageorientationbox">
                                                <property name="visible">True</property>
                                                <property name="can_focus">False</property>
                                                <property name="model">liststore3</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">1</property>
                                                <property name="top_attach">1</property>
                                                <property name="width">4</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkComboBox" id="papersizebox">
                                                <property name="visible">True</property>
                                                <property name="can_focus">False</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">1</property>
                                                <property name="top_attach">0</property>
                                                <property name="width">4</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkLabel" id="pagemargintxt1">
                                                <property name="can_focus">False</property>
                                                <property name="halign">start</property>
                                                <property name="label" translatable="yes" context="printdialog|pagemargintxt1">Margin:</property>
                                                <property name="use_underline">True</property>
                                                <property name="mnemonic_widget">pagemarginsb:0mm</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">4</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkSpinButton" id="pagemarginsb:0mm">
                                                <property name="can_focus">True</property>
                                                <property name="activates_default">True</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">1</property>
                                                <property name="top_attach">4</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkLabel" id="sheetmargintxt1">
                                                <property name="can_focus">False</property>
                                                <property name="halign">start</property>
                                                <property name="label" translatable="yes" context="printdialog|sheetmargintxt1">Distance:</property>
                                                <property name="use_underline">True</property>
                                                <property name="mnemonic_widget">sheetmarginsb:0mm</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">5</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkSpinButton" id="sheetmarginsb:0mm">
                                                <property name="can_focus">True</property>
                                                <property name="activates_default">True</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">1</property>
                                                <property name="top_attach">5</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkLabel" id="pagemargintxt2">
                                                <property name="can_focus">False</property>
                                                <property name="halign">start</property>
                                                <property name="label" translatable="yes" context="printdialog|pagemargintxt2">between pages</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">2</property>
                                                <property name="top_attach">4</property>
                                                <property name="width">2</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkLabel" id="sheetmargintxt2">
                                                <property name="can_focus">False</property>
                                                <property name="halign">start</property>
                                                <property name="label" translatable="yes" context="printdialog|sheetmargintxt2">to sheet border</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">2</property>
                                                <property name="top_attach">5</property>
                                                <property name="width">2</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkRadioButton" id="brochure">
                                                <property name="label" translatable="yes" context="printdialog|brochure">Brochure</property>
                                                <property name="visible">True</property>
                                                <property name="can_focus">True</property>
                                                <property name="receives_default">False</property>
                                                <property name="halign">start</property>
                                                <property name="use_underline">True</property>
                                                <property name="draw_indicator">True</property>
                                                <property name="group">pagespersheetbtn</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">8</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkSpinButton" id="pagerows">
                                                <property name="can_focus">True</property>
                                                <property name="activates_default">True</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">1</property>
                                                <property name="top_attach">3</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkSpinButton" id="pagecols">
                                                <property name="can_focus">True</property>
                                                <property name="activates_default">True</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">3</property>
                                                <property name="top_attach">3</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkLabel" id="by">
                                                <property name="can_focus">False</property>
                                                <property name="label" translatable="yes" context="printdialog|by">by</property>
                                                <property name="use_underline">True</property>
                                                <property name="mnemonic_widget">pagecols</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">2</property>
                                                <property name="top_attach">3</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkCheckButton" id="bordercb">
                                                <property name="label" translatable="yes" context="printdialog|bordercb">Draw a border around each page</property>
                                                <property name="visible">True</property>
                                                <property name="can_focus">True</property>
                                                <property name="receives_default">False</property>
                                                <property name="halign">start</property>
                                                <property name="use_underline">True</property>
                                                <property name="draw_indicator">True</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">7</property>
                                                <property name="width">4</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkBox" id="box12">
                                                <property name="visible">True</property>
                                                <property name="can_focus">False</property>
                                                <property name="spacing">3</property>
                                                <child>
                                                  <object class="GtkRadioButton" id="pagespersheetbtn">
                                                    <property name="label" translatable="yes" context="printdialog|pagespersheetbtn">Pages per sheet:</property>
                                                    <property name="visible">True</property>
                                                    <property name="can_focus">True</property>
                                                    <property name="receives_default">False</property>
                                                    <property name="halign">start</property>
                                                    <property name="use_underline">True</property>
                                                    <property name="draw_indicator">True</property>
                                                    <property name="group">brochure</property>
                                                    <accessibility>
                                                      <relation type="label-for" target="pagespersheetbox"/>
                                                    </accessibility>
                                                  </object>
                                                  <packing>
                                                    <property name="expand">False</property>
                                                    <property name="fill">True</property>
                                                    <property name="position">0</property>
                                                  </packing>
                                                </child>
                                                <child>
                                                  <object class="GtkLabel" id="pagespersheettxt">
                                                    <property name="visible">True</property>
                                                    <property name="can_focus">False</property>
                                                  </object>
                                                  <packing>
                                                    <property name="expand">False</property>
                                                    <property name="fill">True</property>
                                                    <property name="position">1</property>
                                                  </packing>
                                                </child>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">2</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkLabel" id="pagestxt">
                                                <property name="can_focus">False</property>
                                                <property name="halign">start</property>
                                                <property name="label" translatable="yes" context="printdialog|pagespersheettxt">Pages:</property>
                                                <property name="use_underline">True</property>
                                                <property name="mnemonic_widget">pagerows</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">0</property>
                                                <property name="top_attach">3</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkComboBox" id="pagespersheetbox">
                                                <property name="visible">True</property>
                                                <property name="can_focus">False</property>
                                                <property name="hexpand">True</property>
                                                <property name="model">liststore1</property>
                                                <accessibility>
                                                  <relation type="labelled-by" target="pagespersheetbtn"/>
                                                </accessibility>
                                              </object>
                                              <packing>
                                                <property name="left_attach">1</property>
                                                <property name="top_attach">2</property>
                                                <property name="width">3</property>
                                              </packing>
                                            </child>
                                            <child>
                                              <object class="GtkComboBox" id="scriptdirection">
                                                <property name="can_focus">False</property>
                                              </object>
                                              <packing>
                                                <property name="left_attach">1</property>
                                                <property name="top_attach">8</property>
                                                <property name="width">3</property>
                                              </packing>
                                            </child>
                                            <property name="can_focus">True</property>
                                            <property name="receives_default">True</property>
                                            <property name="halign">end</property>
                                          </object>
                                          <packing>
                                            <property name="expand">False</property>
                                            <property name="fill">True</property>
                                            <property name="pack_type">end</property>
                                            <property name="position">2</property>
                                          </packing>
                                        </child>
                                      </object>
                                    </child>
                                    <child type="label">
                                      <object class="GtkLabel" id="label3">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="label" translatable="yes" context="printdialog|label3">Page Layout</property>
                                        <attributes>
                                          <attribute name="weight" value="bold"/>
                                        </attributes>
                                      </object>
                                      <packing>
                                        <property name="expand">False</property>
                                        <property name="fill">True</property>
                                        <property name="position">1</property>
                                      </packing>
                                    </child>
                                  </object>
                                  <packing>
                                    <property name="expand">False</property>
                                    <property name="fill">True</property>
                                    <property name="position">2</property>
                                  </packing>
                                </child>
                              </object>
                            </child>
                            <child type="label">
                              <object class="GtkLabel" id="labelprinter">
                                <property name="visible">True</property>
                                <property name="can_focus">False</property>
                                <property name="label" translatable="yes" context="printdialog|labelprinter">Printer</property>
                                <property name="use_underline">True</property>
                                <property name="mnemonic_widget">printersbox</property>
                                <attributes>
                                  <attribute name="weight" value="bold"/>
                                </attributes>
                              </object>
                            </child>
                          </object>
                          <packing>
                            <property name="expand">False</property>
                            <property name="fill">True</property>
                            <property name="position">0</property>
                          </packing>
                        </child>
                        <child>
                          <object class="GtkFrame" id="frPrintRange">
                            <property name="visible">True</property>
                            <property name="can_focus">False</property>
                            <property name="label_xalign">0</property>
                            <property name="shadow_type">none</property>
                            <child>
                              <object class="GtkAlignment" id="alPrintRange">
                                <property name="visible">True</property>
                                <property name="can_focus">False</property>
                                <property name="top_padding">6</property>
                                <property name="left_padding">12</property>
                                <child>
                                  <object class="GtkGrid" id="grid1">
                                    <property name="visible">True</property>
                                    <property name="can_focus">False</property>
                                    <property name="row_spacing">2</property>
                                    <property name="column_spacing">6</property>
                                    <child>
                                      <object class="GtkRadioButton" id="rbAllPages">
                                        <property name="label" translatable="yes" context="printdialog|rbAllPages">_All pages</property>
                                        <property name="visible">True</property>
                                        <property name="can_focus">True</property>
                                        <property name="receives_default">False</property>
                                        <property name="halign">start</property>
                                        <property name="margin_bottom">2</property>
                                        <property name="use_underline">True</property>
                                        <property name="active">True</property>
                                        <property name="draw_indicator">True</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">0</property>
                                        <property name="width">3</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkRadioButton" id="rbRangePages">
                                        <property name="label" translatable="yes" context="printdialog|rbPageRange">_Pages:</property>
                                        <property name="visible">True</property>
                                        <property name="can_focus">True</property>
                                        <property name="receives_default">False</property>
                                        <property name="halign">start</property>
                                        <property name="margin_top">2</property>
                                        <property name="margin_bottom">2</property>
                                        <property name="use_underline">True</property>
                                        <property name="draw_indicator">True</property>
                                        <property name="group">rbAllPages</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">1</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkEntry" id="pagerange">
                                        <property name="visible">True</property>
                                        <property name="can_focus">True</property>
                                        <property name="hexpand">True</property>
                                        <property name="activates_default">True</property>
                                        <property name="placeholder_text" translatable="yes" context="printdialog|pagerange">e.g.: 1, 3-5, 7, 9</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">1</property>
                                        <property name="top_attach">1</property>
                                        <property name="width">2</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkRadioButton" id="rbEvenPages">
                                        <property name="label" translatable="yes" context="printdialog|rmEvenPages">_Even pages</property>
                                        <property name="visible">True</property>
                                        <property name="can_focus">True</property>
                                        <property name="receives_default">False</property>
                                        <property name="halign">start</property>
                                        <property name="margin_top">2</property>
                                        <property name="margin_bottom">2</property>
                                        <property name="use_underline">True</property>
                                        <property name="draw_indicator">True</property>
                                        <property name="group">rbAllPages</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">2</property>
                                        <property name="width">3</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkRadioButton" id="rbOddPages">
                                        <property name="label" translatable="yes" context="printdialog|rbOddPages">_Odd pages</property>
                                        <property name="visible">True</property>
                                        <property name="can_focus">True</property>
                                        <property name="receives_default">False</property>
                                        <property name="halign">start</property>
                                        <property name="margin_top">2</property>
                                        <property name="margin_bottom">2</property>
                                        <property name="use_underline">True</property>
                                        <property name="draw_indicator">True</property>
                                        <property name="group">rbAllPages</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">3</property>
                                        <property name="width">3</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkLabel" id="fromwhich">
                                        <property name="can_focus">False</property>
                                        <property name="halign">start</property>
                                        <property name="label" translatable="yes" context="printdialog|fromwhich">_From which print:</property>
                                        <property name="use_underline">True</property>
                                        <property name="mnemonic_widget">printextrabox</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">6</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkComboBoxText" id="printextrabox">
                                        <property name="can_focus">False</property>
                                        <property name="hexpand">True</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">1</property>
                                        <property name="top_attach">6</property>
                                        <property name="width">2</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkLabel" id="labelpapersides">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="halign">start</property>
                                        <property name="label" translatable="yes" context="printdialog|labelpapersides">Paper _sides:</property>
                                        <property name="use_underline">True</property>
                                        <property name="mnemonic_widget">sidesbox</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">7</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkComboBoxText" id="sidesbox">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="hexpand">True</property>
                                        <items>
                                          <item translatable="yes" context="printdialog|liststore4">Print only in one side</item>
                                          <item translatable="yes" context="printdialog|liststore4">Print in both sides (long edge)</item>
                                          <item translatable="yes" context="printdialog|liststore4">Print in both sides (short edge)</item>
                                        </items>
                                      </object>
                                      <packing>
                                        <property name="left_attach">1</property>
                                        <property name="top_attach">7</property>
                                        <property name="width">2</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkLabel" id="labelcopies">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="halign">start</property>
                                        <property name="label" translatable="yes" context="printdialog|labelcopies">_Number of copies:</property>
                                        <property name="use_underline">True</property>
                                        <property name="mnemonic_widget">copycount</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">8</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkSpinButton" id="copycount">
                                        <property name="visible">True</property>
                                        <property name="can_focus">True</property>
                                        <property name="valign">center</property>
                                        <property name="hexpand">True</property>
                                        <property name="activates_default">True</property>
                                        <property name="text" translatable="no">1</property>
                                        <property name="adjustment">adjustment2</property>
                                        <property name="value">1</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">1</property>
                                        <property name="top_attach">8</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkCheckButton" id="reverseorder">
                                        <property name="label" translatable="yes" context="printdialog|reverseorder">Print in _reverse order</property>
                                        <property name="visible">True</property>
                                        <property name="can_focus">True</property>
                                        <property name="receives_default">False</property>
                                        <property name="halign">start</property>
                                        <property name="use_underline">True</property>
                                        <property name="draw_indicator">True</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">1</property>
                                        <property name="top_attach">9</property>
                                        <property name="width">2</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkBox" id="box9">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="halign">end</property>
                                        <property name="spacing">4</property>
                                        <child>
                                          <object class="GtkCheckButton" id="collate">
                                            <property name="label" translatable="yes" context="printdialog|collate">_Collate</property>
                                            <property name="visible">True</property>
                                            <property name="can_focus">True</property>
                                            <property name="receives_default">False</property>
                                            <property name="use_underline">True</property>
                                            <property name="draw_indicator">True</property>
                                          </object>
                                          <packing>
                                            <property name="expand">False</property>
                                            <property name="fill">True</property>
                                            <property name="position">0</property>
                                          </packing>
                                        </child>
                                        <child>
                                          <object class="GtkImage" id="collateimage">
                                            <property name="visible">True</property>
                                            <property name="can_focus">False</property>
                                            <property name="stock">gtk-missing-image</property>
                                          </object>
                                          <packing>
                                            <property name="expand">False</property>
                                            <property name="fill">True</property>
                                            <property name="position">1</property>
                                          </packing>
                                        </child>
                                      </object>
                                      <packing>
                                        <property name="left_attach">2</property>
                                        <property name="top_attach">8</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkLabel" id="cbPrintOrder">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="halign">start</property>
                                        <property name="label" translatable="yes" context="printdialog|cbPrintOrder">_Order:</property>
                                        <property name="use_underline">True</property>
                                        <property name="mnemonic_widget">reverseorder</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">9</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkSeparator">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="margin_top">3</property>
                                        <property name="margin_bottom">3</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">5</property>
                                        <property name="width">3</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkRadioButton" id="rbRangeSelection">
                                        <property name="label" translatable="yes" context="printdialog|rbRangeSelection">_Selection</property>
                                        <property name="can_focus">True</property>
                                        <property name="receives_default">False</property>
                                        <property name="halign">start</property>
                                        <property name="margin_top">2</property>
                                        <property name="use_underline">True</property>
                                        <property name="draw_indicator">True</property>
                                        <property name="group">rbAllPages</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">4</property>
                                        <property name="width">3</property>
                                      </packing>
                                    </child>
                                  </object>
                                </child>
                              </object>
                            </child>
                            <child type="label">
                              <object class="GtkLabel" id="label2">
                                <property name="visible">True</property>
                                <property name="can_focus">False</property>
                                <property name="label" translatable="yes" context="printdialog|label2">Range and Copies</property>
                                <property name="mnemonic_widget">grid1</property>
                                <attributes>
                                  <attribute name="weight" value="bold"/>
                                </attributes>
                              </object>
                            </child>
                          </object>
                          <packing>
                            <property name="expand">False</property>
                            <property name="fill">True</property>
                            <property name="position">1</property>
                          </packing>
                        </child>
                        <child>
                          <object class="GtkFrame" id="layoutframe">
                            <property name="visible">True</property>
                            <property name="can_focus">False</property>
                            <property name="label_xalign">0</property>
                            <property name="shadow_type">none</property>
                            <child>
                              <object class="GtkAlignment" id="alignment3">
                                <property name="visible">True</property>
                                <property name="can_focus">False</property>
                                <property name="top_padding">6</property>
                                <property name="left_padding">12</property>
                                <child>
                                  <object class="GtkGrid" id="grid3">
                                    <property name="visible">True</property>
                                    <property name="can_focus">False</property>
                                    <property name="row_spacing">6</property>
                                    <property name="column_spacing">6</property>
                                    <child>
                                      <object class="GtkLabel" id="labelorientation">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="halign">start</property>
                                        <property name="label" translatable="yes" context="printdialog|labelorientation">Orientation:</property>
                                        <property name="use_underline">True</property>
                                        <property name="mnemonic_widget">pageorientationbox</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">1</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkLabel" id="labelsize">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="halign">start</property>
                                        <property name="label" translatable="yes" context="printdialog|labelsize">Paper size:</property>
                                        <property name="use_underline">True</property>
                                        <property name="mnemonic_widget">papersizebox</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">0</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkLabel" id="labelorder">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="halign">start</property>
                                        <property name="label" translatable="yes" context="printdialog|labelorder">Order:</property>
                                        <property name="use_underline">True</property>
                                        <property name="mnemonic_widget">orderbox</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">6</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkComboBoxText" id="orderbox">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="hexpand">True</property>
                                        <items>
                                          <item translatable="yes" context="printdialog|liststore2">Left to right, then down</item>
                                          <item translatable="yes" context="printdialog|liststore2">Top to bottom, then right</item>
                                          <item translatable="yes" context="printdialog|liststore2">Top to bottom, then left</item>
                                          <item translatable="yes" context="printdialog|liststore2">Right to left, then down</item>
                                        </items>
                                      </object>
                                      <packing>
                                        <property name="left_attach">1</property>
                                        <property name="top_attach">6</property>
                                        <property name="width">3</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkDrawingArea" id="orderpreview">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="tooltip_text" translatable="yes" context="printdialog|collationpreview">Collation preview</property>
                                        <property name="halign">center</property>
                                        <property name="valign">start</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">4</property>
                                        <property name="top_attach">2</property>
                                        <property name="height">7</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkComboBoxText" id="pageorientationbox">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="active">0</property>
                                        <items>
                                          <item translatable="yes" context="printdialog|liststore3">Automatic</item>
                                          <item translatable="yes" context="printdialog|liststore3">Portrait</item>
                                          <item translatable="yes" context="printdialog|liststore3">Landscape</item>
                                        </items>
                                      </object>
                                      <packing>
                                        <property name="left_attach">1</property>
                                        <property name="top_attach">1</property>
                                        <property name="width">4</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkComboBoxText" id="papersizebox">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">1</property>
                                        <property name="top_attach">0</property>
                                        <property name="width">4</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkLabel" id="pagemargintxt1">
                                        <property name="can_focus">False</property>
                                        <property name="halign">start</property>
                                        <property name="label" translatable="yes" context="printdialog|pagemargintxt1">Margin:</property>
                                        <property name="use_underline">True</property>
                                        <property name="mnemonic_widget">pagemarginsb</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">4</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkSpinButton" id="pagemarginsb">
                                        <property name="can_focus">True</property>
                                        <property name="activates_default">True</property>
                                        <property name="text" translatable="no">0</property>
                                        <property name="adjustment">adjustment5</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">1</property>
                                        <property name="top_attach">4</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkLabel" id="sheetmargintxt1">
                                        <property name="can_focus">False</property>
                                        <property name="halign">start</property>
                                        <property name="label" translatable="yes" context="printdialog|sheetmargintxt1">Distance:</property>
                                        <property name="use_underline">True</property>
                                        <property name="mnemonic_widget">sheetmarginsb</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">5</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkSpinButton" id="sheetmarginsb">
                                        <property name="can_focus">True</property>
                                        <property name="activates_default">True</property>
                                        <property name="text" translatable="no">0</property>
                                        <property name="adjustment">adjustment6</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">1</property>
                                        <property name="top_attach">5</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkLabel" id="pagemargintxt2">
                                        <property name="can_focus">False</property>
                                        <property name="halign">start</property>
                                        <property name="label" translatable="yes" context="printdialog|pagemargintxt2">between pages</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">2</property>
                                        <property name="top_attach">4</property>
                                        <property name="width">2</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkLabel" id="sheetmargintxt2">
                                        <property name="can_focus">False</property>
                                        <property name="halign">start</property>
                                        <property name="label" translatable="yes" context="printdialog|sheetmargintxt2">to sheet border</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">2</property>
                                        <property name="top_attach">5</property>
                                        <property name="width">2</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkRadioButton" id="brochure">
                                        <property name="label" translatable="yes" context="printdialog|brochure">Brochure</property>
                                        <property name="visible">True</property>
                                        <property name="can_focus">True</property>
                                        <property name="receives_default">False</property>
                                        <property name="halign">start</property>
                                        <property name="use_underline">True</property>
                                        <property name="draw_indicator">True</property>
                                        <property name="group">pagespersheetbtn</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">8</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkSpinButton" id="pagerows">
                                        <property name="can_focus">True</property>
                                        <property name="activates_default">True</property>
                                        <property name="text" translatable="no">1</property>
                                        <property name="adjustment">adjustment3</property>
                                        <property name="value">1</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">1</property>
                                        <property name="top_attach">3</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkSpinButton" id="pagecols">
                                        <property name="can_focus">True</property>
                                        <property name="activates_default">True</property>
                                        <property name="text" translatable="no">1</property>
                                        <property name="adjustment">adjustment4</property>
                                        <property name="value">1</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">3</property>
                                        <property name="top_attach">3</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkLabel" id="by">
                                        <property name="can_focus">False</property>
                                        <property name="label" translatable="yes" context="printdialog|by">by</property>
                                        <property name="use_underline">True</property>
                                        <property name="mnemonic_widget">pagecols</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">2</property>
                                        <property name="top_attach">3</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkCheckButton" id="bordercb">
                                        <property name="label" translatable="yes" context="printdialog|bordercb">Draw a border around each page</property>
                                        <property name="visible">True</property>
                                        <property name="can_focus">True</property>
                                        <property name="receives_default">False</property>
                                        <property name="halign">start</property>
                                        <property name="use_underline">True</property>
                                        <property name="draw_indicator">True</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">7</property>
                                        <property name="width">4</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkBox" id="box12">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="spacing">3</property>
                                        <child>
                                          <object class="GtkRadioButton" id="pagespersheetbtn">
                                            <property name="label" translatable="yes" context="printdialog|pagespersheetbtn">Pages per sheet:</property>
                                            <property name="visible">True</property>
                                            <property name="can_focus">True</property>
                                            <property name="receives_default">False</property>
                                            <property name="halign">start</property>
                                            <property name="use_underline">True</property>
                                            <property name="active">True</property>
                                            <property name="draw_indicator">True</property>
                                            <accessibility>
                                              <relation type="label-for" target="pagespersheetbox"/>
                                            </accessibility>
                                          </object>
                                          <packing>
                                            <property name="expand">False</property>
                                            <property name="fill">True</property>
                                            <property name="position">0</property>
                                          </packing>
                                        </child>
                                        <child>
                                          <object class="GtkLabel" id="pagespersheettxt">
                                            <property name="visible">True</property>
                                            <property name="can_focus">False</property>
                                          </object>
                                          <packing>
                                            <property name="expand">False</property>
                                            <property name="fill">True</property>
                                            <property name="position">1</property>
                                          </packing>
                                        </child>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">2</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkLabel" id="pagestxt">
                                        <property name="can_focus">False</property>
                                        <property name="halign">start</property>
                                        <property name="label" translatable="yes" context="printdialog|pagespersheettxt">Pages:</property>
                                        <property name="use_underline">True</property>
                                        <property name="mnemonic_widget">pagerows</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">0</property>
                                        <property name="top_attach">3</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkComboBoxText" id="pagespersheetbox">
                                        <property name="visible">True</property>
                                        <property name="can_focus">False</property>
                                        <property name="hexpand">True</property>
                                        <property name="active">0</property>
                                        <items>
                                          <item id="1" context="printdialog|liststore1">1</item>
                                          <item id="2" context="printdialog|liststore1">2</item>
                                          <item id="4" context="printdialog|liststore1">4</item>
                                          <item id="6" context="printdialog|liststore1">6</item>
                                          <item id="9" context="printdialog|liststore1">9</item>
                                          <item id="16" context="printdialog|liststore1">16</item>
                                          <item id="65535" translatable="yes" context="printdialog|liststore1">Custom</item>
                                        </items>
                                        <accessibility>
                                          <relation type="labelled-by" target="pagespersheetbtn"/>
                                        </accessibility>
                                      </object>
                                      <packing>
                                        <property name="left_attach">1</property>
                                        <property name="top_attach">2</property>
                                        <property name="width">3</property>
                                      </packing>
                                    </child>
                                    <child>
                                      <object class="GtkComboBoxText" id="scriptdirection">
                                        <property name="can_focus">False</property>
                                      </object>
                                      <packing>
                                        <property name="left_attach">1</property>
                                        <property name="top_attach">8</property>
                                        <property name="width">3</property>
                                      </packing>
                                    </child>
                                  </object>
                                </child>
                              </object>
                            </child>
                            <child type="label">
                              <object class="GtkLabel" id="label3">
                                <property name="visible">True</property>
                                <property name="can_focus">False</property>
                                <property name="label" translatable="yes" context="printdialog|label3">Page Layout</property>
                                <attributes>
                                  <attribute name="weight" value="bold"/>
                                </attributes>
                              </object>
                            </child>
                          </object>
                          <packing>
                            <property name="expand">False</property>
                            <property name="fill">True</property>
                            <property name="position">2</property>
                          </packing>
                        </child>
                      </object>
                    </child>
@@ -1259,10 +1187,10 @@
                      </packing>
                    </child>
                    <child type="tab">
                      <object class="GtkLabel" id="customlabel">
                      <object class="GtkLabel" id="custom">
                        <property name="visible">True</property>
                        <property name="can_focus">False</property>
                        <property name="label" translatable="yes" context="printdialog|customlabel">custom</property>
                        <property name="label">custom</property>
                      </object>
                      <packing>
                        <property name="position">1</property>
@@ -1293,4 +1221,12 @@
      </object>
    </child>
  </object>
  <object class="GtkTreeStore" id="liststore1">
    <columns>
      <!-- column-name text -->
      <column type="gchararray"/>
      <!-- column-name id -->
      <column type="gchararray"/>
    </columns>
  </object>
</interface>
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 7b5356b..7e4741f 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -5024,26 +5024,6 @@ private:
        return OString(pStr, pStr ? strlen(pStr) : 0);
    }

    OString get_page_ident(int nPage) const
    {
        auto nMainLen = gtk_notebook_get_n_pages(m_pNotebook);
        auto nOverFlowLen = m_bOverFlowBoxActive ? gtk_notebook_get_n_pages(m_pOverFlowNotebook) - 1 : 0;
        if (m_bOverFlowBoxIsStart)
        {
            if (nPage < nOverFlowLen)
                return get_page_ident(m_pOverFlowNotebook, nPage);
            nPage -= nOverFlowLen;
            return get_page_ident(m_pNotebook, nPage);
        }
        else
        {
            if (nPage < nMainLen)
                return get_page_ident(m_pNotebook, nPage);
            nPage -= nMainLen;
            return get_page_ident(m_pOverFlowNotebook, nPage);
        }
    }

    static gint get_page_number(GtkNotebook *pNotebook, const OString& rIdent)
    {
        gint nPages = gtk_notebook_get_n_pages(pNotebook);
@@ -5070,6 +5050,11 @@ private:
        return OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8);
    }

    static void set_tab_label_text(GtkNotebook *pNotebook, guint nPage, const OUString& rText)
    {
        gtk_notebook_set_tab_label_text(pNotebook, gtk_notebook_get_nth_page(pNotebook, nPage), rText.toUtf8().getStr());
    }

    void append_useless_page(GtkNotebook *pNotebook)
    {
        disable_notify_events();
@@ -5381,6 +5366,26 @@ public:
        return nPage;
    }

    virtual OString get_page_ident(int nPage) const override
    {
        auto nMainLen = gtk_notebook_get_n_pages(m_pNotebook);
        auto nOverFlowLen = m_bOverFlowBoxActive ? gtk_notebook_get_n_pages(m_pOverFlowNotebook) - 1 : 0;
        if (m_bOverFlowBoxIsStart)
        {
            if (nPage < nOverFlowLen)
                return get_page_ident(m_pOverFlowNotebook, nPage);
            nPage -= nOverFlowLen;
            return get_page_ident(m_pNotebook, nPage);
        }
        else
        {
            if (nPage < nMainLen)
                return get_page_ident(m_pNotebook, nPage);
            nPage -= nMainLen;
            return get_page_ident(m_pOverFlowNotebook, nPage);
        }
    }

    virtual OString get_current_page_ident() const override
    {
        return get_page_ident(get_current_page());
@@ -5475,6 +5480,21 @@ public:
        return OUString();
    }

    virtual void set_tab_label_text(const OString& rIdent, const OUString& rText) override
    {
        gint nPageNum = get_page_number(m_pNotebook, rIdent);
        if (nPageNum != -1)
        {
            set_tab_label_text(m_pNotebook, nPageNum, rText);
            return;
        }
        nPageNum = get_page_number(m_pOverFlowNotebook, rIdent);
        if (nPageNum != -1)
        {
            set_tab_label_text(m_pOverFlowNotebook, nPageNum, rText);
        }
    }

    virtual void disable_notify_events() override
    {
        g_signal_handler_block(m_pNotebook, m_nSwitchPageSignalId);