summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorDaniel Silva <danielfaleirosilva@gmail.com>2018-06-29 11:36:03 -0300
committerDaniel Silva <danielfaleirosilva@gmail.com>2018-11-29 13:02:16 -0200
commitff4896a2af1df6138e9246fe1588dfe8c3748f1a (patch)
tree73dbd9d54f1a760a14756ecb2259cadf8bc130ee /vcl
parent1a2ebd24e5daaefa209dea7f4b1889a8295b5794 (diff)
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@cib.de>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/print.hrc4
-rw-r--r--vcl/inc/printdlg.hxx4
-rw-r--r--vcl/source/gdi/print.cxx10
-rw-r--r--vcl/source/window/printdlg.cxx90
4 files changed, 101 insertions, 7 deletions
diff --git a/vcl/inc/print.hrc b/vcl/inc/print.hrc
index 505f508b45b8..fced0004312d 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 8ea63dfd4986..701a5fa9598e 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 cff0450231f7..32da4f83cf34 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -1432,14 +1432,14 @@ OUString Printer::GetPaperName( Paper ePaper )
{
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)
@@ -1470,6 +1470,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 d410e62d1261..80df9a54475d 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -564,6 +564,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");
@@ -629,6 +630,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();
@@ -679,6 +683,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 ) );
@@ -736,6 +741,7 @@ void PrintDialog::dispose()
mpSheetMarginTxt1.clear();
mpSheetMarginEdt.clear();
mpSheetMarginTxt2.clear();
+ mpPaperSizeBox.clear();
mpNupOrientationBox.clear();
mpNupOrderBox.clear();
mpNupOrderWin.clear();
@@ -745,6 +751,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() );
@@ -787,7 +838,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()
@@ -820,7 +871,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()
@@ -1687,6 +1738,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();
}
@@ -1699,8 +1768,7 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox&, rBox, void )
{
if( &rBox == mpPrinters )
{
-
- if ( rBox.GetSelectedEntryPos() != 0)
+ if ( !isPrintToFile() )
{
OUString aNewPrinter( rBox.GetSelectedEntry() );
// set new printer
@@ -1709,6 +1777,7 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox&, rBox, void )
// update text fields
mpOKButton->SetText( maPrintText );
updatePrinterText();
+ setPaperSizes();
preparePreview();
}
else // print to file
@@ -1717,6 +1786,7 @@ IMPL_LINK( PrintDialog, SelectHdl, ListBox&, rBox, void )
maPController->setPrinter( VclPtrInstance<Printer>( Printer::GetDefaultPrinterName() ) );
mpOKButton->SetText( maPrintToFileText );
maPController->resetPrinterOptions( true );
+ setPaperSizes();
preparePreview( true, true );
}
}
@@ -1730,6 +1800,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 )