tdf#54908 Make selection active if there's a selection (Writer)

If the user make a selection in Writer and then opens print dialog or PDF
export dialog, Print Selection is the default option.

Change-Id: I46ba90cfeabafef1c05dd3e5008ecf55f177a146
Reviewed-on: https://gerrit.libreoffice.org/64804
Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
Tested-by: Jenkins
(cherry picked from commit f50363c7008c239d302944144beb256de6a55f38)
Reviewed-on: https://gerrit.libreoffice.org/76879
Reviewed-by: Xisco FaulĂ­ <xiscofauli@libreoffice.org>
diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx
index 213f2cc..14738ff 100644
--- a/filter/source/pdf/impdialog.cxx
+++ b/filter/source/pdf/impdialog.cxx
@@ -503,8 +503,9 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent)
    mxRbAll->connect_toggled( LINK( this, ImpPDFTabGeneralPage, ToggleAllHdl ) );
    TogglePagesHdl();

    mxRbSelection->set_sensitive( pParent->mbSelectionPresent );
    if ( pParent->mbSelectionPresent )
    const bool bSelectionPresent = pParent->mbSelectionPresent;
    mxRbSelection->set_sensitive( bSelectionPresent );
    if ( bSelectionPresent )
        mxRbSelection->connect_toggled( LINK( this, ImpPDFTabGeneralPage, ToggleSelectionHdl ) );
    mbIsPresentation = pParent->mbIsPresentation;
    mbIsWriter = pParent->mbIsWriter;
@@ -611,7 +612,12 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent)
    }

    mxCbExportPlaceholders->set_visible(mbIsWriter);
    if( !mbIsWriter )
    if( mbIsWriter )
    {
        // tdf#54908 Make selection active if there is a selection in Writer's version
        mxRbSelection->set_active( bSelectionPresent );
    }
    else
    {
        mxCbExportPlaceholders->set_active(false);
    }
diff --git a/sw/source/core/view/printdata.cxx b/sw/source/core/view/printdata.cxx
index 44f34d1..2e9d9d3 100644
--- a/sw/source/core/view/printdata.cxx
+++ b/sw/source/core/view/printdata.cxx
@@ -301,7 +301,8 @@ SwPrintUIOptions::SwPrintUIOptions(
    aWidgetIds[4] = "rbRangeSelection";
    m_aUIProperties[nIdx++].Value = setChoiceRadiosControlOpt(aWidgetIds, OUString(),
                                                        aHelpIds, aPrintRangeName,
                                                        aChoices, 0 /* always default to 'All pages' */,
                                                        aChoices,
                                                        bHasSelection ? 4 : 0,
                                                        aChoicesDisabled);

    // show an Edit dependent on "Pages" selected