summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Specht <oliver.specht@cib.de>2024-02-20 13:25:41 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2024-02-23 12:11:42 +0100
commit8b191a6566065438417665af32fa30f8346ad4df (patch)
tree289e275b82c2f7db0c6088e8e041437ecd505f42
parent0feb1b2c4a11317159195e451bf7a1a0dd755dd8 (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>
-rw-r--r--include/vcl/print.hxx1
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx12
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.cxx11
-rw-r--r--vcl/inc/osx/salprn.h2
-rw-r--r--vcl/inc/salprn.hxx2
-rw-r--r--vcl/inc/unx/genprn.h2
-rw-r--r--vcl/inc/win/salprn.h2
-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.cxx16
11 files changed, 62 insertions, 4 deletions
diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index 870ed5d915a1..3da922afa884 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -234,6 +234,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 8f4c8fb3dcb7..4f3152b6bc2e 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;
@@ -9138,9 +9140,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 cdf6d5ce9bd1..b3fbec75a8f5 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;
@@ -3328,9 +3330,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 81081afe64ef..3697e51c338d 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -1488,6 +1488,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 302d74375f5c..5fd3886312e3 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;