[Libreoffice-commits] core.git: Branch 'feature/print_revamp' - i18nutil/source include/vcl vcl/inc vcl/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Jul 26 19:16:52 UTC 2018
i18nutil/source/utility/paper.cxx | 5 +-
include/vcl/print.hxx | 1
vcl/inc/print.hrc | 4 +
vcl/inc/printdlg.hxx | 4 +
vcl/source/gdi/print.cxx | 10 +++-
vcl/source/window/printdlg.cxx | 90 ++++++++++++++++++++++++++++++++++++--
6 files changed, 106 insertions(+), 8 deletions(-)
New commits:
commit 4acb86cea21de5e1d8907535e1c7ee2f94086ec1
Author: Daniel Silva <danielfaleirosilva at gmail.com>
AuthorDate: Fri Jun 29 11:36:03 2018 -0300
Commit: Katarina Behrens <Katarina.Behrens at cib.de>
CommitDate: Thu Jul 26 21:16:28 2018 +0200
Sets paper sizes listbox in print dialog
Change-Id: Iaeb50f6e854b90c1062d2ed6e3e053a6c26ea520
Reviewed-on: https://gerrit.libreoffice.org/56711
Tested-by: Jenkins
Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>
diff --git a/i18nutil/source/utility/paper.cxx b/i18nutil/source/utility/paper.cxx
index c2728f697183..473b8e1d977f 100644
--- a/i18nutil/source/utility/paper.cxx
+++ b/i18nutil/source/utility/paper.cxx
@@ -168,8 +168,11 @@ void PaperInfo::doSloppyFit()
long lDiffW = labs(aDinTab[i].m_nWidth - m_nPaperWidth);
long lDiffH = labs(aDinTab[i].m_nHeight - m_nPaperHeight);
+ long lFlipDiffW = labs(aDinTab[i].m_nHeight - m_nPaperWidth);
+ long lFlipDiffH = labs(aDinTab[i].m_nWidth - m_nPaperHeight);
- if ( lDiffW < MAXSLOPPY && lDiffH < MAXSLOPPY )
+ if ( (lDiffW < MAXSLOPPY && lDiffH < MAXSLOPPY) ||
+ (lFlipDiffW < MAXSLOPPY && lFlipDiffH < MAXSLOPPY) )
{
m_nPaperWidth = aDinTab[i].m_nWidth;
m_nPaperHeight = aDinTab[i].m_nHeight;
diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index c80b514b05df..f219087c2f2b 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -334,6 +334,7 @@ public:
const Size& GetPaperSizePixel() const { return maPaperSize; }
Size GetPaperSize() const { return PixelToLogic( maPaperSize ); }
+ Size GetPaperSize( int nPaper );
const Point& GetPageOffsetPixel() const { return maPageOffset; }
Point GetPageOffset() const { return PixelToLogic( maPageOffset ); }
diff --git a/vcl/inc/print.hrc b/vcl/inc/print.hrc
index b1b3d47c7be3..db8cbdf4bdcf 100644
--- a/vcl/inc/print.hrc
+++ b/vcl/inc/print.hrc
@@ -31,6 +31,7 @@ const char* RID_STR_PAPERNAMES[] =
NC_("RID_STR_PAPERNAMES", "A3"),
NC_("RID_STR_PAPERNAMES", "A4"),
NC_("RID_STR_PAPERNAMES", "A5"),
+ NC_("RID_STR_PAPERNAMES", "A6"),
NC_("RID_STR_PAPERNAMES", "B4 (ISO)"),
NC_("RID_STR_PAPERNAMES", "B5 (ISO)"),
NC_("RID_STR_PAPERNAMES", "Letter"),
@@ -61,8 +62,9 @@ const char* RID_STR_PAPERNAMES[] =
NC_("RID_STR_PAPERNAMES", "B4 (JIS)"),
NC_("RID_STR_PAPERNAMES", "B5 (JIS)"),
NC_("RID_STR_PAPERNAMES", "B6 (JIS)"),
+ NC_("RID_STR_PAPERNAMES", "Japanese Postcard"),
// To translators: This is the last entry of the sequence of paper size names
- NC_("RID_STR_PAPERNAMES", "Japanese Postcard")
+ NC_("RID_STR_PAPERNAMES", "Double Postcard")
};
#endif // INCLUDED_VCL_INC_PRINT_HRC
diff --git a/vcl/inc/printdlg.hxx b/vcl/inc/printdlg.hxx
index 0be16fcd8413..659e28c275fe 100644
--- a/vcl/inc/printdlg.hxx
+++ b/vcl/inc/printdlg.hxx
@@ -119,6 +119,7 @@ namespace vcl
bool isSingleJobs() const { return mbSingleJobs; };
bool hasPreview();
+ void setPaperSizes();
void previewForward();
void previewBackward();
@@ -183,6 +184,7 @@ namespace vcl
VclPtr<FixedText> mpSheetMarginTxt1;
VclPtr<MetricField> mpSheetMarginEdt;
VclPtr<FixedText> mpSheetMarginTxt2;
+ VclPtr<ListBox> mpPaperSizeBox;
VclPtr<ListBox> mpNupOrientationBox;
// page order ("left to right, then down")
@@ -208,6 +210,8 @@ namespace vcl
bool mbShowLayoutFrame;
bool mbSingleJobs;
+ Paper mePaper;
+
DECL_LINK( ClickHdl, Button*, void );
DECL_LINK( SelectHdl, ListBox&, void );
DECL_LINK( ModifyHdl, Edit&, void );
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index a5fe96a76db0..1abec5c36def 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -1471,14 +1471,14 @@ OUString Printer::GetPaperName( Paper ePaper )
pSVData->mpPaperNames = new std::unordered_map< int, OUString >;
static const int PaperIndex[] =
{
- PAPER_A0, PAPER_A1, PAPER_A2, PAPER_A3, PAPER_A4, PAPER_A5,
+ PAPER_A0, PAPER_A1, PAPER_A2, PAPER_A3, PAPER_A4, PAPER_A5, PAPER_A6,
PAPER_B4_ISO, PAPER_B5_ISO, PAPER_LETTER, PAPER_LEGAL, PAPER_TABLOID,
PAPER_USER, PAPER_B6_ISO, PAPER_ENV_C4, PAPER_ENV_C5, PAPER_ENV_C6, PAPER_ENV_C65,
PAPER_ENV_DL, PAPER_SLIDE_DIA, PAPER_C, PAPER_D, PAPER_E,
PAPER_EXECUTIVE, PAPER_FANFOLD_LEGAL_DE, PAPER_ENV_MONARCH, PAPER_ENV_PERSONAL,
PAPER_ENV_9, PAPER_ENV_10, PAPER_ENV_11, PAPER_ENV_12, PAPER_KAI16,
PAPER_KAI32, PAPER_KAI32BIG, PAPER_B4_JIS, PAPER_B5_JIS, PAPER_B6_JIS,
- PAPER_POSTCARD_JP
+ PAPER_POSTCARD_JP, PAPER_DOUBLEPOSTCARD_JP
};
assert(SAL_N_ELEMENTS(PaperIndex) == SAL_N_ELEMENTS(RID_STR_PAPERNAMES) && "localized paper name count wrong");
for (size_t i = 0; i < SAL_N_ELEMENTS(PaperIndex); ++i)
@@ -1509,6 +1509,12 @@ const PaperInfo& Printer::GetPaperInfo( int nPaper ) const
return mpInfoPrinter->m_aPaperFormats[nPaper];
}
+Size Printer::GetPaperSize( int nPaper )
+{
+ PaperInfo aInfo = GetPaperInfo( nPaper );
+ return PixelToLogic( Size( aInfo.getWidth(), aInfo.getHeight() ) );
+}
+
void Printer::SetDuplexMode( DuplexMode eDuplex )
{
if ( mbInPrintPage )
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index c10dd7bed22f..1ef167a9e0c7 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -562,6 +562,7 @@ PrintDialog::PrintDialog(vcl::Window* i_pWindow, const std::shared_ptr<PrinterCo
get(mpNupPagesBox, "pagespersheetbox");
get(mpNupOrientationBox, "pageorientationbox");
get(mpNupOrderTxt, "labelorder");
+ get(mpPaperSizeBox, "papersizebox");
get(mpNupOrderBox, "orderbox");
get(mpPagesBtn, "pagespersheetbtn");
get(mpBrochureBtn, "brochure");
@@ -628,6 +629,9 @@ PrintDialog::PrintDialog(vcl::Window* i_pWindow, const std::shared_ptr<PrinterCo
// update the text fields for the printer
updatePrinterText();
+ // set paper sizes listbox
+ setPaperSizes();
+
// setup dependencies
checkControlDependencies();
@@ -678,6 +682,7 @@ PrintDialog::PrintDialog(vcl::Window* i_pWindow, const std::shared_ptr<PrinterCo
mpNupPagesBox->SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) );
mpNupOrientationBox->SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) );
mpNupOrderBox->SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) );
+ mpPaperSizeBox->SetSelectHdl( LINK( this, PrintDialog, SelectHdl ) );
// setup modify hdl
mpPageEdit->SetModifyHdl( LINK( this, PrintDialog, ModifyHdl ) );
@@ -735,6 +740,7 @@ void PrintDialog::dispose()
mpSheetMarginTxt1.clear();
mpSheetMarginEdt.clear();
mpSheetMarginTxt2.clear();
+ mpPaperSizeBox.clear();
mpNupOrientationBox.clear();
mpNupOrderBox.clear();
mpNupOrderWin.clear();
@@ -744,6 +750,51 @@ void PrintDialog::dispose()
ModalDialog::dispose();
}
+void PrintDialog::setPaperSizes()
+{
+ mpPaperSizeBox->Clear();
+
+ if ( isPrintToFile() )
+ {
+ mpPaperSizeBox->Enable( false );
+ }
+ else
+ {
+ VclPtr<Printer> aPrt( maPController->getPrinter() );
+ mePaper = aPrt->GetPaper();
+
+ for (int nPaper = 0; nPaper < aPrt->GetPaperInfoCount(); nPaper++)
+ {
+ PaperInfo aInfo = aPrt->GetPaperInfo( nPaper );
+ aInfo.doSloppyFit();
+ Paper ePaper = aInfo.getPaper();
+
+ const LocaleDataWrapper& rLocWrap( GetSettings().GetLocaleDataWrapper() );
+ MapUnit eUnit = MapUnit::MapMM;
+ int nDigits = 0;
+ if( rLocWrap.getMeasurementSystemEnum() == MeasurementSystem::US )
+ {
+ eUnit = MapUnit::Map100thInch;
+ nDigits = 2;
+ }
+ Size aSize = aPrt->GetPaperSize( nPaper );
+ Size aLogicPaperSize( LogicToLogic( aSize, MapMode( MapUnit::Map100thMM ), MapMode( eUnit ) ) );
+
+ OUString aWidth( rLocWrap.getNum( aLogicPaperSize.Width(), nDigits ) );
+ OUString aHeight( rLocWrap.getNum( aLogicPaperSize.Height(), nDigits ) );
+ OUString aUnit = eUnit == MapUnit::MapMM ? OUString("mm") : OUString("in");
+ OUString aPaperName = Printer::GetPaperName( ePaper ) + " " + aWidth + aUnit + " x " + aHeight + aUnit;
+
+ mpPaperSizeBox->InsertEntry( aPaperName );
+
+ if ( ePaper == mePaper )
+ mpPaperSizeBox->SelectEntryPos( nPaper );
+ }
+
+ mpPaperSizeBox->Enable( true );
+ }
+}
+
void PrintDialog::updatePrinterText()
{
const OUString aDefPrt( Printer::GetDefaultPrinterName() );
@@ -786,7 +837,7 @@ void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache )
if ( !hasPreview() )
{
mpPreviewWindow->setPreview( aMtf, aCurPageSize,
- aPrt->GetPaperName(),
+ Printer::GetPaperName( mePaper ),
maNoPreviewStr,
aPrt->GetDPIX(), aPrt->GetDPIY(),
aPrt->GetPrinterOptions().IsConvertToGreyscales()
@@ -819,7 +870,7 @@ void PrintDialog::preparePreview( bool i_bNewPage, bool i_bMayUseCache )
}
mpPreviewWindow->setPreview( aMtf, aCurPageSize,
- aPrt->GetPaperName(),
+ Printer::GetPaperName( mePaper ),
nPages > 0 ? OUString() : maNoPageStr,
aPrt->GetDPIX(), aPrt->GetDPIY(),
aPrt->GetPrinterOptions().IsConvertToGreyscales()
@@ -1686,6 +1737,24 @@ IMPL_LINK ( PrintDialog, ClickHdl, Button*, pButton, void )
{
maPController->setupPrinter(GetFrameWeld());
+ if ( !isPrintToFile() )
+ {
+ VclPtr<Printer> aPrt( maPController->getPrinter() );
+ mePaper = aPrt->GetPaper();
+
+ for (int nPaper = 0; nPaper < aPrt->GetPaperInfoCount(); nPaper++ )
+ {
+ PaperInfo aInfo = aPrt->GetPaperInfo( nPaper );
+ aInfo.doSloppyFit();
+ Paper ePaper = aInfo.getPaper();
+
+ if ( mePaper == ePaper )
+ {
+ mpPaperSizeBox->SelectEntryPos( nPaper );
+ break;
+ }
+ }
+ }
// tdf#63905 don't use cache: page size may change
preparePreview();
}
@@ -1698,8 +1767,7 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox&, rBox, void )
{
if( &rBox == mpPrinters )
{
-
- if ( rBox.GetSelectedEntryPos() != 0)
+ if ( !isPrintToFile() )
{
OUString aNewPrinter( rBox.GetSelectedEntry() );
// set new printer
@@ -1708,6 +1776,7 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox&, rBox, void )
// update text fields
mpOKButton->SetText( maPrintText );
updatePrinterText();
+ setPaperSizes();
preparePreview();
}
else // print to file
@@ -1716,6 +1785,7 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox&, rBox, void )
maPController->setPrinter( VclPtrInstance<Printer>( Printer::GetDefaultPrinterName() ) );
mpOKButton->SetText( maPrintToFileText );
maPController->resetPrinterOptions( true );
+ setPaperSizes();
preparePreview( true, true );
}
}
@@ -1729,6 +1799,18 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox&, rBox, void )
mpPagesBtn->Check();
updateNupFromPages();
}
+ else if ( &rBox == mpPaperSizeBox )
+ {
+ VclPtr<Printer> aPrt( maPController->getPrinter() );
+ PaperInfo aInfo = aPrt->GetPaperInfo( rBox.GetSelectedEntryPos() );
+ aInfo.doSloppyFit();
+ mePaper = aInfo.getPaper();
+ aPrt->SetPaper( mePaper );
+ if ( mePaper == PAPER_USER )
+ aPrt->SetPaperSizeUser( Size( aInfo.getWidth(), aInfo.getHeight() ) );
+
+ preparePreview();
+ }
}
IMPL_LINK( PrintDialog, ModifyHdl, Edit&, rEdit, void )
More information about the Libreoffice-commits
mailing list