summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel <danielfaleirosilva@gmail.com>2018-05-15 22:58:38 -0300
committerDaniel Silva <danielfaleirosilva@gmail.com>2018-11-29 13:02:16 -0200
commit2c23a96f7b6888c0e05fdc2aba57f03cd797b647 (patch)
tree046bb25699a9e357c2344d30009d50ab800e0952
parente3ce6ea30e2cdd81857597f50ef5e0a6acd198ee (diff)
tdf#67905 adds an option to disable print preview in print dialog
Change-Id: Id6dd1724a1b8f61d94f0685f63d28b3cff19988f
-rw-r--r--vcl/inc/printdlg.hxx5
-rw-r--r--vcl/inc/strings.hrc1
-rw-r--r--vcl/source/window/printdlg.cxx64
-rw-r--r--vcl/uiconfig/ui/printdialog.ui16
4 files changed, 73 insertions, 13 deletions
diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx
index 077711896bcd..8799c8dba277 100644
--- a/vcl/inc/printdlg.hxx
+++ b/vcl/inc/printdlg.hxx
@@ -181,13 +181,15 @@ namespace vcl
VclPtr<FixedText> mpNumPagesText;
VclPtr<PushButton> mpBackwardBtn;
VclPtr<PushButton> mpForwardBtn;
+ VclPtr<CheckBox> mpPreviewBox;
VclPtr<OKButton> mpOKButton;
VclPtr<CancelButton> mpCancelButton;
VclPtr<HelpButton> mpHelpButton;
OUString maPageStr;
- OUString const maNoPageStr;
+ OUString maNoPageStr;
+ OUString maNoPreviewStr;
sal_Int32 mnCurPage;
sal_Int32 mnCachedPages;
@@ -247,6 +249,7 @@ namespace vcl
bool isPrintToFile();
bool isCollate();
bool isSingleJobs();
+ bool hasPreview();
void previewForward();
void previewBackward();
diff --git a/vcl/inc/strings.hrc b/vcl/inc/strings.hrc
index 4b33177c74c1..ab696bd43b3f 100644
--- a/vcl/inc/strings.hrc
+++ b/vcl/inc/strings.hrc
@@ -113,6 +113,7 @@
#define SV_ACCESSERROR_NO_FONTS NC_("SV_ACCESSERROR_NO_FONTS", "No fonts could be found on the system.")
#define SV_PRINT_NOPAGES NC_("SV_PRINT_NOPAGES", "No pages")
+#define SV_PRINT_NOPREVIEW NC_("SV_PRINT_NOPREVIEW", "Preview is disabled")
#define SV_PRINT_TOFILE_TXT NC_("SV_PRINT_TOFILE_TXT", "Print to File...")
#define SV_PRINT_DEFPRT_TXT NC_("SV_PRINT_DEFPRT_TXT", "Default printer")
#define SV_PRINT_PRINTPREVIEW_TXT NC_("SV_PRINT_PRINTPREVIEW_TXT", "Print preview")
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index ce0e4b03fa3f..32bc19824d64 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -653,6 +653,7 @@ PrintDialog::PrintDialog( vcl::Window* i_pParent, const std::shared_ptr<PrinterC
, maJobPage(m_pUIBuilder.get())
, maOptionsPage(m_pUIBuilder.get())
, maNoPageStr( VclResId( SV_PRINT_NOPAGES ) )
+ , maNoPreviewStr( VclResId( SV_PRINT_NOPREVIEW ) )
, mnCurPage( 0 )
, mnCachedPages( 0 )
, maPrintToFileText( VclResId( SV_PRINT_TOFILE_TXT ) )
@@ -668,6 +669,7 @@ PrintDialog::PrintDialog( vcl::Window* i_pParent, const std::shared_ptr<PrinterC
get(mpPageEdit, "pageedit-nospin");
get(mpTabCtrl, "tabcontrol");
get(mpPreviewWindow, "preview");
+ get(mpPreviewBox, "previewbox");
// save printbutton text, gets exchanged occasionally with print to file
maPrintText = mpOKButton->GetText();
@@ -717,9 +719,6 @@ PrintDialog::PrintDialog( vcl::Window* i_pParent, const std::shared_ptr<PrinterC
// not printing to file
maPController->resetPrinterOptions( false );
- // get the first page
- preparePreview( true, true );
-
// update the text fields for the printer
updatePrinterText();
@@ -750,6 +749,7 @@ PrintDialog::PrintDialog( vcl::Window* i_pParent, const std::shared_ptr<PrinterC
mpHelpButton->SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
mpForwardBtn->SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
mpBackwardBtn->SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
+ mpPreviewBox->SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
maJobPage.mpCollateBox->SetToggleHdl( LINK( this, PrintDialog, ToggleHdl ) );
maJobPage.mpSetupButton->SetClickHdl( LINK( this, PrintDialog, ClickHdl ) );
@@ -808,6 +808,7 @@ void PrintDialog::dispose()
mpNumPagesText.clear();
mpBackwardBtn.clear();
mpForwardBtn.clear();
+ mpPreviewBox.clear();
mpOKButton.clear();
mpCancelButton.clear();
mpHelpButton.clear();
@@ -837,6 +838,16 @@ void PrintDialog::readFromSettings()
}
}
+ aValue = pItem->getValue( "PrintDialog", "HasPreview" );
+ if ( aValue.equalsIgnoreAsciiCase("true") )
+ {
+ mpPreviewBox->Check();
+ }
+ else
+ {
+ mpPreviewBox->Check( false );
+ }
+
// persistent window state
OUString aWinState( pItem->getValue( "PrintDialog",
"WindowState" ) );
@@ -867,6 +878,9 @@ void PrintDialog::storeToSettings()
"WindowState",
OStringToOUString( GetWindowState(), RTL_TEXTENCODING_UTF8 )
);
+ pItem->setValue( "PrintDialog",
+ "HasPreview",
+ hasPreview() ? OUString("true") : OUString("false") );
pItem->Commit();
}
@@ -885,7 +899,12 @@ bool PrintDialog::isSingleJobs()
return maOptionsPage.mpCollateSingleJobsBox->IsChecked();
}
-static void setHelpId( vcl::Window* i_pWindow, const Sequence< OUString >& i_rHelpIds, sal_Int32 i_nIndex )
+bool PrintDialog::hasPreview()
+{
+ return mpPreviewBox->IsChecked();
+}
+
+void setHelpId( vcl::Window* i_pWindow, const Sequence< OUString >& i_rHelpIds, sal_Int32 i_nIndex )
{
if( i_nIndex >= 0 && i_nIndex < i_rHelpIds.getLength() )
i_pWindow->SetHelpId( OUStringToOString( i_rHelpIds.getConstArray()[i_nIndex], RTL_TEXTENCODING_UTF8 ) );
@@ -1370,25 +1389,43 @@ void PrintDialog::setPreviewText()
void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache )
{
+ VclPtr<Printer> aPrt( maPController->getPrinter() );
+ Size aCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MapUnit::Map100thMM ) );
+ GDIMetaFile aMtf;
+
// page range may have changed depending on options
sal_Int32 nPages = maPController->getFilteredPageCount();
mnCachedPages = nPages;
+ mpPageEdit->SetMin( 1 );
+ mpPageEdit->SetMax( nPages );
+
+ setPreviewText();
+
+ if ( !hasPreview() )
+ {
+ mpPreviewWindow->setPreview( aMtf, aCurPageSize,
+ aPrt->GetPaperName(),
+ maNoPreviewStr,
+ aPrt->GetDPIX(), aPrt->GetDPIY(),
+ aPrt->GetPrinterOptions().IsConvertToGreyscales()
+ );
+
+ mpForwardBtn->Enable( false );
+ mpBackwardBtn->Enable( false );
+ mpPageEdit->Enable( false );
+
+ return;
+ }
+
if( mnCurPage >= nPages )
mnCurPage = nPages-1;
if( mnCurPage < 0 )
mnCurPage = 0;
- setPreviewText();
-
- mpPageEdit->SetMin( 1 );
- mpPageEdit->SetMax( nPages );
-
if( i_bNewPage )
{
const MapMode aMapMode( MapUnit::Map100thMM );
- GDIMetaFile aMtf;
- VclPtr<Printer> aPrt( maPController->getPrinter() );
if( nPages > 0 )
{
PrinterController::PageSize aPageSize =
@@ -1400,7 +1437,6 @@ void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache )
}
}
- Size aCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MapUnit::Map100thMM ) );
mpPreviewWindow->setPreview( aMtf, aCurPageSize,
aPrt->GetPaperName(),
nPages > 0 ? OUString() : maNoPageStr,
@@ -1650,6 +1686,10 @@ IMPL_LINK( PrintDialog, ClickHdl, Button*, pButton, void )
pHelp->Start( "vcl/ui/printdialog", mpOKButton );
}
}
+ else if ( pButton == mpPreviewBox )
+ {
+ preparePreview( true, true );
+ }
else if( pButton == mpForwardBtn )
{
previewForward();
diff --git a/vcl/uiconfig/ui/printdialog.ui b/vcl/uiconfig/ui/printdialog.ui
index d832944052cc..0c1a7c7ab450 100644
--- a/vcl/uiconfig/ui/printdialog.ui
+++ b/vcl/uiconfig/ui/printdialog.ui
@@ -273,6 +273,22 @@
<property name="fill">True</property>
<property name="position">1</property>
</packing>
+ <child>
+ <object class="GtkCheckButton" id="previewbox">
+ <property name="label" translatable="yes" context="printdialog|previewbox">Preview</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="xalign">0</property>
+ <property name="halign">center</property>
+ <property name="margin_left">30</property>
+ <property name="margin_right">30</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
</child>
</object>
<packing>