diff options
author | Srijan Bhatia <srijanbhatiasun@gmail.com> | 2020-06-18 18:41:14 +0530 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-10-27 18:36:27 +0100 |
commit | 482507d7bbc915fd5a10c64bfb60695b2a233a12 (patch) | |
tree | 1de8d54ea83f42a280e2842206c38e3b6ac6a859 /sc | |
parent | cec0ef3d45265c19a9f3d419c3074692d15b6607 (diff) |
tdf#127680 Add the option to print even or odd values from a particular range
Added a box besides the pages option that lets the user choose between left and right pages/left pages/right pages.
Change-Id: Iee0386f4f3cfd2dac3fcf898a3fefb5434cb27a8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96612
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Signed-off-by: Xisco Fauli <xiscofauli@libreoffice.org>
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104877
Reviewed-by: Sophie Gautier <sophi@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 58 |
1 files changed, 40 insertions, 18 deletions
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index 2a4153756eb1..dec6a92b3362 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -249,7 +249,7 @@ ScPrintUIOptions::ScPrintUIOptions() sal_Int32 nContent = rPrintOpt.GetAllSheets() ? 0 : 1; bool bSuppress = rPrintOpt.GetSkipEmpty(); - sal_Int32 nNumProps= 9, nIdx = 0; + sal_Int32 nNumProps= 10, nIdx = 0; m_aUIProperties.resize(nNumProps); @@ -297,21 +297,15 @@ ScPrintUIOptions::ScPrintUIOptions() // create a choice for the range to print OUString aPrintRangeName( "PrintRange" ); - aChoices.realloc( 4 ); - aHelpIds.realloc( 4 ); - uno::Sequence< OUString > aWidgetIds( 4 ); + aChoices.realloc( 2 ); + aHelpIds.realloc( 2 ); + uno::Sequence< OUString > aWidgetIds( 2 ); aChoices[0] = ScResId( SCSTR_PRINTOPT_PRINTALLPAGES ); aHelpIds[0] = ".HelpID:vcl:PrintDialog:PrintRange:RadioButton:0"; aWidgetIds[0] = "rbAllPages"; aChoices[1] = ScResId( SCSTR_PRINTOPT_PRINTPAGES ); aHelpIds[1] = ".HelpID:vcl:PrintDialog:PrintRange:RadioButton:1"; aWidgetIds[1] = "rbRangePages"; - aChoices[2] = ScResId( SCSTR_PRINTOPT_PRINTEVENPAGES ); - aHelpIds[2] = ".HelpID:vcl:PrintDialog:PrintRange:RadioButton:2"; - aWidgetIds[2] = "rbEvenPages"; - aChoices[3] = ScResId( SCSTR_PRINTOPT_PRINTODDPAGES ); - aHelpIds[3] = ".HelpID:vcl:PrintDialog:PrintRange:RadioButton:3"; - aWidgetIds[3] = "rbOddPages"; m_aUIProperties[nIdx++].Value = setChoiceRadiosControlOpt(aWidgetIds, OUString(), aHelpIds, aPrintRangeName, @@ -324,6 +318,16 @@ ScPrintUIOptions::ScPrintUIOptions() ".HelpID:vcl:PrintDialog:PageRange:Edit", "PageRange", OUString(), aPageRangeOpt); + vcl::PrinterOptionsHelper::UIControlOptions aEvenOddOpt(aPrintRangeName, 0, true); + m_aUIProperties[ nIdx++ ].Value = setChoiceListControlOpt("evenoddbox", + OUString(), + uno::Sequence<OUString>(), + "EvenOdd", + uno::Sequence<OUString>(), + 0, + uno::Sequence< sal_Bool >(), + aEvenOddOpt); + assert(nIdx == nNumProps); } @@ -1409,7 +1413,8 @@ bool ScModelObj::FillRenderMarkData( const uno::Any& aSelection, bool bHasPrintContent = false; sal_Int32 nPrintContent = 0; // all sheets / selected sheets / selected cells - sal_Int32 nPrintRange = 0; // all pages / pages / even pages / odd pages + sal_Int32 nPrintRange = 0; // all pages / pages + sal_Int32 nEOContent = 0; // even pages / odd pages OUString aPageRange; // "pages" edit value for( const auto& rOption : rOptions ) @@ -1430,6 +1435,10 @@ bool ScModelObj::FillRenderMarkData( const uno::Any& aSelection, { rOption.Value >>= nPrintRange; } + else if ( rOption.Name == "EvenOdd" ) + { + rOption.Value >>= nEOContent; + } else if ( rOption.Name == "PrintContent" ) { bHasPrintContent = true; @@ -1593,6 +1602,7 @@ sal_Int32 SAL_CALL ScModelObj::getRendererCount(const uno::Any& aSelection, maValidPages.clear(); sal_Int32 nContent = 0; + sal_Int32 nEOContent = 0; bool bSinglePageSheets = false; for ( const auto& rValue : rOptions) { @@ -1604,6 +1614,10 @@ sal_Int32 SAL_CALL ScModelObj::getRendererCount(const uno::Any& aSelection, { rValue.Value >>= bSinglePageSheets; } + else if ( rValue.Name == "EvenOdd" ) + { + rValue.Value >>= nEOContent; + } } if (bSinglePageSheets) @@ -1611,8 +1625,8 @@ sal_Int32 SAL_CALL ScModelObj::getRendererCount(const uno::Any& aSelection, return pDocShell->GetDocument().GetTableCount(); } - bool bIsPrintEvenPages = nContent != 3; - bool bIsPrintOddPages = nContent != 2; + bool bIsPrintEvenPages = (nEOContent != 2 && nContent == 0) || nContent != 0; + bool bIsPrintOddPages = (nEOContent != 1 && nContent == 0) || nContent != 0; for ( sal_Int32 nPage = 1; nPage <= nPages; nPage++ ) { @@ -1622,7 +1636,7 @@ sal_Int32 SAL_CALL ScModelObj::getRendererCount(const uno::Any& aSelection, sal_Int32 nSelectCount = static_cast<sal_Int32>( maValidPages.size() ); - if ( nContent == 2 || nContent == 3 ) // even pages / odd pages + if ( nEOContent == 1 || nEOContent == 2 ) // even pages / odd pages return nSelectCount; if ( !aPagesStr.isEmpty() ) @@ -1824,19 +1838,23 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32 pPrintFunc->SetRenderFlag( true ); sal_Int32 nContent = 0; + sal_Int32 nEOContent = 0; for ( const auto& rValue : rOptions) { if ( rValue.Name == "PrintRange" ) { rValue.Value >>= nContent; - break; + } + else if ( rValue.Name == "EvenOdd" ) + { + rValue.Value >>= nEOContent; } } MultiSelection aPage; aPage.SetTotalRange( Range(0,RANGE_MAX) ); - bool bOddOrEven = nContent == 2 || nContent == 3; // even pages or odd pages + bool bOddOrEven = (nContent == 0 && nEOContent == 1) || (nContent == 1 && nEOContent == 2); // even pages or odd pages // tdf#127682 when odd/even allow nRenderer of 0 even when maValidPages is empty // to allow PrinterController::abortJob to spool an empty page as part of // its abort procedure @@ -2054,19 +2072,23 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec pPrintFunc->SetExclusivelyDrawOleAndDrawObjects(); sal_Int32 nContent = 0; + sal_Int32 nEOContent = 0; for ( const auto& rValue : rOptions) { if ( rValue.Name == "PrintRange" ) { rValue.Value >>= nContent; - break; + } + else if ( rValue.Name == "EvenOdd" ) + { + rValue.Value >>= nEOContent; } } MultiSelection aPage; aPage.SetTotalRange( Range(0,RANGE_MAX) ); - bool bOddOrEven = nContent == 2 || nContent == 3; // even pages or odd pages + bool bOddOrEven = (nContent == 0 && nEOContent == 1) || (nContent == 0 && nEOContent == 2); // even pages or odd pages // tdf#127682 when odd/even allow nRenderer of 0 even when maValidPages is empty // to allow PrinterController::abortJob to spool an empty page as part of // its abort procedure |