filter/source/pdf/impdialog.cxx | 62 +++++++++++++++++++++++------- filter/source/pdf/impdialog.hxx | 12 ++++- filter/source/pdf/pdfexport.cxx | 9 ++++ filter/uiconfig/ui/pdfgeneralpage.ui | 62 ++++++++++++++++++++++++++---- offapi/UnoApi_offapi.mk | 1 offapi/com/sun/star/sheet/XSheetRange.idl | 42 ++++++++++++++++++++ sc/inc/viewuno.hxx | 5 ++ sc/qa/uitest/calc_tests4/exportToPDF.py | 2 sc/source/ui/unoobj/docuno.cxx | 13 +++++- sc/source/ui/unoobj/viewuno.cxx | 32 +++++++++++++++ sc/source/ui/view/printfun.cxx | 2 sd/qa/uitest/impress_tests/exportToPDF.py | 2 sw/qa/uitest/writer_tests4/exportToPDF.py | 2 13 files changed, 217 insertions(+), 29 deletions(-)
New commits: commit 13bd849f60286c49457c290218e5b7acf9cadba8 Author: NickWingate <nick.wing...@collabora.com> AuthorDate: Tue Aug 29 15:31:08 2023 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Thu Dec 21 10:49:16 2023 +0100 Add export sheet range option to calc User can specify which sheets to export e.g. '2-5,7' exports sheets 2,3,4,5,7. Note: this is different from exporting pages as one sheet may contain several pages worth of content. Also fix a bug where exporting only a selected sheet causes the next sheet to be exported. e.g.: Sheet 1 is empty, Sheet 2 has content. Exporting Sheet 1 results in Sheet 2's content being exported Signed-off-by: NickWingate <nick.wing...@collabora.com> Change-Id: Iecd42188ddbbbcd70eb37bec80783e29e3cb5b19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156255 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Szymon Kłos <szymon.k...@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159686 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx index c7149b0ca534..c4e133297e95 100644 --- a/filter/source/pdf/impdialog.cxx +++ b/filter/source/pdf/impdialog.cxx @@ -108,8 +108,10 @@ ImpPDFTabDialog::ImpPDFTabDialog(weld::Window* pParent, const Sequence< Property mbCanCopyOrExtract( false ), mbCanExtractForAccessibility( true ), - mbIsRangeChecked( false ), + mbIsPageRangeChecked( false ), msPageRange( ' ' ), + mbIsSheetRangeChecked( false ), + msSheetRange( ' ' ), mbSelectionIsChecked( false ), mbExportRelativeFsysLinks( false ), @@ -506,8 +508,10 @@ Sequence< PropertyValue > ImpPDFTabDialog::GetFilterData() comphelper::makePropertyValue("RestrictPermissions", mbRestrictPermissions), comphelper::makePropertyValue("PreparedPermissionPassword", maPreparedOwnerPassword) }; - if( mbIsRangeChecked ) + if( mbIsPageRangeChecked ) aRet.push_back(comphelper::makePropertyValue("PageRange", msPageRange)); + if( mbIsSheetRangeChecked ) + aRet.push_back(comphelper::makePropertyValue("SheetRange", msSheetRange)); else if( mbSelectionIsChecked ) aRet.push_back(comphelper::makePropertyValue("Selection", maSelection)); @@ -531,9 +535,11 @@ ImpPDFTabGeneralPage::ImpPDFTabGeneralPage(weld::Container* pPage, weld::DialogC , mbIsWriter(false) , mpParent(nullptr) , mxRbAll(m_xBuilder->weld_radio_button("all")) - , mxRbRange(m_xBuilder->weld_radio_button("range")) + , mxRbPageRange(m_xBuilder->weld_radio_button("pagerange")) + , mxRbSheetRange(m_xBuilder->weld_radio_button("sheetrange")) , mxRbSelection(m_xBuilder->weld_radio_button("selection")) , mxEdPages(m_xBuilder->weld_entry("pages")) + , mxEdSheets(m_xBuilder->weld_entry("sheets")) , mxRbLosslessCompression(m_xBuilder->weld_radio_button("losslesscompress")) , mxRbJPEGCompression(m_xBuilder->weld_radio_button("jpegcompress")) , mxQualityFrame(m_xBuilder->weld_widget("qualityframe")) @@ -564,7 +570,7 @@ ImpPDFTabGeneralPage::ImpPDFTabGeneralPage(weld::Container* pPage, weld::DialogC , mxFtWatermark(m_xBuilder->weld_label("watermarklabel")) , mxEdWatermark(m_xBuilder->weld_entry("watermarkentry")) , mxSlidesFt(m_xBuilder->weld_label("slides")) - , mxSheetsFt(m_xBuilder->weld_label("selectedsheets")) + , mxSheetsSelectionFt(m_xBuilder->weld_label("selectedsheets")) { } @@ -579,11 +585,13 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent) mpParent = pParent; // init this class data - mxRbRange->connect_toggled( LINK( this, ImpPDFTabGeneralPage, TogglePagesHdl ) ); + mxRbPageRange->connect_toggled( LINK( this, ImpPDFTabGeneralPage, TogglePagesHdl ) ); + mxRbSheetRange->connect_toggled( LINK( this, ImpPDFTabGeneralPage, ToggleSheetsHdl ) ); mxRbAll->set_active(true); mxRbAll->connect_toggled( LINK( this, ImpPDFTabGeneralPage, ToggleAllHdl ) ); TogglePagesHdl(); + ToggleSheetsHdl(); mxRbSelection->set_sensitive( pParent->mbSelectionPresent ); if ( pParent->mbSelectionPresent ) @@ -687,7 +695,7 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent) if ( mbIsPresentation ) { - mxRbRange->set_label(mxSlidesFt->get_label()); + mxRbPageRange->set_label(mxSlidesFt->get_label()); mxCbExportNotesPages->show(); mxCbExportNotesPages->set_active(pParent->mbExportNotesPages); mxCbExportNotesPages->connect_toggled( LINK(this, ImpPDFTabGeneralPage, ToggleExportNotesPagesHdl ) ); @@ -714,10 +722,13 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent) if( mbIsSpreadsheet ) { - mxRbSelection->set_label(mxSheetsFt->get_label()); + mxRbSelection->set_label(mxSheetsSelectionFt->get_label()); // tdf#105965 Make Selection/Selected sheets the default PDF export range setting for spreadsheets mxRbSelection->set_active(true); + mxRbSheetRange->show(); + mxEdSheets->show(); + mxCbSinglePageSheets->show(); mxCbSinglePageSheets->set_active(pParent->mbSinglePageSheets); mxCbSinglePageSheets->set_sensitive(!pParent->maConfigItem.IsReadOnly("SinglePageSheets")); @@ -726,6 +737,9 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent) { mxCbSinglePageSheets->hide(); mxCbSinglePageSheets->set_active(false); + mxRbSheetRange->hide(); + mxRbSheetRange->set_active(false); + mxEdSheets->hide(); } mxCbExportEmptyPages->set_active(!pParent->mbIsSkipEmptyPages); @@ -773,12 +787,17 @@ void ImpPDFTabGeneralPage::GetFilterConfigItem( ImpPDFTabDialog* pParent ) pParent->mbIsExportPlaceholders = mxCbExportPlaceholders->get_active(); pParent->mbAddStream = mxCbAddStream->get_visible() && mxCbAddStream->get_active(); - pParent->mbIsRangeChecked = false; - if( mxRbRange->get_active() ) + pParent->mbIsPageRangeChecked = false; + if( mxRbPageRange->get_active() ) { - pParent->mbIsRangeChecked = true; + pParent->mbIsPageRangeChecked = true; pParent->msPageRange = mxEdPages->get_text(); //FIXME all right on other languages ? } + else if ( mxRbSheetRange->get_active() ) + { + pParent->mbIsSheetRangeChecked = true; + pParent->msSheetRange = mxEdSheets->get_text(); + } else if( mxRbSelection->get_active() ) { pParent->mbSelectionIsChecked = mxRbSelection->get_active(); @@ -841,6 +860,12 @@ IMPL_LINK_NOARG(ImpPDFTabGeneralPage, TogglePagesHdl, weld::Toggleable&, void) EnableExportNotesPages(); } +IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleSheetsHdl, weld::Toggleable&, void) +{ + ToggleSheetsHdl(); + EnableExportNotesPages(); +} + IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleSelectionHdl, weld::Toggleable&, void) { EnableExportNotesPages(); @@ -848,11 +873,18 @@ IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleSelectionHdl, weld::Toggleable&, voi void ImpPDFTabGeneralPage::TogglePagesHdl() { - mxEdPages->set_sensitive( mxRbRange->get_active() ); - if (mxRbRange->get_active()) + mxEdPages->set_sensitive( mxRbPageRange->get_active() ); + if (mxRbPageRange->get_active()) mxEdPages->grab_focus(); } +void ImpPDFTabGeneralPage::ToggleSheetsHdl() +{ + mxEdSheets->set_sensitive( mxRbSheetRange->get_active() ); + if (mxRbSheetRange->get_active()) + mxEdSheets->grab_focus(); +} + void ImpPDFTabGeneralPage::EnableExportNotesPages() { if ( mbIsPresentation ) @@ -915,7 +947,8 @@ IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleAddStreamHdl, weld::Toggleable&, voi if( mxCbAddStream->get_active() ) { mxRbAll->set_active(true); - mxRbRange->set_sensitive( false ); + mxRbPageRange->set_sensitive( false ); + mxRbSheetRange->set_sensitive( false ); mxRbSelection->set_sensitive( false ); mxEdPages->set_sensitive( false ); mxRbAll->set_sensitive( false ); @@ -923,7 +956,8 @@ IMPL_LINK_NOARG(ImpPDFTabGeneralPage, ToggleAddStreamHdl, weld::Toggleable&, voi else { mxRbAll->set_sensitive(true); - mxRbRange->set_sensitive(true); + mxRbPageRange->set_sensitive(true); + mxRbSheetRange->set_sensitive(true); mxRbSelection->set_sensitive(true); } } diff --git a/filter/source/pdf/impdialog.hxx b/filter/source/pdf/impdialog.hxx index 8cbfc0af987f..95d25f99d705 100644 --- a/filter/source/pdf/impdialog.hxx +++ b/filter/source/pdf/impdialog.hxx @@ -128,8 +128,10 @@ class ImpPDFTabDialog final : public SfxTabDialogController bool mbCanExtractForAccessibility; css::uno::Reference< css::beans::XMaterialHolder > mxPreparedPasswords; - bool mbIsRangeChecked; + bool mbIsPageRangeChecked; OUString msPageRange; + bool mbIsSheetRangeChecked; + OUString msSheetRange; bool mbSelectionIsChecked; bool mbExportRelativeFsysLinks; @@ -184,9 +186,11 @@ class ImpPDFTabGeneralPage : public SfxTabPage ImpPDFTabDialog* mpParent; std::unique_ptr<weld::RadioButton> mxRbAll; - std::unique_ptr<weld::RadioButton> mxRbRange; + std::unique_ptr<weld::RadioButton> mxRbPageRange; + std::unique_ptr<weld::RadioButton> mxRbSheetRange; std::unique_ptr<weld::RadioButton> mxRbSelection; std::unique_ptr<weld::Entry> mxEdPages; + std::unique_ptr<weld::Entry> mxEdSheets; std::unique_ptr<weld::RadioButton> mxRbLosslessCompression; std::unique_ptr<weld::RadioButton> mxRbJPEGCompression; std::unique_ptr<weld::Widget> mxQualityFrame; @@ -217,10 +221,11 @@ class ImpPDFTabGeneralPage : public SfxTabPage std::unique_ptr<weld::Label> mxFtWatermark; std::unique_ptr<weld::Entry> mxEdWatermark; std::unique_ptr<weld::Label> mxSlidesFt; - std::unique_ptr<weld::Label> mxSheetsFt; + std::unique_ptr<weld::Label> mxSheetsSelectionFt; DECL_LINK(ToggleAllHdl, weld::Toggleable&, void); DECL_LINK(TogglePagesHdl, weld::Toggleable&, void); + DECL_LINK(ToggleSheetsHdl, weld::Toggleable&, void); DECL_LINK(ToggleSelectionHdl, weld::Toggleable&, void); DECL_LINK(ToggleCompressionHdl, weld::Toggleable&, void); DECL_LINK(ToggleReduceImageResolutionHdl, weld::Toggleable&, void); @@ -230,6 +235,7 @@ class ImpPDFTabGeneralPage : public SfxTabPage DECL_LINK(ToggleExportNotesPagesHdl, weld::Toggleable&, void); void TogglePagesHdl(); + void ToggleSheetsHdl(); void EnableExportNotesPages(); DECL_LINK(TogglePDFVersionOrUniversalAccessibilityHandle, weld::Toggleable&, void); diff --git a/filter/source/pdf/pdfexport.cxx b/filter/source/pdf/pdfexport.cxx index 7d07f8182bdc..1459590b2f23 100644 --- a/filter/source/pdf/pdfexport.cxx +++ b/filter/source/pdf/pdfexport.cxx @@ -59,6 +59,7 @@ #include <com/sun/star/io/XOutputStream.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/drawing/XShapes.hpp> +#include <com/sun/star/sheet/XSheetRange.hpp> #include <com/sun/star/security/XCertificate.hpp> #include <com/sun/star/beans/XMaterialHolder.hpp> #include <com/sun/star/xml/crypto/SEInitializer.hpp> @@ -518,6 +519,14 @@ bool PDFExport::Export( const OUString& rFile, const Sequence< PropertyValue >& { if ( rProp.Name == "PageRange" ) rProp.Value >>= aPageRange; + else if ( rProp.Name == "SheetRange" ) + { + Reference< frame::XController > xController( Reference< frame::XModel >( mxSrcDoc, UNO_QUERY_THROW )->getCurrentController() ); + Reference< sheet::XSheetRange > xView( xController, UNO_QUERY); + OUString aSheetRange; + rProp.Value >>= aSheetRange; + aSelection = xView->getSelectionFromString(aSheetRange); + } else if ( rProp.Name == "Selection" ) aSelection = rProp.Value; else if ( rProp.Name == "UseLosslessCompression" ) diff --git a/filter/uiconfig/ui/pdfgeneralpage.ui b/filter/uiconfig/ui/pdfgeneralpage.ui index 40c5fc4eb47d..f09113793d07 100644 --- a/filter/uiconfig/ui/pdfgeneralpage.ui +++ b/filter/uiconfig/ui/pdfgeneralpage.ui @@ -60,8 +60,8 @@ </packing> </child> <child> - <object class="GtkRadioButton" id="range"> - <property name="label" translatable="yes" context="pdfgeneralpage|range">_Pages:</property> + <object class="GtkRadioButton" id="pagerange"> + <property name="label" translatable="yes" context="pdfgeneralpage|pagerange">_Pages:</property> <property name="visible">True</property> <property name="can-focus">True</property> <property name="receives-default">False</property> @@ -74,8 +74,8 @@ <relation type="label-for" target="pages"/> </accessibility> <child internal-child="accessible"> - <object class="AtkObject" id="range-atkobject"> - <property name="AtkObject::accessible-description" translatable="yes" context="pdfgeneralpage|extended_tip|range">Exports the pages you type in the box.</property> + <object class="AtkObject" id="pagerange-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="pdfgeneralpage|extended_tip|pagerange">Exports the pages you type in the box.</property> </object> </child> </object> @@ -84,6 +84,31 @@ <property name="top-attach">1</property> </packing> </child> + <child> + <object class="GtkRadioButton" id="sheetrange"> + <property name="label" translatable="yes" context="pdfgeneralpage|sheetrange">_Sheets:</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="valign">center</property> + <property name="use-underline">True</property> + <property name="draw-indicator">True</property> + <property name="group">all</property> + <accessibility> + <relation type="label-for" target="sheets"/> + </accessibility> + <child internal-child="accessible"> + <object class="AtkObject" id="sheetrange-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="pdfgeneralpage|extended_tip|sheetrange">Exports the sheets you type in the box.</property> + </object> + </child> + </object> + <packing> + <property name="left-attach">0</property> + <property name="top-attach">2</property> + </packing> + </child> <child> <object class="GtkRadioButton" id="selection"> <property name="label" translatable="yes" context="pdfgeneralpage|selection">_Selection</property> @@ -114,7 +139,7 @@ <property name="width-chars">5</property> <property name="truncate-multiline">True</property> <accessibility> - <relation type="labelled-by" target="range"/> + <relation type="labelled-by" target="pagerange"/> </accessibility> <child internal-child="accessible"> <object class="AtkObject" id="pages-atkobject"> @@ -127,12 +152,33 @@ <property name="top-attach">1</property> </packing> </child> + <child> + <object class="GtkEntry" id="sheets"> + <property name="visible">True</property> + <property name="can-focus">True</property> + <property name="activates-default">True</property> + <property name="width-chars">5</property> + <property name="truncate-multiline">True</property> + <accessibility> + <relation type="labelled-by" target="sheetrange"/> + </accessibility> + <child internal-child="accessible"> + <object class="AtkObject" id="sheets-atkobject"> + <property name="AtkObject::accessible-description" translatable="yes" context="pdfgeneralpage|extended_tip|sheets">Exports the sheets you type in the box.</property> + </object> + </child> + </object> + <packing> + <property name="left-attach">1</property> + <property name="top-attach">2</property> + </packing> + </child> <child> <object class="GtkLabel" id="slides"> <property name="can-focus">False</property> <property name="no-show-all">True</property> <property name="halign">start</property> - <property name="label" translatable="yes" context="pdfgeneralpage|slides">Slides:</property> + <property name="label" translatable="yes" context="pdfgeneralpage|slides">_Slides:</property> </object> <packing> <property name="left-attach">0</property> @@ -1040,7 +1086,8 @@ <object class="GtkSizeGroup" id="sizegroupLabel"> <widgets> <widget name="all"/> - <widget name="range"/> + <widget name="pagerange"/> + <widget name="sheetrange"/> <widget name="selection"/> <widget name="losslesscompress"/> <widget name="box3"/> @@ -1051,6 +1098,7 @@ <object class="GtkSizeGroup" id="sizegroupWidget"> <widgets> <widget name="pages"/> + <widget name="sheets"/> <widget name="qualityframe"/> <widget name="resolution"/> <widget name="watermarkentry"/> diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 186c68d500fb..5399c70482e9 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -3555,6 +3555,7 @@ $(eval $(call gb_UnoApi_add_idlfiles,offapi,com/sun/star/sheet,\ XScenarios \ XScenariosSupplier \ XSelectedSheetsSupplier \ + XSheetRange \ XSheetAnnotation \ XSheetAnnotationAnchor \ XSheetAnnotationShapeSupplier \ diff --git a/offapi/com/sun/star/sheet/XSheetRange.idl b/offapi/com/sun/star/sheet/XSheetRange.idl new file mode 100644 index 000000000000..6a8070ae1e15 --- /dev/null +++ b/offapi/com/sun/star/sheet/XSheetRange.idl @@ -0,0 +1,42 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-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/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + + +module com { module sun { module star { module sheet { + + +/** + @since LibreOffice 24.2 + */ +interface XSheetRange: com::sun::star::uno::XInterface +{ + /** @returns + selection from given string range + + <p> Example: '2-5,7' returns selection of pages/sheets/slides 2,3,4,5,7 + + */ + any getSelectionFromString( [in] string aStrRange ); + +}; + + +}; }; }; }; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/inc/viewuno.hxx b/sc/inc/viewuno.hxx index 027b4753a944..483f9631551f 100644 --- a/sc/inc/viewuno.hxx +++ b/sc/inc/viewuno.hxx @@ -35,6 +35,7 @@ #include <com/sun/star/sheet/XActivationBroadcaster.hpp> #include <com/sun/star/sheet/XViewPane.hpp> #include <com/sun/star/sheet/XRangeSelection.hpp> +#include <com/sun/star/sheet/XSheetRange.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> #include <com/sun/star/beans/XPropertySet.hpp> @@ -136,6 +137,7 @@ class ScTabViewObj final : public ScViewPaneBase, public css::sheet::XViewSplitable, public css::sheet::XViewFreezable, public css::sheet::XRangeSelection, + public css::sheet::XSheetRange, public css::datatransfer::XTransferableSupplier, public css::sheet::XSelectedSheetsSupplier { @@ -196,6 +198,9 @@ public: virtual void SAL_CALL addSelectionChangeListener( const css::uno::Reference< css::view::XSelectionChangeListener >& xListener ) override; virtual void SAL_CALL removeSelectionChangeListener( const css::uno::Reference< css::view::XSelectionChangeListener >& xListener ) override; + // XSheetRange + virtual css::uno::Any SAL_CALL getSelectionFromString( const OUString& aStrRange ) override; + //! XPrintable? // XPropertySet diff --git a/sc/qa/uitest/calc_tests4/exportToPDF.py b/sc/qa/uitest/calc_tests4/exportToPDF.py index a635ee60a5d0..777d9899e421 100644 --- a/sc/qa/uitest/calc_tests4/exportToPDF.py +++ b/sc/qa/uitest/calc_tests4/exportToPDF.py @@ -53,7 +53,7 @@ class exportToPDF(UITestCase): self.assertEqual("true", get_state_as_dict(xDialog.getChild(child))['Checked']) nonCheckedChildren = ['all', 'changecomment', 'changeform', 'changeinsdel', 'changenone', 'contfacinglayout', 'contlayout', 'fitvis', 'fitwidth', - 'fitwin', 'fitzoom', 'losslesscompress', 'openinternet', 'openpdf', 'pageonly', 'printlow', 'printnone', 'range', + 'fitwin', 'fitzoom', 'losslesscompress', 'openinternet', 'openpdf', 'pageonly', 'printlow', 'printnone', 'pagerange', 'sheetrange', 'singlelayout', 'thumbs', 'visiblebookmark'] for child in nonCheckedChildren: diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index c906f39336f5..257002fb704b 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -2141,7 +2141,18 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec if (bSinglePageSheets) nTotalPages = pDocShell->GetDocument().GetTableCount(); - sal_Int32 nRenderer = lcl_GetRendererNum( nSelRenderer, aPagesStr, nTotalPages ); + // if no pages counted then user must be trying to print sheet/selection without any content (i.e empty) + if (nTotalPages == 0) + { + ScPrintOptions aNewOptions = aStatus.GetOptions(); + aNewOptions.SetSkipEmpty(false); + aStatus.SetOptions(aNewOptions); + + pPrintFuncCache.reset(new ScPrintFuncCache( pDocShell, aMark, aStatus )); + nTotalPages = pPrintFuncCache->GetPageCount(); + } + + sal_Int32 nRenderer = lcl_GetRendererNum( nSelRenderer, aPagesStr, nTotalPages ); // 0, "", 0 if ( nRenderer < 0 ) throw lang::IllegalArgumentException(); diff --git a/sc/source/ui/unoobj/viewuno.cxx b/sc/source/ui/unoobj/viewuno.cxx index 2d066bcfc26b..51a931650686 100644 --- a/sc/source/ui/unoobj/viewuno.cxx +++ b/sc/source/ui/unoobj/viewuno.cxx @@ -43,6 +43,7 @@ #include <cppuhelper/queryinterface.hxx> #include <toolkit/helper/convert.hxx> #include <vcl/svapp.hxx> +#include <tools/multisel.hxx> #include <drawsh.hxx> #include <drtxtob.hxx> @@ -485,6 +486,7 @@ uno::Any SAL_CALL ScTabViewObj::queryInterface( const uno::Type& rType ) static_cast<sheet::XViewSplitable*>(this), static_cast<sheet::XViewFreezable*>(this), static_cast<sheet::XRangeSelection*>(this), + static_cast<sheet::XSheetRange*>(this), static_cast<sheet::XSelectedSheetsSupplier*>(this), static_cast<datatransfer::XTransferableSupplier*>(this)); if ( aReturn.hasValue() ) @@ -594,6 +596,7 @@ uno::Sequence<uno::Type> SAL_CALL ScTabViewObj::getTypes() cppu::UnoType<sheet::XViewSplitable>::get(), cppu::UnoType<sheet::XViewFreezable>::get(), cppu::UnoType<sheet::XRangeSelection>::get(), + cppu::UnoType<sheet::XSheetRange>::get(), cppu::UnoType<lang::XUnoTunnel>::get(), cppu::UnoType<sheet::XEnhancedMouseClickBroadcaster>::get(), cppu::UnoType<sheet::XActivationBroadcaster>::get(), @@ -950,6 +953,35 @@ uno::Any SAL_CALL ScTabViewObj::getSelection() return uno::Any(uno::Reference(cppu::getXWeak(pObj.get()))); } +uno::Any SAL_CALL ScTabViewObj::getSelectionFromString( const OUString& aStrRange ) +{ + ScDocShell* pDocSh = GetViewShell()->GetViewData().GetDocShell(); + const sal_Int16 nTabCount = pDocSh->GetDocument().GetTableCount(); + + StringRangeEnumerator aRangeEnum(aStrRange , 0, nTabCount-1); + + // iterate through sheet range + + StringRangeEnumerator::Iterator aIter = aRangeEnum.begin(); + StringRangeEnumerator::Iterator aEnd = aRangeEnum.end(); + + ScRangeListRef aRangeList = new ScRangeList; + + while ( aIter != aEnd ) + { + ScRange currentTab(SCCOL(0), SCROW(0), SCTAB(*aIter)); + aRangeList->push_back(currentTab); + ++aIter; + } + + rtl::Reference<ScCellRangesBase> pObj = new ScCellRangesObj(pDocSh, *aRangeList); + + // SetCursorOnly tells the range the specific cells selected are irelevant - maybe could rename? + pObj->SetCursorOnly(true); + + return uno::Any(uno::Reference<uno::XInterface>(static_cast<cppu::OWeakObject*>(pObj.get()))); +} + // XEnumerationAccess uno::Reference<container::XEnumeration> SAL_CALL ScTabViewObj::createEnumeration() diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx index a61520875238..697a03f8a315 100644 --- a/sc/source/ui/view/printfun.cxx +++ b/sc/source/ui/view/printfun.cxx @@ -713,7 +713,7 @@ bool ScPrintFunc::AdjustPrintArea( bool bNew ) { nStartCol = 0; nStartRow = 0; - if (!rDoc.GetPrintArea( nPrintTab, nEndCol, nEndRow, bNotes )) + if (!rDoc.GetPrintArea( nPrintTab, nEndCol, nEndRow, bNotes ) && aTableParam.bSkipEmpty) return false; // nothing bPrintAreaValid = true; } diff --git a/sd/qa/uitest/impress_tests/exportToPDF.py b/sd/qa/uitest/impress_tests/exportToPDF.py index 429e28df4f0d..e654f608947b 100644 --- a/sd/qa/uitest/impress_tests/exportToPDF.py +++ b/sd/qa/uitest/impress_tests/exportToPDF.py @@ -55,7 +55,7 @@ class exportToPDF(UITestCase): self.assertEqual("true", get_state_as_dict(xDialog.getChild(child))['Checked']) nonCheckedChildren = ['changecomment', 'changeform', 'changeinsdel', 'changenone', 'contfacinglayout', 'contlayout', 'fitvis', - 'fitwidth', 'fitwin', 'fitzoom', 'losslesscompress', 'openinternet', 'openpdf', 'pageonly', 'printlow', 'printnone', 'range', + 'fitwidth', 'fitwin', 'fitzoom', 'losslesscompress', 'openinternet', 'openpdf', 'pageonly', 'printlow', 'printnone', 'pagerange', 'selection', 'singlelayout', 'thumbs', 'visiblebookmark'] for child in nonCheckedChildren: diff --git a/sw/qa/uitest/writer_tests4/exportToPDF.py b/sw/qa/uitest/writer_tests4/exportToPDF.py index ef628d4eea68..a075e6a4c773 100644 --- a/sw/qa/uitest/writer_tests4/exportToPDF.py +++ b/sw/qa/uitest/writer_tests4/exportToPDF.py @@ -51,7 +51,7 @@ class exportToPDF(UITestCase): self.assertEqual("true", get_state_as_dict(xDialog.getChild(child))['Checked']) nonCheckedChildren = ['changecomment', 'changeform', 'changeinsdel', 'changenone', 'contfacinglayout', 'contlayout', 'fitvis', - 'fitwidth', 'fitwin', 'fitzoom', 'losslesscompress', 'openinternet', 'openpdf', 'pageonly', 'printlow', 'printnone', 'range', + 'fitwidth', 'fitwin', 'fitzoom', 'losslesscompress', 'openinternet', 'openpdf', 'pageonly', 'printlow', 'printnone', 'pagerange', 'selection', 'singlelayout', 'thumbs', 'visiblebookmark'] for child in nonCheckedChildren: