tdf#129162 PDF Export: Disable range when whole-sheet export is active

Added ToggleSinglePageSheetsHdl in impdialog.hxx and implemented it in
impdialog.cxx following the pattern of ToggleAddStreamHdl. The handler
disables all range widgets when 'Whole sheet export' is active, as it
overrides sheet selection entirely. A new variable
bDialogUsedThisSession was introduced that checks if the user had used
the dialog to export as pdf once in the current session. This was done
so as to always initialize the 'whole sheet export' to false on dialog
pop up for first time on current session, and then to persist the user
selected state throughout the sesssion and reset on session restart.
Also added a test to check for the disabling of range field in
calc_tests4 folder under the method test_singlePageSheetsDisablesRange.
Change the following files:
filter/source/pdf/impdialog.cxx
filter/source/pdf/impdialog.hxx
sc/qa/uitest/calc_tests4/tdf129162_singlepagesheets_disables_range_options.py

Change-Id: I81390ff1d173ac05d7178440775efa1dbbf106bd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202286
Reviewed-by: Jonathan Clark <jonathan@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Sampath-1984
2026-04-25 09:22:47 +02:00
committed by Ilmari Lauhakangas
parent 9d510964a9
commit 938a0f670d
3 changed files with 61 additions and 1 deletions
+18 -1
View File
@@ -60,6 +60,7 @@ using namespace ::com::sun::star::uno;
Please note: the default used here are the same as per specification,
They should be the same in PDFFilter::implExport and in PDFExport::PDFExport
*/
static bool bDialogUsedThisSession = false;
ImpPDFTabDialog::ImpPDFTabDialog(weld::Window* pParent, const Sequence< PropertyValue >& rFilterData,
const Reference< XComponent >& rxDoc)
: SfxTabDialogController(pParent, u"filter/ui/pdfoptionsdialog.ui"_ustr, u"PdfOptionsDialog"_ustr)
@@ -722,8 +723,10 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent)
mxEdSheets->show();
mxCbSinglePageSheets->show();
mxCbSinglePageSheets->set_active(pParent->mbSinglePageSheets);
mxCbSinglePageSheets->set_active(bDialogUsedThisSession ? pParent->mbSinglePageSheets : false);
mxCbSinglePageSheets->set_sensitive(!pParent->maConfigItem.IsReadOnly(u"SinglePageSheets"_ustr));
mxCbSinglePageSheets->connect_toggled(LINK(this, ImpPDFTabGeneralPage, ToggleSinglePageSheetsHdl));
ToggleSinglePageSheetsHdl(*mxCbSinglePageSheets);
}
else
{
@@ -766,7 +769,10 @@ void ImpPDFTabGeneralPage::GetFilterConfigItem( ImpPDFTabDialog* pParent )
pParent->mbExportHiddenSlides = mxCbExportHiddenSlides->get_active();
if (mbIsSpreadsheet)
{
pParent->mbSinglePageSheets = mxCbSinglePageSheets->get_active();
bDialogUsedThisSession = true;
}
pParent->mbIsSkipEmptyPages = !mxCbExportEmptyPages->get_active();
pParent->mbIsExportPlaceholders = mxCbExportPlaceholders->get_active();
@@ -947,6 +953,17 @@ IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleAddStreamHdl, weld::Toggleable&, voi
}
}
IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleSinglePageSheetsHdl, weld::Toggleable&, void)
{
const bool bSinglePageSheets = mxCbSinglePageSheets->get_active();
mxRbAll->set_sensitive(!bSinglePageSheets);
mxRbPageRange->set_sensitive(!bSinglePageSheets);
mxRbSheetRange->set_sensitive(!bSinglePageSheets);
mxRbSelection->set_sensitive(!bSinglePageSheets);
mxEdPages->set_sensitive(!bSinglePageSheets && mxRbPageRange->get_active());
mxEdSheets->set_sensitive(!bSinglePageSheets && mxRbSheetRange->get_active());
}
void ImpPDFTabGeneralPage::thePDFVersionChanged()
{
const bool bIsPDFA = IsPdfaSelected();
+1
View File
@@ -234,6 +234,7 @@ class ImpPDFTabGeneralPage : public SfxTabPage
DECL_LINK(ToggleReduceImageResolutionHdl, weld::Toggleable&, void);
DECL_LINK(ToggleWatermarkHdl, weld::Toggleable&, void);
DECL_LINK(ToggleAddStreamHdl, weld::Toggleable&, void);
DECL_LINK(ToggleSinglePageSheetsHdl, weld::Toggleable&, void);
DECL_LINK(ToggleExportFormFieldsHdl, weld::Toggleable&, void);
DECL_LINK(ToggleExportNotesPagesHdl, weld::Toggleable&, void);
@@ -0,0 +1,42 @@
# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
#from uitest.framework import UITestCase
#from uitest.uihelper.common import get_state_as_dict
#from libreoffice.uno.propertyvalue import mkPropertyValues
import os
from tempfile import TemporaryDirectory
from uitest.framework import UITestCase
from uitest.uihelper.calc import enter_text_to_cell
from uitest.uihelper.common import get_state_as_dict
from libreoffice.uno.propertyvalue import mkPropertyValues
from org.libreoffice.unotest import systemPathToFileUrl
class tdf129162(UITestCase):
def test_singlePageSheetsDisablesRangeOptions(self):
with self.ui_test.create_doc_in_start_center("calc"):
with self.ui_test.execute_dialog_through_command('.uno:ExportToPDF', close_button="cancel") as xDialog:
rangeChildren = ['all', 'pagerange', 'sheetrange', 'selection']
self.assertEqual("false", get_state_as_dict(xDialog.getChild('singlepagesheets'))['Selected'])
for child in rangeChildren:
self.assertEqual("true", get_state_as_dict(xDialog.getChild(child))['Enabled'])
xDialog.getChild('singlepagesheets').executeAction('CLICK', mkPropertyValues({}))
self.assertEqual("true", get_state_as_dict(xDialog.getChild('singlepagesheets'))['Selected'])
for child in rangeChildren:
self.assertEqual("false", get_state_as_dict(xDialog.getChild(child))['Enabled'])
xDialog.getChild('singlepagesheets').executeAction('CLICK', mkPropertyValues({}))
self.assertEqual("false", get_state_as_dict(xDialog.getChild('singlepagesheets'))['Selected'])
for child in rangeChildren:
self.assertEqual("true", get_state_as_dict(xDialog.getChild(child))['Enabled'])
# vim: set shiftwidth=4 softtabstop=4 expandtab: