[Libreoffice-commits] core.git: Branch 'feature/print_revamp' - include/vcl vcl/inc vcl/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sun Aug 12 23:29:34 UTC 2018
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 <danielfaleirosilva at gmail.com>
AuthorDate: Sun Aug 12 17:32:30 2018 -0300
Commit: Daniel Silva <danielfaleirosilva at gmail.com>
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 <danielfaleirosilva at gmail.com>
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_DLLPRIVATE bool getReversePrint() const;
SAL_DLLPRIVATE void setPapersizeFromSetup( bool i_bPapersizeFromSetup );
SAL_DLLPRIVATE bool getPapersizeFromSetup() const;
+ SAL_DLLPRIVATE Size& getPaperSizeSetup() const;
SAL_DLLPRIVATE void setPaperSizeFromUser( Size i_aUserSize );
+ SAL_DLLPRIVATE Size& getPaperSizeFromUser() const;
+ SAL_DLLPRIVATE bool isPaperSizeFromUser() const;
VCL_PLUGIN_PUBLIC void setPrinterModified( bool i_bPapersizeFromSetup );
VCL_PLUGIN_PUBLIC bool getPrinterModified() const;
SAL_DLLPRIVATE void 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<Printer> 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( static_cast<sal_Int32>(eOrientation) ) );
}
@@ -2008,7 +2033,10 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox&, rBox, void )
else
aPrt->SetPaper( mePaper );
- maPController->setPaperSizeFromUser( Size( aInfo.getWidth(), aInfo.getHeight() ) );
+ Size aPaperSize = Size( aInfo.getWidth(), aInfo.getHeight() );
+ checkPaperSize( aPaperSize );
+ maPController->setPaperSizeFromUser( aPaperSize );
+
preparePreview();
}
}
More information about the Libreoffice-commits
mailing list