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 dd9f787875a9a953d1fb84de44e04fd2a0c2f8c1 Author: NickWingate <[email protected]> AuthorDate: Tue Aug 29 15:31:08 2023 +0100 Commit: Szymon Kłos <[email protected]> CommitDate: Fri Sep 8 15:04:41 2023 +0200 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 <[email protected]> Change-Id: Iecd42188ddbbbcd70eb37bec80783e29e3cb5b19 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156255 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Szymon Kłos <[email protected]> diff --git a/filter/source/pdf/impdialog.cxx b/filter/source/pdf/impdialog.cxx index 2723afbf0ab8..d9f3f3576a4e 100644 --- a/filter/source/pdf/impdialog.cxx +++ b/filter/source/pdf/impdialog.cxx @@ -106,8 +106,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 ), @@ -492,8 +494,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)); @@ -517,9 +521,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")) @@ -550,7 +556,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")) { } @@ -565,11 +571,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 ) @@ -654,7 +662,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 ) ); @@ -677,10 +685,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); } @@ -688,6 +699,9 @@ void ImpPDFTabGeneralPage::SetFilterConfigItem(ImpPDFTabDialog* pParent) { mxCbSinglePageSheets->hide(); mxCbSinglePageSheets->set_active(false); + mxRbSheetRange->hide(); + mxRbSheetRange->set_active(false); + mxEdSheets->hide(); } mxCbExportPlaceholders->set_visible(mbIsWriter); @@ -734,12 +748,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(); @@ -802,6 +821,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(); @@ -809,11 +834,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 ) @@ -859,7 +891,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 ); @@ -867,7 +900,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 45442c58048b..ed26bcb78dbd 100644 --- a/filter/source/pdf/impdialog.hxx +++ b/filter/source/pdf/impdialog.hxx @@ -131,8 +131,10 @@ class ImpPDFTabDialog final : public SfxTabDialogController std::shared_ptr< svx::AccessibilityCheckDialog > mpAccessibilityCheckDialog; - bool mbIsRangeChecked; + bool mbIsPageRangeChecked; OUString msPageRange; + bool mbIsSheetRangeChecked; + OUString msSheetRange; bool mbSelectionIsChecked; bool mbExportRelativeFsysLinks; @@ -187,9 +189,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; @@ -220,10 +224,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); @@ -233,6 +238,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 b886aa5d0f43..b9a6bb42c42a 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> @@ -499,6 +500,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 f39034a9b184..44512b9fac85 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> @@ -1039,7 +1085,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"/> @@ -1050,6 +1097,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 92fd71dd8e12..e15a570bd3ef 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -3556,6 +3556,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..2951e9ee96b6 --- /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 7.6 + */ +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 b4ce26f7fc8d..41329e0f79d8 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> @@ -137,6 +138,7 @@ class ScTabViewObj final : public ScViewPaneBase, public css::sheet::XViewSplitable, public css::sheet::XViewFreezable, public css::sheet::XRangeSelection, + public css::sheet::XSheetRange, public css::lang::XUnoTunnel, public css::datatransfer::XTransferableSupplier, public css::sheet::XSelectedSheetsSupplier @@ -198,6 +200,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 944005f19a2c..91c618ce9320 100644 --- a/sc/qa/uitest/calc_tests4/exportToPDF.py +++ b/sc/qa/uitest/calc_tests4/exportToPDF.py @@ -52,7 +52,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 c901c77f7b25..63cce6873057 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -2137,7 +2137,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 f58bf3782eb5..e2811a87287d 100644 --- a/sc/source/ui/unoobj/viewuno.cxx +++ b/sc/source/ui/unoobj/viewuno.cxx @@ -42,6 +42,7 @@ #include <cppuhelper/supportsservice.hxx> #include <toolkit/helper/convert.hxx> #include <vcl/svapp.hxx> +#include <tools/multisel.hxx> #include <drawsh.hxx> #include <drtxtob.hxx> @@ -479,6 +480,7 @@ uno::Any SAL_CALL ScTabViewObj::queryInterface( const uno::Type& rType ) SC_QUERYINTERFACE( sheet::XViewSplitable ) SC_QUERYINTERFACE( sheet::XViewFreezable ) SC_QUERYINTERFACE( sheet::XRangeSelection ) + SC_QUERYINTERFACE( sheet::XSheetRange ) SC_QUERYINTERFACE( lang::XUnoTunnel ) SC_QUERYINTERFACE( datatransfer::XTransferableSupplier ) SC_QUERYINTERFACE( sheet::XSelectedSheetsSupplier ) @@ -588,6 +590,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(), @@ -944,6 +947,35 @@ uno::Any SAL_CALL ScTabViewObj::getSelection() return uno::Any(uno::Reference<uno::XInterface>(static_cast<cppu::OWeakObject*>(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 7b42e184334c..ecd9754795e3 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 286299b4befa..866907805d66 100644 --- a/sd/qa/uitest/impress_tests/exportToPDF.py +++ b/sd/qa/uitest/impress_tests/exportToPDF.py @@ -54,7 +54,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 1051896c063d..ce4ff41eb3c8 100644 --- a/sw/qa/uitest/writer_tests4/exportToPDF.py +++ b/sw/qa/uitest/writer_tests4/exportToPDF.py @@ -50,7 +50,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:
