summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorOliver Specht <oliver.specht@cib.de>2024-01-18 08:48:10 +0100
committerAndras Timar <andras.timar@collabora.com>2024-02-09 20:09:40 +0100
commit96af55c34c0ce90c05886d5a546adfff80e3725e (patch)
tree000dec71f955e909d3aa1e020e284e8f189bc2ff /vcl
parent7fc0e5b7f6d28aa9a4e6e7b6f836440b33a0ba89 (diff)
tdf#159254 import paper bin/paper source from rtf/docx files
Imports \binfsxn and \binsxn from RTF and w:paperSrc from docx files and applies paper tray to the page style if the printer supports the imported tray value. Works only on Windows. Change-Id: Ie1170c58f7114f0dbf6bdd2721d4e077886cbe16 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162236 Tested-by: Jenkins Tested-by: Gabor Kelemen <gabor.kelemen.extern@allotropia.de> Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163119
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/osx/salprn.h2
-rw-r--r--vcl/inc/salprn.hxx3
-rw-r--r--vcl/inc/unx/genprn.h2
-rw-r--r--vcl/inc/win/salprn.h3
-rw-r--r--vcl/osx/salprn.cxx5
-rw-r--r--vcl/source/gdi/print.cxx8
-rw-r--r--vcl/unx/generic/print/genprnpsp.cxx5
-rw-r--r--vcl/win/gdi/salprn.cxx19
8 files changed, 47 insertions, 0 deletions
diff --git a/vcl/inc/osx/salprn.h b/vcl/inc/osx/salprn.h
index 7bfd41787e99..9c26e171db23 100644
--- a/vcl/inc/osx/salprn.h
+++ b/vcl/inc/osx/salprn.h
@@ -82,6 +82,8 @@ class AquaSalInfoPrinter : public SalInfoPrinter
virtual sal_uInt32 GetCapabilities( const ImplJobSetup* i_pSetupData, PrinterCapType i_nType ) override;
virtual sal_uInt16 GetPaperBinCount( const ImplJobSetup* i_pSetupData ) override;
virtual OUString GetPaperBinName( const ImplJobSetup* i_pSetupData, sal_uInt16 i_nPaperBin ) override;
+ virtual sal_uInt16 GetPaperBinBySourceIndex(const ImplJobSetup* pSetupData,
+ sal_uInt16 nPaperSource) override;
virtual void InitPaperFormats( const ImplJobSetup* i_pSetupData ) override;
virtual int GetLandscapeAngle( const ImplJobSetup* i_pSetupData ) override;
diff --git a/vcl/inc/salprn.hxx b/vcl/inc/salprn.hxx
index 97a0fe13aab2..ae0b313dab05 100644
--- a/vcl/inc/salprn.hxx
+++ b/vcl/inc/salprn.hxx
@@ -82,6 +82,9 @@ public:
virtual sal_uInt32 GetCapabilities( const ImplJobSetup* pSetupData, PrinterCapType nType ) = 0;
virtual sal_uInt16 GetPaperBinCount( const ImplJobSetup* pSetupData ) = 0;
virtual OUString GetPaperBinName( const ImplJobSetup* pSetupData, sal_uInt16 nPaperBin ) = 0;
+ virtual sal_uInt16 GetPaperBinBySourceIndex(const ImplJobSetup* pSetupData,
+ sal_uInt16 nPaperSource) = 0;
+
// fills m_aPaperFormats and sets m_bPapersInit to true
virtual void InitPaperFormats( const ImplJobSetup* pSetupData ) = 0;
// returns angle that a landscape page will be turned counterclockwise wrt to portrait
diff --git a/vcl/inc/unx/genprn.h b/vcl/inc/unx/genprn.h
index d030c461439a..abe84b71ca21 100644
--- a/vcl/inc/unx/genprn.h
+++ b/vcl/inc/unx/genprn.h
@@ -45,6 +45,8 @@ public:
virtual sal_uInt32 GetCapabilities( const ImplJobSetup* pSetupData, PrinterCapType nType ) override;
virtual sal_uInt16 GetPaperBinCount( const ImplJobSetup* pSetupData ) override;
virtual OUString GetPaperBinName( const ImplJobSetup* pSetupData, sal_uInt16 nPaperBin ) override;
+ virtual sal_uInt16 GetPaperBinBySourceIndex(const ImplJobSetup* pSetupData,
+ sal_uInt16 nPaperSource) override;
virtual void InitPaperFormats( const ImplJobSetup* pSetupData ) override;
virtual int GetLandscapeAngle( const ImplJobSetup* pSetupData ) override;
};
diff --git a/vcl/inc/win/salprn.h b/vcl/inc/win/salprn.h
index e1bbb665e29d..b0ec1697c3a5 100644
--- a/vcl/inc/win/salprn.h
+++ b/vcl/inc/win/salprn.h
@@ -69,6 +69,9 @@ public:
virtual sal_uInt32 GetCapabilities( const ImplJobSetup* pSetupData, PrinterCapType nType ) override;
virtual sal_uInt16 GetPaperBinCount( const ImplJobSetup* pSetupData ) override;
virtual OUString GetPaperBinName( const ImplJobSetup* pSetupData, sal_uInt16 nPaperBin ) override;
+ virtual sal_uInt16 GetPaperBinBySourceIndex(const ImplJobSetup* pSetupData,
+ sal_uInt16 nPaperSource) override;
+
virtual void InitPaperFormats( const ImplJobSetup* pSetupData ) override;
virtual int GetLandscapeAngle( const ImplJobSetup* pSetupData ) override;
};
diff --git a/vcl/osx/salprn.cxx b/vcl/osx/salprn.cxx
index 9f9c8c08f3db..3de45d9e8005 100644
--- a/vcl/osx/salprn.cxx
+++ b/vcl/osx/salprn.cxx
@@ -265,6 +265,11 @@ OUString AquaSalInfoPrinter::GetPaperBinName( const ImplJobSetup*, sal_uInt16 )
return OUString();
}
+sal_uInt16 AquaSalInfoPrinter::GetPaperBinBySourceIndex( const ImplJobSetup*, sal_uInt16 )
+{
+ return 0xffff;
+}
+
sal_uInt32 AquaSalInfoPrinter::GetCapabilities( const ImplJobSetup*, PrinterCapType i_nType )
{
switch( i_nType )
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index eff94a9211ea..401d38118c38 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -1479,6 +1479,14 @@ OUString Printer::GetPaperBinName( sal_uInt16 nPaperBin ) const
return OUString();
}
+sal_uInt16 Printer::GetPaperBinBySourceIndex(sal_uInt16 nPaperSource) const
+{
+ if ( IsDisplayPrinter() )
+ return 0;
+
+ return mpInfoPrinter->GetPaperBinBySourceIndex( &maJobSetup.ImplGetConstData(), nPaperSource );
+}
+
void Printer::SetCopyCount( sal_uInt16 nCopy, bool bCollate )
{
mnCopyCount = nCopy;
diff --git a/vcl/unx/generic/print/genprnpsp.cxx b/vcl/unx/generic/print/genprnpsp.cxx
index 33990decad1c..ce5a45624dfc 100644
--- a/vcl/unx/generic/print/genprnpsp.cxx
+++ b/vcl/unx/generic/print/genprnpsp.cxx
@@ -638,6 +638,11 @@ OUString PspSalInfoPrinter::GetPaperBinName( const ImplJobSetup* pJobSetup, sal_
return OUString();
}
+sal_uInt16 PspSalInfoPrinter::GetPaperBinBySourceIndex( const ImplJobSetup*, sal_uInt16 )
+{
+ return 0xffff;
+}
+
sal_uInt32 PspSalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, PrinterCapType nType )
{
switch( nType )
diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx
index 3302efa2d986..065b06019635 100644
--- a/vcl/win/gdi/salprn.cxx
+++ b/vcl/win/gdi/salprn.cxx
@@ -1196,6 +1196,25 @@ OUString WinSalInfoPrinter::GetPaperBinName( const ImplJobSetup* pSetupData, sal
return aPaperBinName;
}
+sal_uInt16 WinSalInfoPrinter::GetPaperBinBySourceIndex( const ImplJobSetup* pSetupData, sal_uInt16 nPaperSource )
+{
+ DWORD nBins = ImplDeviceCaps( this, DC_BINNAMES, nullptr, pSetupData );
+ if (nBins != GDI_ERROR)
+ {
+ auto pBuffer = std::make_unique<sal_uInt16[]>(nBins);
+ DWORD nBins = ImplDeviceCaps( this, DC_BINS, reinterpret_cast<BYTE*>(pBuffer.get()), pSetupData );
+ if (nBins != GDI_ERROR)
+ {
+ for (DWORD nBin = 0; nBin < nBins; ++nBin)
+ {
+ if (nPaperSource == *(pBuffer.get() + nBin))
+ return nBin;
+ }
+ }
+ }
+ return 0xffff;
+}
+
sal_uInt32 WinSalInfoPrinter::GetCapabilities( const ImplJobSetup* pSetupData, PrinterCapType nType )
{
DWORD nRet;