diff options
author | Oliver Specht <oliver.specht@cib.de> | 2024-02-20 13:25:41 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2024-03-07 13:54:18 +0100 |
commit | 060851706f280386e4b968ad6b53c6e1cbc48ab6 (patch) | |
tree | 6f70beea9e5539f3890be2f4d18309ae557968b4 | |
parent | 9703fddea1058cb6018a5e693f03909d2b37315c (diff) |
tdf#159793 Save printer paper tray in RTF and DOCX
Saves the paper tray id as w:paperSrc w:first and w:other in docx
and \binfsxn and \binsxn in RTF
Change-Id: I79004f54aba3b6609d7921afacf815726f7f2678
Change-Id: Ie3c11fffa6a133250b7db69b4e845bccaa8e2280
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163654
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit 8b191a6566065438417665af32fa30f8346ad4df)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163831
-rw-r--r-- | include/vcl/print.hxx | 1 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 12 | ||||
-rw-r--r-- | sw/source/filter/ww8/rtfattributeoutput.cxx | 11 | ||||
-rw-r--r-- | vcl/inc/osx/salprn.h | 2 | ||||
-rw-r--r-- | vcl/inc/salprn.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/unx/genprn.h | 2 | ||||
-rw-r--r-- | vcl/inc/win/salprn.h | 2 | ||||
-rw-r--r-- | vcl/osx/salprn.cxx | 5 | ||||
-rw-r--r-- | vcl/source/gdi/print.cxx | 8 | ||||
-rw-r--r-- | vcl/unx/generic/print/genprnpsp.cxx | 5 | ||||
-rw-r--r-- | vcl/win/gdi/salprn.cxx | 16 |
11 files changed, 62 insertions, 4 deletions
diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx index e23cf8d0af1b..e7c88f56bdd8 100644 --- a/include/vcl/print.hxx +++ b/include/vcl/print.hxx @@ -228,6 +228,7 @@ public: bool SetPaperBin( sal_uInt16 nPaperBin ); sal_uInt16 GetPaperBin() const; sal_uInt16 GetPaperBinBySourceIndex(sal_uInt16 nPaperSource) const; + sal_uInt16 GetSourceIndexByPaperBin(sal_uInt16 nPaperBin) const; void SetPaper( Paper ePaper ); bool SetPaperSizeUser( const Size& rSize ); /** @return The paper format of the printer's current "jobsetup". Note that if PAPER_USER the actual size can be anything. */ diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 3b5d57fc27b2..9b8c4dbceb2b 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -161,6 +161,8 @@ #include <frozen/bits/defines.h> #include <frozen/bits/elsa_std.h> #include <frozen/unordered_map.h> +#include <IDocumentDeviceAccess.hxx> +#include <sfx2/printer.hxx> using ::editeng::SvxBorderLine; @@ -9143,9 +9145,15 @@ void DocxAttributeOutput::FormatFrameSize( const SwFormatFrameSize& rSize ) } } -void DocxAttributeOutput::FormatPaperBin( const SvxPaperBinItem& ) +void DocxAttributeOutput::FormatPaperBin(const SvxPaperBinItem& rPaperBin) { - SAL_INFO("sw.ww8", "TODO DocxAttributeOutput::FormatPaperBin()" ); + sal_Int8 nPaperBin = rPaperBin.GetValue(); + rtl::Reference<FastAttributeList> attrList = FastSerializerHelper::createAttrList( ); + SfxPrinter* pPrinter = m_rExport.m_rDoc.getIDocumentDeviceAccess().getPrinter(true); + sal_Int16 nPaperSource = pPrinter->GetSourceIndexByPaperBin(nPaperBin); + attrList->add( FSNS( XML_w, XML_first ), OString::number(nPaperSource) ); + attrList->add( FSNS( XML_w, XML_other ), OString::number(nPaperSource) ); + m_pSerializer->singleElementNS( XML_w, XML_paperSrc, attrList ); } void DocxAttributeOutput::FormatFirstLineIndent(SvxFirstLineIndentItem const& rFirstLine) diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx index 26203291d6e5..57a4bdf23147 100644 --- a/sw/source/filter/ww8/rtfattributeoutput.cxx +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx @@ -94,6 +94,8 @@ #include <formatflysplit.hxx> #include <fmtwrapinfluenceonobjpos.hxx> #include "rtfexport.hxx" +#include <IDocumentDeviceAccess.hxx> +#include <sfx2/printer.hxx> using namespace ::com::sun::star; using namespace sw::util; @@ -3329,9 +3331,14 @@ void RtfAttributeOutput::FormatFrameSize(const SwFormatFrameSize& rSize) } } -void RtfAttributeOutput::FormatPaperBin(const SvxPaperBinItem& /*rItem*/) +void RtfAttributeOutput::FormatPaperBin(const SvxPaperBinItem& rItem) { - SAL_INFO("sw.rtf", "TODO: " << __func__); + SfxPrinter* pPrinter = m_rExport.m_rDoc.getIDocumentDeviceAccess().getPrinter(true); + sal_Int16 nPaperSource = pPrinter->GetSourceIndexByPaperBin(rItem.GetValue()); + m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_BINFSXN); + m_aSectionBreaks.append(static_cast<sal_Int32>(nPaperSource)); + m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_BINSXN); + m_aSectionBreaks.append(static_cast<sal_Int32>(nPaperSource)); } void RtfAttributeOutput::FormatFirstLineIndent(SvxFirstLineIndentItem const& rFirstLine) diff --git a/vcl/inc/osx/salprn.h b/vcl/inc/osx/salprn.h index 9c26e171db23..cd262795178e 100644 --- a/vcl/inc/osx/salprn.h +++ b/vcl/inc/osx/salprn.h @@ -84,6 +84,8 @@ class AquaSalInfoPrinter : public SalInfoPrinter virtual OUString GetPaperBinName( const ImplJobSetup* i_pSetupData, sal_uInt16 i_nPaperBin ) override; virtual sal_uInt16 GetPaperBinBySourceIndex(const ImplJobSetup* pSetupData, sal_uInt16 nPaperSource) override; + virtual sal_uInt16 GetSourceIndexByPaperBin(const ImplJobSetup* pSetupData, + sal_uInt16 nPaperBin) 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 ae0b313dab05..05dca2fcabec 100644 --- a/vcl/inc/salprn.hxx +++ b/vcl/inc/salprn.hxx @@ -84,6 +84,8 @@ public: virtual OUString GetPaperBinName( const ImplJobSetup* pSetupData, sal_uInt16 nPaperBin ) = 0; virtual sal_uInt16 GetPaperBinBySourceIndex(const ImplJobSetup* pSetupData, sal_uInt16 nPaperSource) = 0; + virtual sal_uInt16 GetSourceIndexByPaperBin(const ImplJobSetup* pSetupData, + sal_uInt16 nPaperSource) = 0; // fills m_aPaperFormats and sets m_bPapersInit to true virtual void InitPaperFormats( const ImplJobSetup* pSetupData ) = 0; diff --git a/vcl/inc/unx/genprn.h b/vcl/inc/unx/genprn.h index abe84b71ca21..b4fb2c8b35ef 100644 --- a/vcl/inc/unx/genprn.h +++ b/vcl/inc/unx/genprn.h @@ -47,6 +47,8 @@ public: virtual OUString GetPaperBinName( const ImplJobSetup* pSetupData, sal_uInt16 nPaperBin ) override; virtual sal_uInt16 GetPaperBinBySourceIndex(const ImplJobSetup* pSetupData, sal_uInt16 nPaperSource) override; + virtual sal_uInt16 GetSourceIndexByPaperBin(const ImplJobSetup* pSetupData, + sal_uInt16 nPaperBin) 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 b0ec1697c3a5..d44687d8e060 100644 --- a/vcl/inc/win/salprn.h +++ b/vcl/inc/win/salprn.h @@ -71,6 +71,8 @@ public: virtual OUString GetPaperBinName( const ImplJobSetup* pSetupData, sal_uInt16 nPaperBin ) override; virtual sal_uInt16 GetPaperBinBySourceIndex(const ImplJobSetup* pSetupData, sal_uInt16 nPaperSource) override; + virtual sal_uInt16 GetSourceIndexByPaperBin(const ImplJobSetup* pSetupData, + sal_uInt16 nPaperBin) 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 3de45d9e8005..3fe37a9ab55e 100644 --- a/vcl/osx/salprn.cxx +++ b/vcl/osx/salprn.cxx @@ -270,6 +270,11 @@ sal_uInt16 AquaSalInfoPrinter::GetPaperBinBySourceIndex( const ImplJobSetup*, sa return 0xffff; } +sal_uInt16 AquaSalInfoPrinter::GetSourceIndexByPaperBin(const ImplJobSetup*, sal_uInt16) +{ + return 0; +} + 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 401d38118c38..2519e5ca44fa 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -1487,6 +1487,14 @@ sal_uInt16 Printer::GetPaperBinBySourceIndex(sal_uInt16 nPaperSource) const return mpInfoPrinter->GetPaperBinBySourceIndex( &maJobSetup.ImplGetConstData(), nPaperSource ); } +sal_uInt16 Printer::GetSourceIndexByPaperBin(sal_uInt16 nPaperBin) const +{ + if (IsDisplayPrinter()) + return 0; + + return mpInfoPrinter->GetSourceIndexByPaperBin( &maJobSetup.ImplGetConstData(), nPaperBin); +} + 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 ce5a45624dfc..1e7edb8e0909 100644 --- a/vcl/unx/generic/print/genprnpsp.cxx +++ b/vcl/unx/generic/print/genprnpsp.cxx @@ -643,6 +643,11 @@ sal_uInt16 PspSalInfoPrinter::GetPaperBinBySourceIndex( const ImplJobSetup*, sal return 0xffff; } +sal_uInt16 PspSalInfoPrinter::GetSourceIndexByPaperBin(const ImplJobSetup*, sal_uInt16) +{ + return 0; +} + 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 065b06019635..aeb3e2b8767a 100644 --- a/vcl/win/gdi/salprn.cxx +++ b/vcl/win/gdi/salprn.cxx @@ -1215,6 +1215,22 @@ sal_uInt16 WinSalInfoPrinter::GetPaperBinBySourceIndex( const ImplJobSetup* pSet return 0xffff; } +sal_uInt16 WinSalInfoPrinter::GetSourceIndexByPaperBin(const ImplJobSetup* pSetupData, sal_uInt16 nPaperBin) +{ + 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 && nBins > nPaperBin) + { + return *(pBuffer.get() + nPaperBin); + } + } + return 0; +} + + sal_uInt32 WinSalInfoPrinter::GetCapabilities( const ImplJobSetup* pSetupData, PrinterCapType nType ) { DWORD nRet; |