[Libreoffice-commits] core.git: Branch 'feature/print_revamp' - include/vcl vcl/inc vcl/source
include/vcl/print.hxx |3 +++ vcl/inc/printdlg.hxx |1 + vcl/source/gdi/print3.cxx | 15 +++ vcl/source/window/printdlg.cxx | 36 4 files changed, 51 insertions(+), 4 deletions(-) New commits: commit e14d9102a62bc3b3af17123d4307cda09f403351 Author: Daniel AuthorDate: Sun Aug 12 17:32:30 2018 -0300 Commit: Daniel Silva CommitDate: Mon Aug 13 01:29:14 2018 +0200 Resolves the mismatching behavior between page size and orientatin selection Change-Id: I8482fa062441aac59fac7324b0987eb20face077 Reviewed-on: https://gerrit.libreoffice.org/58907 Tested-by: Jenkins Reviewed-by: Daniel Silva diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx index d4ec3219af3d..2e3cc1a79db7 100644 --- a/include/vcl/print.hxx +++ b/include/vcl/print.hxx @@ -557,7 +557,10 @@ public: SAL_DLLPRIVATEbool getReversePrint() const; SAL_DLLPRIVATEvoid setPapersizeFromSetup( bool i_bPapersizeFromSetup ); SAL_DLLPRIVATEbool getPapersizeFromSetup() const; +SAL_DLLPRIVATESize& getPaperSizeSetup() const; SAL_DLLPRIVATEvoid setPaperSizeFromUser( Size i_aUserSize ); +SAL_DLLPRIVATESize& getPaperSizeFromUser() const; +SAL_DLLPRIVATEbool isPaperSizeFromUser() const; VCL_PLUGIN_PUBLIC void setPrinterModified( bool i_bPapersizeFromSetup ); VCL_PLUGIN_PUBLIC bool getPrinterModified() const; SAL_DLLPRIVATEvoid pushPropertiesToPrinter(); diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx index 3b6ad1827fa3..cbf91436f565 100644 --- a/vcl/inc/printdlg.hxx +++ b/vcl/inc/printdlg.hxx @@ -233,6 +233,7 @@ namespace vcl void setPaperOrientation( Orientation eOrientation ); void updateOrientationBox( bool bAutomatic = true ); bool hasOrientationChanged() const; +void checkPaperSize( Size& rPaperSize ); void setPreviewText(); void updatePrinterText(); void checkControlDependencies(); diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx index b56a5740a5fd..1fb481471180 100644 --- a/vcl/source/gdi/print3.cxx +++ b/vcl/source/gdi/print3.cxx @@ -1382,6 +1382,11 @@ bool PrinterController::getPapersizeFromSetup() const return mpImplData->mbPapersizeFromSetup; } +Size& PrinterController::getPaperSizeSetup() const +{ +return mpImplData->maDefaultPageSize; +} + void PrinterController::setPaperSizeFromUser( Size i_aUserSize ) { mpImplData->mbPapersizeFromUser = true; @@ -1391,6 +1396,16 @@ void PrinterController::setPaperSizeFromUser( Size i_aUserSize ) mpImplData->maUserPageSize = i_aUserSize; } +Size& PrinterController::getPaperSizeFromUser() const +{ +return mpImplData->maUserPageSize; +} + +bool PrinterController::isPaperSizeFromUser() const +{ +return mpImplData->mbPapersizeFromUser; +} + void PrinterController::setPrinterModified( bool i_bPrinterModified ) { mpImplData->mbPrinterModified = i_bPrinterModified; diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 8308f11f7272..c62142d6cba4 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -1037,11 +1037,36 @@ bool PrintDialog::hasOrientationChanged() const || (nOrientation == ORIENTATION_PORTRAIT && eOrientation == Orientation::Landscape); } -// Always use this function to set paper orientation in -// order to update document orientation as well +// make sure paper size matches paper orientation +void PrintDialog::checkPaperSize( Size& rPaperSize ) +{ +Orientation eOrientation = maPController->getPrinter()->GetOrientation(); +if ( (eOrientation == Orientation::Portrait && rPaperSize.Width() > rPaperSize.Height()) || + (eOrientation == Orientation::Landscape && rPaperSize.Width() < rPaperSize.Height()) ) +{ +rPaperSize = Size( rPaperSize.Height(), rPaperSize.Width() ); +} +} + +// Always use this function to set paper orientation to make sure everything behaves well void PrintDialog::setPaperOrientation( Orientation eOrientation ) { -maPController->getPrinter()->SetOrientation( eOrientation ); +VclPtr aPrt( maPController->getPrinter() ); +aPrt->SetOrientation( eOrientation ); + +// check if it's necessary to swap width and height of paper +if ( maPController->isPaperSizeFromUser() ) +{ +Size& aPaperSize = maPController->getPaperSizeFromUser(); +checkPaperSize( aPaperSize ); +} +else if ( maPController->getPapersizeFromSetup() ) +{ +Size& aPaperSize = maPController->getPaperSizeSetup(); +checkPaperSize( aPaperSize ); +} + +// used to sync printer paper orientation with document orientation maPController->setValue( "IsLandscape", makeAny(
[Libreoffice-commits] core.git: Branch 'feature/print_revamp' - include/vcl vcl/inc vcl/source vcl/uiconfig
include/vcl/print.hxx |1 + vcl/inc/printdlg.hxx |2 ++ vcl/source/gdi/print.cxx |5 + vcl/source/window/printdlg.cxx | 29 + vcl/uiconfig/ui/printdialog.ui | 18 ++ 5 files changed, 55 insertions(+) New commits: commit e5f94bcb3d54e956749401ba714cb528bc99e3e6 Author: Daniel Silva AuthorDate: Sun Jul 22 21:05:56 2018 -0300 Commit: Katarina Behrens CommitDate: Tue Aug 7 11:38:37 2018 +0200 Sets duplex (paper sides) box in print dialog Change-Id: I223335dd9e02f8b09947a7b97ef4d718716a464b Reviewed-on: https://gerrit.libreoffice.org/57833 Tested-by: Jenkins Reviewed-by: Katarina Behrens diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx index f219087c2f2b..21117df0a5fe 100644 --- a/include/vcl/print.hxx +++ b/include/vcl/print.hxx @@ -309,6 +309,7 @@ public: boolSetOrientation( Orientation eOrient ); Orientation GetOrientation() const; voidSetDuplexMode( DuplexMode ); +DuplexMode GetDuplexMode() const; boolSetPaperBin( sal_uInt16 nPaperBin ); sal_uInt16 GetPaperBin() const; diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx index 659e28c275fe..86b6cf6d1a07 100644 --- a/vcl/inc/printdlg.hxx +++ b/vcl/inc/printdlg.hxx @@ -143,6 +143,7 @@ namespace vcl VclPtrmpCopyCountField; VclPtrmpCollateBox; VclPtr mpCollateImage; +VclPtr mpPaperSidesBox; VclPtrmpReverseOrderBox; VclPtrmpOKButton; @@ -226,6 +227,7 @@ namespace vcl css::beans::PropertyValue* getValueForWindow( vcl::Window* ) const; void preparePreview( bool i_bPrintChanged = true, bool i_bMayUseCache = false ); +void setupPaperSidesBox(); void setPreviewText(); void updatePrinterText(); void checkControlDependencies(); diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index bc7716496e13..e285d93007d2 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -1550,6 +1550,11 @@ void Printer::SetDuplexMode( DuplexMode eDuplex ) } } +DuplexMode Printer::GetDuplexMode() const +{ +return maJobSetup.ImplGetConstData().GetDuplexMode(); +} + Paper Printer::GetPaper() const { return maJobSetup.ImplGetConstData().GetPaperFormat(); diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx index 1ef167a9e0c7..7b9ff7f7cd80 100644 --- a/vcl/source/window/printdlg.cxx +++ b/vcl/source/window/printdlg.cxx @@ -556,6 +556,7 @@ PrintDialog::PrintDialog(vcl::Window* i_pWindow, const std::shared_ptrGrabFocus(); mpCopyCountField->SetSelection( Selection(0, 0x) ); @@ -679,6 +683,7 @@ PrintDialog::PrintDialog(vcl::Window* i_pWindow, const std::shared_ptrSetSelectHdl( LINK( this, PrintDialog, SelectHdl ) ); +mpPaperSidesBox->SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) ); mpNupPagesBox->SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) ); mpNupOrientationBox->SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) ); mpNupOrderBox->SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) ); @@ -725,6 +730,7 @@ void PrintDialog::dispose() mpCopyCountField.clear(); mpCollateBox.clear(); mpCollateImage.clear(); +mpPaperSidesBox.clear(); mpReverseOrderBox.clear(); mpPagesBtn.clear(); mpBrochureBtn.clear(); @@ -750,6 +756,22 @@ void PrintDialog::dispose() ModalDialog::dispose(); } +void PrintDialog::setupPaperSidesBox() +{ +DuplexMode eDuplex = maPController->getPrinter()->GetDuplexMode(); + +if ( eDuplex == DuplexMode::Unknown || isPrintToFile() ) +{ +mpPaperSidesBox->SelectEntryPos( 0 ); +mpPaperSidesBox->Enable( false ); +} +else +{ +mpPaperSidesBox->SelectEntryPos( static_cast(eDuplex) - 1 ); +mpPaperSidesBox->Enable( true ); +} +} + void PrintDialog::setPaperSizes() { mpPaperSizeBox->Clear(); @@ -1788,6 +1810,13 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox&, rBox, void ) setPaperSizes(); preparePreview( true, true ); } + +setupPaperSidesBox(); +} +else if ( == mpPaperSidesBox ) +{ +DuplexMode eDuplex = static_cast(mpPaperSidesBox->GetSelectedEntryPos() + 1); +maPController->getPrinter()->SetDuplexMode( eDuplex ); } else if( == mpNupOrientationBox || == mpNupOrderBox ) { diff --git a/vcl/uiconfig/ui/printdialog.ui b/vcl/uiconfig/ui/printdialog.ui index 0073dbf1e5f4..2e5118c24cd4 100644 --- a/vcl/uiconfig/ui/printdialog.ui +++ b/vcl/uiconfig/ui/printdialog.ui @@ -87,6 +87,23 @@ + + + + + + + +Print only in