tdf#67905 adds an option to disable print preview in print dialog
Change-Id: Id6dd1724a1b8f61d94f0685f63d28b3cff19988f
diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx
index 07771189..8799c8d 100644
--- a/vcl/inc/printdlg.hxx
+++ b/vcl/inc/printdlg.hxx
@@ -181,13 +181,15 @@
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 @@
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 4b33177..ab696bd 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 ce0e4b0..32bc198 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -653,6 +653,7 @@
, 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 @@
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 @@
// 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 @@
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 @@
mpNumPagesText.clear();
mpBackwardBtn.clear();
mpForwardBtn.clear();
mpPreviewBox.clear();
mpOKButton.clear();
mpCancelButton.clear();
mpHelpButton.clear();
@@ -837,6 +838,16 @@
}
}
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 @@
"WindowState",
OStringToOUString( GetWindowState(), RTL_TEXTENCODING_UTF8 )
);
pItem->setValue( "PrintDialog",
"HasPreview",
hasPreview() ? OUString("true") : OUString("false") );
pItem->Commit();
}
@@ -885,7 +899,12 @@
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::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 @@
}
}
Size aCurPageSize = aPrt->PixelToLogic( aPrt->GetPaperSizePixel(), MapMode( MapUnit::Map100thMM ) );
mpPreviewWindow->setPreview( aMtf, aCurPageSize,
aPrt->GetPaperName(),
nPages > 0 ? OUString() : maNoPageStr,
@@ -1650,6 +1686,10 @@
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 d832944..0c1a7c7 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>