summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorDaniel Silva <danielfaleirosilva@gmail.com>2018-07-12 23:00:45 -0300
committerAron Budea <aron.budea@collabora.com>2019-09-26 18:56:44 +0200
commit89dec0de22190a6c3d725b7434189006e22bde7f (patch)
treeb369fc0f0586f42cd4954df743f0bba2190f57ff /basctl
parent148ff6dce686e882b7939d9835c55957d5d260f6 (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> (cherry picked from commit faf2b0f165e9d9e3160e5d54e3d2e9973facf0b8)
Diffstat (limited to 'basctl')
-rw-r--r--basctl/inc/strings.hrc2
-rw-r--r--basctl/source/basicide/basicrenderable.cxx32
-rw-r--r--basctl/source/basicide/basicrenderable.hxx8
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;