diff options
author | Daniel Silva <danielfaleirosilva@gmail.com> | 2018-07-12 23:00:45 -0300 |
---|---|---|
committer | Daniel Silva <danielfaleirosilva@gmail.com> | 2018-11-29 13:02:16 -0200 |
commit | faf2b0f165e9d9e3160e5d54e3d2e9973facf0b8 (patch) | |
tree | 4d677f1ddd3c784a2c75ce1c622c76abf930878e /sc | |
parent | 07e4261ceaea31a20ab2bc1a76df722ed0bd54c4 (diff) |
Adds print even pages/print odd pages options in print dialog
Change-Id: I17733d83cc652be8c5abaf20cd4b5e23d3a577a1
Reviewed-on: https://gerrit.libreoffice.org/57380
Tested-by: Jenkins
Reviewed-by: Daniel Silva <danielfaleirosilva@gmail.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/docuno.hxx | 5 | ||||
-rw-r--r-- | sc/inc/strings.hrc | 2 | ||||
-rw-r--r-- | sc/source/ui/unoobj/docuno.cxx | 96 |
3 files changed, 89 insertions, 14 deletions
diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx index 42903a6bbb1f..ad4dc8ef931c 100644 --- a/sc/inc/docuno.hxx +++ b/sc/inc/docuno.hxx @@ -120,7 +120,10 @@ private: OUString const & aServiceSpecifier, css::uno::Sequence<css::uno::Any> const * arguments); - OUString maBuildId; + static bool IsOnEvenPage( sal_Int32 nPage ) { return nPage % 2 == 0; }; + + OUString maBuildId; + std::vector<sal_Int32> maValidPages; protected: const SfxItemPropertySet& GetPropertySet() const { return aPropSet; } diff --git a/sc/inc/strings.hrc b/sc/inc/strings.hrc index 5fb1084aa398..7158305fe49f 100644 --- a/sc/inc/strings.hrc +++ b/sc/inc/strings.hrc @@ -110,6 +110,8 @@ #define SCSTR_PRINTOPT_FROMWHICH NC_("SCSTR_PRINTOPT_FROMWHICH", "From which:") #define SCSTR_PRINTOPT_PRINTALLPAGES NC_("SCSTR_PRINTOPT_PRINTALLPAGES", "Print all pages") #define SCSTR_PRINTOPT_PRINTPAGES NC_("SCSTR_PRINTOPT_PRINTPAGES", "Print pages") +#define SCSTR_PRINTOPT_PRINTEVENPAGES NC_("SCSTR_PRINTOPT_PRINTEVENPAGES", "Print even pages") +#define SCSTR_PRINTOPT_PRINTODDPAGES NC_("SCSTR_PRINTOPT_PRINTODDPAGES", "Print odd pages") #define SCSTR_PRINTOPT_PRODNAME NC_("SCSTR_PRINTOPT_PRODNAME", "%PRODUCTNAME %s") #define SCSTR_WARN_ME_IN_FUTURE_CHECK NC_("SCSTR_WARN_ME_IN_FUTURE_CHECK", "Warn me about this in the future.") #define SCSTR_DDEDOC_NOT_LOADED NC_("SCSTR_DDEDOC_NOT_LOADED", "The following DDE source could not be updated possibly because the source document was not open. Please launch the source document and try again." ) diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index b96b467bfe92..268f246e4ed6 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -301,10 +301,12 @@ ScPrintUIOptions::ScPrintUIOptions() // create a choice for the range to print OUString aPrintRangeName( "PrintRange" ); - aChoices.realloc( 2 ); + aChoices.realloc( 4 ); aHelpIds.realloc( 1 ); aChoices[0] = ScResId( SCSTR_PRINTOPT_PRINTALLPAGES ); aChoices[1] = ScResId( SCSTR_PRINTOPT_PRINTPAGES ); + aChoices[2] = ScResId( SCSTR_PRINTOPT_PRINTEVENPAGES ); + aChoices[3] = ScResId( SCSTR_PRINTOPT_PRINTODDPAGES ); aHelpIds[0] = ".HelpID:vcl:PrintDialog:PrintRange:ListBox"; m_aUIProperties[nIdx++].Value = setChoiceListControlOpt( "printextrabox", OUString(), aHelpIds, @@ -1508,7 +1510,7 @@ 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 + sal_Int32 nPrintRange = 0; // all pages / pages / even pages / odd pages OUString aPageRange; // "pages" edit value for( sal_Int32 i = 0, nLen = rOptions.getLength(); i < nLen; i++ ) @@ -1693,8 +1695,32 @@ sal_Int32 SAL_CALL ScModelObj::getRendererCount(const uno::Any& aSelection, sal_Int32 nPages = pPrintFuncCache->GetPageCount(); m_pPrintState.reset(); + maValidPages.clear(); + + sal_Int32 nContent = 0; + for ( const auto& rValue : rOptions) + { + if ( rValue.Name == "PrintRange" ) + { + rValue.Value >>= nContent; + break; + } + } + + bool bIsPrintEvenPages = nContent != 3; + bool bIsPrintOddPages = nContent != 2; + + for ( sal_Int32 nPage = 1; nPage <= nPages; nPage++ ) + { + if ( (bIsPrintEvenPages && IsOnEvenPage( nPage )) || (bIsPrintOddPages && !IsOnEvenPage( nPage )) ) + maValidPages.push_back( nPage ); + } + + sal_Int32 nSelectCount = static_cast<sal_Int32>( maValidPages.size() ); + + if ( nContent == 2 || nContent == 3 ) // even pages / odd pages + return nSelectCount; - sal_Int32 nSelectCount = nPages; if ( !aPagesStr.isEmpty() ) { StringRangeEnumerator aRangeEnum( aPagesStr, 0, nPages-1 ); @@ -1790,7 +1816,12 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32 // printer is used as device (just for page layout), draw view is not needed - SCTAB nTab = pPrintFuncCache->GetTabForPage( nRenderer ); + SCTAB nTab; + if ( !maValidPages.empty() ) + nTab = pPrintFuncCache->GetTabForPage( maValidPages.at( nRenderer )-1 ); + else + nTab = pPrintFuncCache->GetTabForPage( nRenderer ); + ScRange aRange; const ScRange* pSelRange = nullptr; @@ -1823,10 +1854,27 @@ uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32 pPrintFuncCache->GetFirstAttr(nTab), nTotalPages, pSelRange, &aStatus.GetOptions())); pPrintFunc->SetRenderFlag( true ); - Range aPageRange( nRenderer+1, nRenderer+1 ); - MultiSelection aPage( aPageRange ); - aPage.SetTotalRange( Range(0,RANGE_MAX) ); - aPage.Select( aPageRange ); + sal_Int32 nContent = 0; + for ( const auto& rValue : rOptions) + { + if ( rValue.Name == "PrintRange" ) + { + rValue.Value >>= nContent; + break; + } + } + + MultiSelection aPage; + if ( nContent == 2 || nContent == 3 ) // even pages or odd pages + { + aPage.SetTotalRange( Range(0,RANGE_MAX) ); + aPage.Select( maValidPages.at( nRenderer ) ); + } + else + { + aPage.SetTotalRange( Range(0,RANGE_MAX) ); + aPage.Select( nRenderer+1 ); + } long nDisplayStart = pPrintFuncCache->GetDisplayStart( nTab ); long nTabStart = pPrintFuncCache->GetTabStart( nTab ); @@ -1946,7 +1994,12 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec } } aDrawViewKeeper; - SCTAB nTab = pPrintFuncCache->GetTabForPage( nRenderer ); + SCTAB nTab; + if ( !maValidPages.empty() ) + nTab = pPrintFuncCache->GetTabForPage( maValidPages.at( nRenderer )-1 ); + else + nTab = pPrintFuncCache->GetTabForPage( nRenderer ); + ScDrawLayer* pModel = rDoc.GetDrawLayer(); if( pModel ) @@ -1973,10 +2026,27 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec if( aStatus.GetMode() == SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS ) pPrintFunc->SetExclusivelyDrawOleAndDrawObjects(); - Range aPageRange( nRenderer+1, nRenderer+1 ); - MultiSelection aPage( aPageRange ); - aPage.SetTotalRange( Range(0,RANGE_MAX) ); - aPage.Select( aPageRange ); + sal_Int32 nContent = 0; + for ( const auto& rValue : rOptions) + { + if ( rValue.Name == "PrintRange" ) + { + rValue.Value >>= nContent; + break; + } + } + + MultiSelection aPage; + if ( nContent == 2 || nContent == 3 ) // even pages or odd pages + { + aPage.SetTotalRange( Range(0,RANGE_MAX) ); + aPage.Select( maValidPages.at( nRenderer ) ); + } + else + { + aPage.SetTotalRange( Range(0,RANGE_MAX) ); + aPage.Select( nRenderer+1 ); + } long nDisplayStart = pPrintFuncCache->GetDisplayStart( nTab ); long nTabStart = pPrintFuncCache->GetTabStart( nTab ); |