[Libreoffice-commits] core.git: Branch 'feature/print_revamp' - vcl/inc vcl/source vcl/uiconfig
Daniel
danielfaleirosilva at gmail.com
Tue May 29 20:54:00 UTC 2018
vcl/inc/printdlg.hxx | 3 +
vcl/inc/strings.hrc | 1
vcl/source/window/printdlg.cxx | 62 +++++++++++++++++++++++++++++++++--------
vcl/uiconfig/ui/printdialog.ui | 16 ++++++++++
4 files changed, 71 insertions(+), 11 deletions(-)
New commits:
commit b9c297021d2b95b67fa2ab2842f0f4b344338129
Author: Daniel <danielfaleirosilva at gmail.com>
Date: Tue May 15 22:58:38 2018 -0300
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 b16d91cad1f6..0a5b09fd366a 100644
--- a/vcl/inc/printdlg.hxx
+++ b/vcl/inc/printdlg.hxx
@@ -181,6 +181,7 @@ namespace vcl
VclPtr<FixedText> mpNumPagesText;
VclPtr<PushButton> mpBackwardBtn;
VclPtr<PushButton> mpForwardBtn;
+ VclPtr<CheckBox> mpPreviewBox;
VclPtr<OKButton> mpOKButton;
VclPtr<CancelButton> mpCancelButton;
@@ -188,6 +189,7 @@ namespace vcl
OUString maPageStr;
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 1475e2a65ceb..1e5eb9d14743 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 084763fa934b..e59694ca8c0f 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -650,6 +650,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 ) )
@@ -665,6 +666,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();
@@ -715,9 +717,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();
@@ -747,6 +746,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 ) );
@@ -805,6 +805,7 @@ void PrintDialog::dispose()
mpNumPagesText.clear();
mpBackwardBtn.clear();
mpForwardBtn.clear();
+ mpPreviewBox.clear();
mpOKButton.clear();
mpCancelButton.clear();
mpHelpButton.clear();
@@ -834,6 +835,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" ) );
@@ -864,6 +875,9 @@ void PrintDialog::storeToSettings()
"WindowState",
OStringToOUString( GetWindowState(), RTL_TEXTENCODING_UTF8 )
);
+ pItem->setValue( "PrintDialog",
+ "HasPreview",
+ hasPreview() ? OUString("true") : OUString("false") );
pItem->Commit();
}
@@ -882,6 +896,11 @@ bool PrintDialog::isSingleJobs()
return maOptionsPage.mpCollateSingleJobsBox->IsChecked();
}
+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() )
@@ -1381,25 +1400,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 =
@@ -1411,7 +1448,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,
@@ -1655,6 +1691,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 b2308cf2f5b9..47790fbcff83 100644
--- a/vcl/uiconfig/ui/printdialog.ui
+++ b/vcl/uiconfig/ui/printdialog.ui
@@ -271,6 +271,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>
More information about the Libreoffice-commits
mailing list