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 /basctl | |
parent | Sets page orientation box in print dialog (diff) | |
download | core-faf2b0f165e9d9e3160e5d54e3d2e9973facf0b8.tar.gz core-faf2b0f165e9d9e3160e5d54e3d2e9973facf0b8.zip |
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 'basctl')
-rw-r--r-- | basctl/inc/strings.hrc | 2 | ||||
-rw-r--r-- | basctl/source/basicide/basicrenderable.cxx | 32 | ||||
-rw-r--r-- | basctl/source/basicide/basicrenderable.hxx | 8 |
3 files changed, 38 insertions, 4 deletions
diff --git a/basctl/inc/strings.hrc b/basctl/inc/strings.hrc index db479a4f17f6..a39ba9d76c04 100644 --- a/basctl/inc/strings.hrc +++ b/basctl/inc/strings.hrc @@ -100,6 +100,8 @@ #define RID_STR_PRINTDLG_PAGES NC_("RID_STR_PRINTDLG_PAGES", "Pages:") #define RID_STR_PRINTDLG_PRINTALLPAGES NC_("RID_STR_PRINTDLG_PRINTALLPAGES", "Print all pages") #define RID_STR_PRINTDLG_PRINTPAGES NC_("RID_STR_PRINTDLG_PRINTPAGES", "Print pages") +#define RID_STR_PRINTDLG_PRINTEVENPAGES NC_("RID_STR_PRINTDLG_PRINTEVENPAGES", "Print even pages") +#define RID_STR_PRINTDLG_PRINTODDPAGES NC_("RID_STR_PRINTDLG_PRINTODDPAGES", "Print odd pages") #define RID_STR_BTNDEL NC_("RID_STR_BTNDEL", "~Delete") #define RID_STR_BTNNEW NC_("RID_STR_BTNNEW", "~New") #define RID_STR_CHOOSE NC_("RID_STR_CHOOSE", "Choose") diff --git a/basctl/source/basicide/basicrenderable.cxx b/basctl/source/basicide/basicrenderable.cxx index e89adb755686..7913c8a10d75 100644 --- a/basctl/source/basicide/basicrenderable.cxx +++ b/basctl/source/basicide/basicrenderable.cxx @@ -48,7 +48,9 @@ Renderable::Renderable (BaseWindow* pWin) // create a choice for the range to print OUString aPrintContentName( "PrintContent" ); const Sequence<OUString> aChoices{IDEResId(RID_STR_PRINTDLG_PRINTALLPAGES), - IDEResId(RID_STR_PRINTDLG_PRINTPAGES)}; + IDEResId(RID_STR_PRINTDLG_PRINTPAGES), + IDEResId(RID_STR_PRINTDLG_PRINTEVENPAGES), + IDEResId(RID_STR_PRINTDLG_PRINTODDPAGES)}; const Sequence<OUString> aHelpIds{".HelpID:vcl:PrintDialog:PrintContent:ListBox"}; m_aUIProperties[1].Value = setChoiceListControlOpt( "printpagesbox", OUString(), aHelpIds, aPrintContentName, @@ -80,12 +82,26 @@ VclPtr< Printer > Renderable::getPrinter() return pPrinter; } +bool Renderable::isPrintOddPages() +{ + sal_Int64 nContent = getIntValue( "PrintContent", -1 ); + return nContent != 2; +} + +bool Renderable::isPrintEvenPages() +{ + sal_Int64 nContent = getIntValue( "PrintContent", -1 ); + return nContent != 3; +} + sal_Int32 SAL_CALL Renderable::getRendererCount ( const Any&, const Sequence<beans::PropertyValue >& i_xOptions ) { processProperties( i_xOptions ); + maValidPages.clear(); + sal_Int32 nCount = 0; if( mpWindow ) { @@ -94,6 +110,16 @@ sal_Int32 SAL_CALL Renderable::getRendererCount ( throw lang::IllegalArgumentException(); nCount = mpWindow->countPages( pPrinter ); + + for (sal_Int32 nPage = 1; nPage <= nCount; nPage++) + { + if ( (isPrintEvenPages() && isOnEvenPage( nPage )) + || (isPrintOddPages() && !isOnEvenPage( nPage )) ) + { + maValidPages.push_back( nPage-1 ); + } + } + sal_Int64 nContent = getIntValue( "PrintContent", -1 ); if( nContent == 1 ) { @@ -106,6 +132,8 @@ sal_Int32 SAL_CALL Renderable::getRendererCount ( nCount = nSelCount; } } + else if ( nContent == 2 || nContent == 3 ) // even/odd pages + return static_cast<sal_Int32>( maValidPages.size() ); } return nCount; @@ -170,7 +198,7 @@ void SAL_CALL Renderable::render ( mpWindow->printPage( nRenderer, pPrinter ); } else - mpWindow->printPage( nRenderer, pPrinter ); + mpWindow->printPage( maValidPages.at( nRenderer ), pPrinter ); } } diff --git a/basctl/source/basicide/basicrenderable.hxx b/basctl/source/basicide/basicrenderable.hxx index 412480609f0c..6f5bd29396bf 100644 --- a/basctl/source/basicide/basicrenderable.hxx +++ b/basctl/source/basicide/basicrenderable.hxx @@ -33,10 +33,14 @@ class Renderable : public cppu::WeakComponentImplHelper< css::view::XRenderable >, public vcl::PrinterOptionsHelper { - VclPtr<BaseWindow> mpWindow; - osl::Mutex maMutex; + VclPtr<BaseWindow> mpWindow; + osl::Mutex maMutex; + std::vector<sal_Int32> maValidPages; VclPtr<Printer> getPrinter(); + bool isPrintOddPages(); + bool isPrintEvenPages(); + static bool isOnEvenPage( sal_Int32 nPage ) { return nPage % 2 == 0; }; public: explicit Renderable (BaseWindow*); virtual ~Renderable() override; |