20#include <rtl/ustring.hxx>
28#define JOBSET_FILE364_SYSTEM (sal_uInt16(0xFFFF))
29#define JOBSET_FILE605_SYSTEM (sal_uInt16(0xFFFE))
36struct ImplOldJobSetupData
38 char cPrinterName[64];
44struct Impl364JobSetupData
74 mnSystem( rJobSetup.GetSystem() ),
75 maPrinterName( rJobSetup.GetPrinterName() ),
76 maDriver( rJobSetup.GetDriver() ),
77 meOrientation( rJobSetup.GetOrientation() ),
78 meDuplexMode( rJobSetup.GetDuplexMode() ),
79 mnPaperBin( rJobSetup.GetPaperBin() ),
80 mePaperFormat( rJobSetup.GetPaperFormat() ),
81 mnPaperWidth( rJobSetup.GetPaperWidth() ),
82 mnPaperHeight( rJobSetup.GetPaperHeight() ),
83 mnDriverDataLen( rJobSetup.GetDriverDataLen() ),
84 mbPapersizeFromSetup( rJobSetup.GetPapersizeFromSetup() ),
85 meSetupMode( rJobSetup.GetPrinterSetupMode() ),
86 maValueMap( rJobSetup.GetValueMap() )
227 return mpData->GetPrinterName();
243 sal_uInt16 nSystem = 0;
245 size_t nRead = nLen -
sizeof(nLen) -
sizeof(nSystem);
249 " max possible entries, but " << nRead <<
" claimed, truncating");
252 sal_uInt64
const nFirstPos = rIStream.
Tell();
253 std::unique_ptr<char[]> pTempBuf(
new char[nRead]);
254 nRead = rIStream.
ReadBytes(pTempBuf.get(), nRead);
255 if (nRead >=
sizeof(ImplOldJobSetupData))
257 ImplOldJobSetupData*
pData =
reinterpret_cast<ImplOldJobSetupData*
>(pTempBuf.get());
259 rtl_TextEncoding aStreamEncoding = RTL_TEXTENCODING_UTF8;
267 pData->cPrinterName[std::size(
pData->cPrinterName) - 1] = 0;
269 pData->cDriverName[std::size(
pData->cDriverName) - 1] = 0;
270 rJobData.
SetDriver( OStringToOUString(
pData->cDriverName, aStreamEncoding) );
276 if (nRead <
sizeof(ImplOldJobSetupData) +
sizeof(Impl364JobSetupData))
278 SAL_WARN(
"vcl",
"Parsing error: " <<
sizeof(ImplOldJobSetupData) +
sizeof(Impl364JobSetupData) <<
279 " required, but " << nRead <<
" available");
283 Impl364JobSetupData* pOldJobData =
reinterpret_cast<Impl364JobSetupData*
>(pTempBuf.get() +
sizeof( ImplOldJobSetupData ));
284 sal_uInt16 nOldJobDataSize = SVBT16ToUInt16( pOldJobData->nSize );
285 rJobData.
SetSystem( SVBT16ToUInt16( pOldJobData->nSystem ) );
289 rJobData.
SetPaperBin( SVBT16ToUInt16( pOldJobData->nPaperBin ) );
290 sal_uInt16 nPaperFormat = SVBT16ToUInt16(pOldJobData->nPaperFormat);
295 SAL_WARN(
"vcl",
"Parsing error: " << nPaperFormat <<
302 const char* pDriverData =
reinterpret_cast<const char*
>(pOldJobData) + nOldJobDataSize;
304 if (pDriverDataEnd > pTempBuf.get() + nRead)
306 SAL_WARN(
"vcl",
"corrupted job setup");
318 rIStream.
Seek( nFirstPos +
sizeof( ImplOldJobSetupData ) +
320 while( rIStream.
Tell() < nFirstPos + nRead )
324 if( aKey ==
"COMPAT_DUPLEX_MODE" )
326 if( aValue ==
"DuplexMode::Unknown" )
328 else if( aValue ==
"DuplexMode::Off" )
330 else if( aValue ==
"DuplexMode::ShortEdge" )
332 else if( aValue ==
"DuplexMode::LongEdge" )
335 else if (aKey ==
u"PRINTER_NAME")
337 else if (aKey ==
u"DRIVER_NAME")
342 SAL_WARN_IF( rIStream.
Tell() != nFirstPos+nRead,
"vcl",
"corrupted job setup" );
344 rIStream.
Seek(nFirstPos + nRead);
362 Impl364JobSetupData aOldJobData;
363 sal_uInt16 nOldJobDataSize =
sizeof( aOldJobData );
364 ShortToSVBT16( nOldJobDataSize, aOldJobData.nSize );
365 ShortToSVBT16( rJobData.
GetSystem(), aOldJobData.nSystem );
367 ShortToSVBT16(
static_cast<sal_uInt16
>(rJobData.
GetOrientation()), aOldJobData.nOrientation );
368 ShortToSVBT16( rJobData.
GetPaperBin(), aOldJobData.nPaperBin );
369 ShortToSVBT16(
static_cast<sal_uInt16
>(rJobData.
GetPaperFormat()), aOldJobData.nPaperFormat );
373 ImplOldJobSetupData aOldData = {};
375 strncpy(aOldData.cPrinterName, aPrnByteName.getStr(), std::size(aOldData.cPrinterName) - 1);
377 strncpy(aOldData.cDriverName, aDriverByteName.getStr(), std::size(aOldData.cDriverName) - 1);
381 rOStream.
WriteBytes( &aOldData,
sizeof( aOldData ) );
382 rOStream.
WriteBytes( &aOldJobData, nOldJobDataSize );
385 const std::unordered_map< OUString, OUString >& rValueMap(
388 for (
auto const&
value : rValueMap)
415 nLen = sal::static_int_cast<sal_uInt16>(rOStream.
Tell() -
nPos);
void SetDuplexMode(DuplexMode eDuplexMode)
sal_uInt16 GetSystem() const
void SetPaperHeight(tools::Long nHeight)
void SetDriverData(sal_uInt8 *pDriverData)
sal_uInt32 GetDriverDataLen() const
tools::Long GetPaperWidth() const
const sal_uInt8 * GetDriverData() const
void SetPrinterSetupMode(PrinterSetupMode eMode)
void SetValueMap(const OUString &rKey, const OUString &rValue)
bool operator==(const ImplJobSetup &rImplJobSetup) const
void SetPaperWidth(tools::Long nWidth)
std::unordered_map< OUString, OUString > maValueMap
sal_uInt32 mnDriverDataLen
void SetPapersizeFromSetup(bool bPapersizeFromSetup)
Orientation meOrientation
void SetSystem(sal_uInt16 nSystem)
Orientation GetOrientation() const
void SetPaperBin(sal_uInt16 nPaperBin)
tools::Long GetPaperHeight() const
void SetPrinterName(const OUString &rPrinterName)
tools::Long mnPaperHeight
const std::unordered_map< OUString, OUString > & GetValueMap() const
bool mbPapersizeFromSetup
void SetOrientation(Orientation eOrientation)
PrinterSetupMode meSetupMode
sal_uInt16 GetPaperBin() const
DuplexMode GetDuplexMode() const
void SetPaperFormat(Paper ePaperFormat)
const OUString & GetDriver() const
void SetDriver(const OUString &rDriver)
const OUString & GetPrinterName() const
void SetDriverDataLen(sal_uInt32 nDriverDataLen)
Paper GetPaperFormat() const
bool operator==(const JobSetup &rJobSetup) const
JobSetup & operator=(const JobSetup &rJob)
SAL_DLLPRIVATE const ImplJobSetup & ImplGetConstData() const
SAL_DLLPRIVATE ImplJobSetup & ImplGetData()
OUString const & GetPrinterName() const
std::size_t WriteBytes(const void *pData, std::size_t nSize)
SvStream & WriteUInt16(sal_uInt16 nUInt16)
sal_uInt64 Seek(sal_uInt64 nPos)
std::size_t ReadBytes(void *pData, std::size_t nSize)
rtl_TextEncoding GetStreamCharSet() const
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
sal_uInt64 remainingSize()
bool same_object(const cow_wrapper &rOther) const
#define JOBSET_FILE364_SYSTEM
SvStream & ReadJobSetup(SvStream &rIStream, JobSetup &rJobSetup)
#define JOBSET_FILE605_SYSTEM
SvStream & WriteJobSetup(SvStream &rOStream, const JobSetup &rJobSetup)
#define SAL_WARN_IF(condition, area, stream)
#define SAL_WARN(area, stream)
std::unique_ptr< sal_Int32[]> pData
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
#define NUM_PAPER_ENTRIES
OUString read_uInt16_lenPrefixed_uInt8s_ToOUString(SvStream &rStrm, rtl_TextEncoding eEnc)
TOOLS_DLLPUBLIC std::size_t write_uInt16_lenPrefixed_uInt8s_FromOString(SvStream &rStrm, std::string_view rStr)
std::size_t write_uInt16_lenPrefixed_uInt8s_FromOUString(SvStream &rStrm, std::u16string_view rStr, rtl_TextEncoding eEnc)