summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--i18nutil/source/utility/paper.cxx5
-rw-r--r--include/vcl/print.hxx1
-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
6 files changed, 106 insertions, 8 deletions
diff --git a/i18nutil/source/utility/paper.cxx b/i18nutil/source/utility/paper.cxx
index 9c1476c0dc03..07a8cc695adf 100644
--- a/i18nutil/source/utility/paper.cxx
+++ b/i18nutil/source/utility/paper.cxx
@@ -169,8 +169,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 631c38a5ab42..bb9f7d22becb 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -330,6 +330,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 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 )