Kaydet (Commit) 8cbdc6a0 authored tarafından Daniel's avatar Daniel Kaydeden (comit) Daniel Silva

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: 's avatarDaniel Silva <danielfaleirosilva@gmail.com>
üst faf2b0f1
......@@ -547,7 +547,10 @@ public:
VCL_DLLPRIVATE bool getReversePrint() const;
VCL_DLLPRIVATE void setPapersizeFromSetup( bool i_bPapersizeFromSetup );
VCL_DLLPRIVATE bool getPapersizeFromSetup() const;
VCL_DLLPRIVATE Size& getPaperSizeSetup() const;
VCL_DLLPRIVATE void setPaperSizeFromUser( Size i_aUserSize );
VCL_DLLPRIVATE Size& getPaperSizeFromUser() const;
VCL_DLLPRIVATE bool isPaperSizeFromUser() const;
void setPrinterModified( bool i_bPapersizeFromSetup );
bool getPrinterModified() const;
VCL_DLLPRIVATE void pushPropertiesToPrinter();
......
......@@ -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();
......
......@@ -1380,6 +1380,11 @@ bool PrinterController::getPapersizeFromSetup() const
return mpImplData->mbPapersizeFromSetup;
}
Size& PrinterController::getPaperSizeSetup() const
{
return mpImplData->maDefaultPageSize;
}
void PrinterController::setPaperSizeFromUser( Size i_aUserSize )
{
mpImplData->mbPapersizeFromUser = true;
......@@ -1389,6 +1394,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;
......
......@@ -1038,11 +1038,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) ) );
}
......@@ -2009,7 +2034,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();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment