summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXisco Fauli <anistenis@gmail.com>2016-05-02 19:07:23 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2016-06-24 23:01:04 +0000
commit0325b22a2a2b537a71f53b7c5d3e6c13fef68911 (patch)
tree185ce849074b367c8005abb704fc4c7f271fca00
parentuitest: add a mode to just run one file (diff)
downloadcore-0325b22a2a2b537a71f53b7c5d3e6c13fef68911.tar.gz
core-0325b22a2a2b537a71f53b7c5d3e6c13fef68911.zip
tdf#62525 vcl: use cow_wrapper for jobset
Besides: * Convert ImplJobSetup to be a class. * Use ImplJobSetup's setters and getters everywhere * add some const-correctness at places Change-Id: I32101048e9be4f3950a4540b0666ed548bbcb211 Reviewed-on: https://gerrit.libreoffice.org/24594 Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de> Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
-rw-r--r--include/vcl/jobdata.hxx2
-rw-r--r--include/vcl/jobset.hxx31
-rw-r--r--vcl/headless/svpprn.cxx68
-rw-r--r--vcl/inc/jobset.h55
-rw-r--r--vcl/inc/salinst.hxx2
-rw-r--r--vcl/inc/salprn.hxx2
-rw-r--r--vcl/inc/unx/geninst.h4
-rw-r--r--vcl/osx/salinst.cxx2
-rw-r--r--vcl/osx/salprn.cxx38
-rw-r--r--vcl/source/gdi/jobset.cxx293
-rw-r--r--vcl/source/gdi/print.cxx189
-rw-r--r--vcl/source/gdi/print3.cxx4
-rw-r--r--vcl/source/window/printdlg.cxx2
-rw-r--r--vcl/unx/generic/print/genprnpsp.cxx150
-rw-r--r--vcl/unx/generic/printer/jobdata.cxx4
-rw-r--r--vcl/win/gdi/salprn.cxx194
16 files changed, 552 insertions, 488 deletions
diff --git a/include/vcl/jobdata.hxx b/include/vcl/jobdata.hxx
index 00a743f8966b..311351894a94 100644
--- a/include/vcl/jobdata.hxx
+++ b/include/vcl/jobdata.hxx
@@ -74,7 +74,7 @@ struct VCL_DLLPUBLIC JobData
// creates a new buffer using new
// it is up to the user to delete it again
bool getStreamBuffer( void*& pData, sal_uInt32& bytes );
- static bool constructFromStreamBuffer( void* pData, sal_uInt32 bytes, JobData& rJobData );
+ static bool constructFromStreamBuffer( const void* pData, sal_uInt32 bytes, JobData& rJobData );
};
} // namespace
diff --git a/include/vcl/jobset.hxx b/include/vcl/jobset.hxx
index 3c2c837919a2..7cc7a3dfc217 100644
--- a/include/vcl/jobset.hxx
+++ b/include/vcl/jobset.hxx
@@ -22,29 +22,19 @@
#include <vcl/dllapi.h>
#include <vcl/prntypes.hxx>
+#include <o3tl/cow_wrapper.hxx>
class SvStream;
-struct ImplJobSetup;
+class ImplJobSetup;
class VCL_DLLPUBLIC JobSetup
{
friend class Printer;
-private:
- ImplJobSetup* mpData;
-
-public:
- SAL_DLLPRIVATE ImplJobSetup* ImplGetData();
- SAL_DLLPRIVATE ImplJobSetup* ImplGetConstData();
- SAL_DLLPRIVATE const ImplJobSetup* ImplGetConstData() const;
-
public:
- JobSetup();
- JobSetup( const JobSetup& rJob );
- ~JobSetup();
-
- OUString GetPrinterName() const;
- OUString GetDriverName() const;
+ JobSetup();
+ JobSetup( const JobSetup& rJob );
+ ~JobSetup();
JobSetup& operator=( const JobSetup& rJob );
@@ -52,8 +42,19 @@ public:
bool operator!=( const JobSetup& rJobSetup ) const
{ return !(JobSetup::operator==( rJobSetup )); }
+ SAL_DLLPRIVATE ImplJobSetup& ImplGetData();
+ SAL_DLLPRIVATE const ImplJobSetup& ImplGetConstData() const;
+
+ OUString GetPrinterName() const;
+ bool IsDefault() const;
+
friend VCL_DLLPUBLIC SvStream& ReadJobSetup( SvStream& rIStream, JobSetup& rJobSetup );
friend VCL_DLLPUBLIC SvStream& WriteJobSetup( SvStream& rOStream, const JobSetup& rJobSetup );
+
+ typedef o3tl::cow_wrapper< ImplJobSetup > ImplType;
+
+private:
+ ImplType mpData;
};
#endif // INCLUDED_VCL_JOBSET_HXX
diff --git a/vcl/headless/svpprn.cxx b/vcl/headless/svpprn.cxx
index a966452848da..c5c8ea550d2b 100644
--- a/vcl/headless/svpprn.cxx
+++ b/vcl/headless/svpprn.cxx
@@ -60,17 +60,17 @@ inline int PtTo10Mu( int nPoints ) { return (int)((((double)nPoints)*35.27777778
static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
{
- pJobSetup->meOrientation = (Orientation)(rData.m_eOrientation == orientation::Landscape ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT);
+ pJobSetup->SetOrientation( (Orientation)(rData.m_eOrientation == orientation::Landscape ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT) );
// copy page size
OUString aPaper;
int width, height;
rData.m_aContext.getPageSize( aPaper, width, height );
- pJobSetup->mePaperFormat = PaperInfo::fromPSName(OUStringToOString( aPaper, RTL_TEXTENCODING_ISO_8859_1 ));
- pJobSetup->mnPaperWidth = 0;
- pJobSetup->mnPaperHeight = 0;
- if( pJobSetup->mePaperFormat == PAPER_USER )
+ pJobSetup->SetPaperFormat( PaperInfo::fromPSName(OUStringToOString( aPaper, RTL_TEXTENCODING_ISO_8859_1 )) );
+ pJobSetup->SetPaperWidth( 0 );
+ pJobSetup->SetPaperHeight( 0 );
+ if( pJobSetup->GetPaperFormat() == PAPER_USER )
{
// transform to 100dth mm
width = PtTo10Mu( width );
@@ -78,13 +78,13 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
if( rData.m_eOrientation == psp::orientation::Portrait )
{
- pJobSetup->mnPaperWidth = width;
- pJobSetup->mnPaperHeight= height;
+ pJobSetup->SetPaperWidth( width );
+ pJobSetup->SetPaperHeight( height );
}
else
{
- pJobSetup->mnPaperWidth = height;
- pJobSetup->mnPaperHeight= width;
+ pJobSetup->SetPaperWidth( height );
+ pJobSetup->SetPaperHeight( width );
}
}
@@ -92,27 +92,28 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
const PPDKey* pKey = nullptr;
const PPDValue* pValue = nullptr;
- pJobSetup->mnPaperBin = 0xffff;
+ pJobSetup->SetPaperBin( 0xffff );
if( rData.m_pParser )
pKey = rData.m_pParser->getKey( OUString( "InputSlot" ) );
if( pKey )
pValue = rData.m_aContext.getValue( pKey );
if( pKey && pValue )
{
- for( pJobSetup->mnPaperBin = 0;
- pValue != pKey->getValue( pJobSetup->mnPaperBin ) &&
- pJobSetup->mnPaperBin < pKey->countValues();
- pJobSetup->mnPaperBin++ )
- ;
- if( pJobSetup->mnPaperBin >= pKey->countValues() || pValue == pKey->getDefaultValue() )
- pJobSetup->mnPaperBin = 0xffff;
+ sal_uInt16 nPaperBin;
+ for( nPaperBin = 0;
+ pValue != pKey->getValue( nPaperBin ) &&
+ nPaperBin < pKey->countValues();
+ nPaperBin++ );
+ pJobSetup->SetPaperBin(nPaperBin);
+ if( nPaperBin >= pKey->countValues() || pValue == pKey->getDefaultValue() )
+ pJobSetup->SetPaperBin( 0xffff );
}
// copy duplex
pKey = nullptr;
pValue = nullptr;
- pJobSetup->meDuplexMode = DUPLEX_UNKNOWN;
+ pJobSetup->SetDuplexMode( DUPLEX_UNKNOWN );
if( rData.m_pParser )
pKey = rData.m_pParser->getKey( OUString( "Duplex" ) );
if( pKey )
@@ -123,40 +124,40 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
pValue->m_aOption.startsWithIgnoreAsciiCase( "Simplex" )
)
{
- pJobSetup->meDuplexMode = DUPLEX_OFF;
+ pJobSetup->SetDuplexMode( DUPLEX_OFF );
}
else if( pValue->m_aOption.equalsIgnoreAsciiCase( "DuplexNoTumble" ) )
{
- pJobSetup->meDuplexMode = DUPLEX_LONGEDGE;
+ pJobSetup->SetDuplexMode( DUPLEX_LONGEDGE );
}
else if( pValue->m_aOption.equalsIgnoreAsciiCase( "DuplexTumble" ) )
{
- pJobSetup->meDuplexMode = DUPLEX_SHORTEDGE;
+ pJobSetup->SetDuplexMode( DUPLEX_SHORTEDGE );
}
}
// copy the whole context
- if( pJobSetup->mpDriverData )
- rtl_freeMemory( pJobSetup->mpDriverData );
+ if( pJobSetup->GetDriverData() )
+ rtl_freeMemory( const_cast<sal_uInt8*>(pJobSetup->GetDriverData()) );
sal_uInt32 nBytes;
void* pBuffer = nullptr;
if( rData.getStreamBuffer( pBuffer, nBytes ) )
{
- pJobSetup->mnDriverDataLen = nBytes;
- pJobSetup->mpDriverData = static_cast<sal_uInt8*>(pBuffer);
+ pJobSetup->SetDriverDataLen( nBytes );
+ pJobSetup->SetDriverData( static_cast<sal_uInt8*>(pBuffer) );
}
else
{
- pJobSetup->mnDriverDataLen = 0;
- pJobSetup->mpDriverData = nullptr;
+ pJobSetup->SetDriverDataLen( 0 );
+ pJobSetup->SetDriverData( nullptr );
}
}
// SalInstance
SalInfoPrinter* SvpSalInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
- ImplJobSetup* pJobSetup )
+ ImplJobSetup* pJobSetup )
{
// create and initialize SalInfoPrinter
SvpSalInfoPrinter* pPrinter = new SvpSalInfoPrinter();
@@ -168,12 +169,13 @@ SalInfoPrinter* SvpSalInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueIn
pPrinter->m_aJobData = aInfo;
pPrinter->m_aPrinterGfx.Init( pPrinter->m_aJobData );
- if( pJobSetup->mpDriverData )
- JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aInfo );
+ if( pJobSetup->GetDriverData() )
+ JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(),
+ pJobSetup->GetDriverDataLen(), aInfo );
- pJobSetup->mnSystem = JOBSETUP_SYSTEM_UNIX;
- pJobSetup->maPrinterName = pQueueInfo->maPrinterName;
- pJobSetup->maDriver = aInfo.m_aDriverName;
+ pJobSetup->SetSystem( JOBSETUP_SYSTEM_UNIX );
+ pJobSetup->SetPrinterName( pQueueInfo->maPrinterName );
+ pJobSetup->SetDriver( aInfo.m_aDriverName );
copyJobDataToJobSetup( pJobSetup, aInfo );
}
diff --git a/vcl/inc/jobset.h b/vcl/inc/jobset.h
index 09480202dccb..db833018f905 100644
--- a/vcl/inc/jobset.h
+++ b/vcl/inc/jobset.h
@@ -29,13 +29,9 @@
#define JOBSETUP_SYSTEM_UNIX 3
#define JOBSETUP_SYSTEM_MAC 4
-struct ImplJobSetup
+class ImplJobSetup
{
- ImplJobSetup();
- ImplJobSetup( const ImplJobSetup& rJobSetup );
- ~ImplJobSetup();
-
- sal_uInt16 mnRefCount; //< RefCount (only independent data)
+private:
sal_uInt16 mnSystem; //< System - JOBSETUP_SYSTEM_xxxx
OUString maPrinterName; //< Printer-Name
OUString maDriver; //< Driver-Name
@@ -49,6 +45,53 @@ struct ImplJobSetup
sal_uInt8* mpDriverData; //< system specific data (will be streamed a byte block)
bool mbPapersizeFromSetup;
std::unordered_map< OUString, OUString, OUStringHash > maValueMap;
+
+public:
+ ImplJobSetup();
+ ImplJobSetup( const ImplJobSetup& rJobSetup );
+ ~ImplJobSetup();
+
+ bool operator==( const ImplJobSetup& rImplJobSetup ) const;
+
+ sal_uInt16 GetSystem() const { return mnSystem; }
+ void SetSystem(sal_uInt16 nSystem);
+
+ const OUString& GetPrinterName() const { return maPrinterName; }
+ void SetPrinterName(const OUString& rPrinterName);
+
+ const OUString& GetDriver() const { return maDriver; }
+ void SetDriver(const OUString& rDriver);
+
+ Orientation GetOrientation() const { return meOrientation; }
+ void SetOrientation(Orientation eOrientation);
+
+ DuplexMode GetDuplexMode() const { return meDuplexMode; }
+ void SetDuplexMode(DuplexMode eDuplexMode);
+
+ sal_uInt16 GetPaperBin() const { return mnPaperBin; }
+ void SetPaperBin(sal_uInt16 nPaperBin);
+
+ Paper GetPaperFormat() const { return mePaperFormat; }
+ void SetPaperFormat(Paper ePaperFormat);
+
+ long GetPaperWidth() const { return mnPaperWidth; }
+ void SetPaperWidth(long nWidth);
+
+ long GetPaperHeight() const { return mnPaperHeight; }
+ void SetPaperHeight(long nHeight);
+
+ sal_uInt32 GetDriverDataLen() const { return mnDriverDataLen; }
+ void SetDriverDataLen(sal_uInt32 nDriverDataLen);
+
+ const sal_uInt8* GetDriverData() const { return mpDriverData; }
+ void SetDriverData(sal_uInt8* pDriverData);
+
+ bool GetPapersizeFromSetup() const { return mbPapersizeFromSetup; }
+ void SetPapersizeFromSetup(bool bPapersizeFromSetup);
+
+ const std::unordered_map< OUString, OUString, OUStringHash >& GetValueMap() const
+ { return maValueMap; }
+ void SetValueMap(const OUString& rKey, const OUString& rValue);
};
// If paper format is PAPER_USER, in the system-independent part it will
diff --git a/vcl/inc/salinst.hxx b/vcl/inc/salinst.hxx
index 21f7be27711f..c86d1f31c1a5 100644
--- a/vcl/inc/salinst.hxx
+++ b/vcl/inc/salinst.hxx
@@ -35,7 +35,7 @@
namespace comphelper { class SolarMutex; }
struct SystemParentData;
struct SalPrinterQueueInfo;
-struct ImplJobSetup;
+class ImplJobSetup;
class OpenGLContext;
class SalGraphics;
class SalFrame;
diff --git a/vcl/inc/salprn.hxx b/vcl/inc/salprn.hxx
index beafef246ffa..54726847e94e 100644
--- a/vcl/inc/salprn.hxx
+++ b/vcl/inc/salprn.hxx
@@ -28,7 +28,7 @@
class SalGraphics;
class SalFrame;
-struct ImplJobSetup;
+class ImplJobSetup;
namespace vcl { class PrinterController; }
struct VCL_PLUGIN_PUBLIC SalPrinterQueueInfo
diff --git a/vcl/inc/unx/geninst.h b/vcl/inc/unx/geninst.h
index cda664aa2522..4b05f7332940 100644
--- a/vcl/inc/unx/geninst.h
+++ b/vcl/inc/unx/geninst.h
@@ -113,8 +113,8 @@ public:
protected:
static void configurePspInfoPrinter( PspSalInfoPrinter* pInfoPrinter,
- SalPrinterQueueInfo* pQueueInfo,
- ImplJobSetup* pSetupData );
+ SalPrinterQueueInfo* pQueueInfo,
+ ImplJobSetup* pSetupData );
};
inline SalGenericInstance *GetGenericInstance()
diff --git a/vcl/osx/salinst.cxx b/vcl/osx/salinst.cxx
index ad3980e3eedd..bff09a5d17a6 100644
--- a/vcl/osx/salinst.cxx
+++ b/vcl/osx/salinst.cxx
@@ -861,7 +861,7 @@ OUString AquaSalInstance::GetDefaultPrinter()
}
SalInfoPrinter* AquaSalInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
- ImplJobSetup* pSetupData )
+ ImplJobSetup* pSetupData )
{
// #i113170# may not be the main thread if called from UNO API
SalData::ensureThreadAutoreleasePool();
diff --git a/vcl/osx/salprn.cxx b/vcl/osx/salprn.cxx
index af51e0544120..d151f6cf6890 100644
--- a/vcl/osx/salprn.cxx
+++ b/vcl/osx/salprn.cxx
@@ -161,13 +161,13 @@ bool AquaSalInfoPrinter::Setup( SalFrame*, ImplJobSetup* )
bool AquaSalInfoPrinter::SetPrinterData( ImplJobSetup* io_pSetupData )
{
// FIXME: implement driver data
- if( io_pSetupData && io_pSetupData->mpDriverData )
+ if( io_pSetupData && io_pSetupData->GetDriverData() )
return SetData( JobSetFlags::ALL, io_pSetupData );
bool bSuccess = true;
// set system type
- io_pSetupData->mnSystem = JOBSETUP_SYSTEM_MAC;
+ io_pSetupData->SetSystem( JOBSETUP_SYSTEM_MAC );
// get paper format
if( mpPrintInfo )
@@ -177,24 +177,24 @@ bool AquaSalInfoPrinter::SetPrinterData( ImplJobSetup* io_pSetupData )
// set paper
PaperInfo aInfo( PtTo10Mu( width ), PtTo10Mu( height ) );
aInfo.doSloppyFit();
- io_pSetupData->mePaperFormat = aInfo.getPaper();
- if( io_pSetupData->mePaperFormat == PAPER_USER )
+ io_pSetupData->SetPaperFormat( aInfo.getPaper() );
+ if( io_pSetupData->GetPaperFormat() == PAPER_USER )
{
- io_pSetupData->mnPaperWidth = PtTo10Mu( width );
- io_pSetupData->mnPaperHeight = PtTo10Mu( height );
+ io_pSetupData->SetPaperWidth( PtTo10Mu( width ) );
+ io_pSetupData->SetPaperHeight( PtTo10Mu( height ) );
}
else
{
- io_pSetupData->mnPaperWidth = 0;
- io_pSetupData->mnPaperHeight = 0;
+ io_pSetupData->SetPaperWidth( 0 );
+ io_pSetupData->SetPaperHeight( 0 );
}
// set orientation
- io_pSetupData->meOrientation = mePageOrientation;
+ io_pSetupData->SetOrientation( mePageOrientation );
- io_pSetupData->mnPaperBin = 0;
- io_pSetupData->mpDriverData = static_cast<sal_uInt8*>(rtl_allocateMemory( 4 ));
- io_pSetupData->mnDriverDataLen = 4;
+ io_pSetupData->SetPaperBin( 0 );
+ io_pSetupData->SetDriverData( static_cast<sal_uInt8*>(rtl_allocateMemory( 4 )) );
+ io_pSetupData->SetDriverDataLen( 4 );
}
else
bSuccess = false;
@@ -224,30 +224,30 @@ void AquaSalInfoPrinter::setPaperSize( long i_nWidth, long i_nHeight, Orientatio
bool AquaSalInfoPrinter::SetData( JobSetFlags i_nFlags, ImplJobSetup* io_pSetupData )
{
- if( ! io_pSetupData || io_pSetupData->mnSystem != JOBSETUP_SYSTEM_MAC )
+ if( ! io_pSetupData || io_pSetupData->GetSystem() != JOBSETUP_SYSTEM_MAC )
return false;
if( mpPrintInfo )
{
if( i_nFlags & JobSetFlags::ORIENTATION )
- mePageOrientation = io_pSetupData->meOrientation;
+ mePageOrientation = io_pSetupData->GetOrientation();
if( i_nFlags & JobSetFlags::PAPERSIZE )
{
// set paper format
long width = 21000, height = 29700;
- if( io_pSetupData->mePaperFormat == PAPER_USER )
+ if( io_pSetupData->GetPaperFormat() == PAPER_USER )
{
// #i101108# sanity check
- if( io_pSetupData->mnPaperWidth && io_pSetupData->mnPaperHeight )
+ if( io_pSetupData->GetPaperWidth() && io_pSetupData->GetPaperHeight() )
{
- width = io_pSetupData->mnPaperWidth;
- height = io_pSetupData->mnPaperHeight;
+ width = io_pSetupData->GetPaperWidth();
+ height = io_pSetupData->GetPaperHeight();
}
}
else
{
- PaperInfo aInfo( io_pSetupData->mePaperFormat );
+ PaperInfo aInfo( io_pSetupData->GetPaperFormat() );
width = aInfo.getWidth();
height = aInfo.getHeight();
}
diff --git a/vcl/source/gdi/jobset.cxx b/vcl/source/gdi/jobset.cxx
index 2b795e51aa99..11137c191b69 100644
--- a/vcl/source/gdi/jobset.cxx
+++ b/vcl/source/gdi/jobset.cxx
@@ -22,9 +22,9 @@
#include <tools/debug.hxx>
#include <tools/stream.hxx>
#include <vcl/jobset.hxx>
-
#include <jobset.h>
#include <memory>
+#include <rtl/instance.hxx>
#define JOBSET_FILE364_SYSTEM ((sal_uInt16)0xFFFF)
#define JOBSET_FILE605_SYSTEM ((sal_uInt16)0xFFFE)
@@ -51,7 +51,6 @@ struct Impl364JobSetupData
ImplJobSetup::ImplJobSetup()
{
- mnRefCount = 1;
mnSystem = 0;
meOrientation = ORIENTATION_PORTRAIT;
meDuplexMode = DUPLEX_UNKNOWN;
@@ -65,27 +64,26 @@ ImplJobSetup::ImplJobSetup()
}
ImplJobSetup::ImplJobSetup( const ImplJobSetup& rJobSetup ) :
- maPrinterName( rJobSetup.maPrinterName ),
- maDriver( rJobSetup.maDriver )
-{
- mnRefCount = 1;
- mnSystem = rJobSetup.mnSystem;
- meOrientation = rJobSetup.meOrientation;
- meDuplexMode = rJobSetup.meDuplexMode;
- mnPaperBin = rJobSetup.mnPaperBin;
- mePaperFormat = rJobSetup.mePaperFormat;
- mnPaperWidth = rJobSetup.mnPaperWidth;
- mnPaperHeight = rJobSetup.mnPaperHeight;
- mnDriverDataLen = rJobSetup.mnDriverDataLen;
- if ( rJobSetup.mpDriverData )
+ mnSystem( rJobSetup.GetSystem() ),
+ maPrinterName( rJobSetup.GetPrinterName() ),
+ maDriver( rJobSetup.GetDriver() ),
+ meOrientation( rJobSetup.GetOrientation() ),
+ meDuplexMode( rJobSetup.GetDuplexMode() ),
+ mnPaperBin( rJobSetup.GetPaperBin() ),
+ mePaperFormat( rJobSetup.GetPaperFormat() ),
+ mnPaperWidth( rJobSetup.GetPaperWidth() ),
+ mnPaperHeight( rJobSetup.GetPaperHeight() ),
+ mnDriverDataLen( rJobSetup.GetDriverDataLen() ),
+ mbPapersizeFromSetup( rJobSetup.GetPapersizeFromSetup() ),
+ maValueMap( rJobSetup.GetValueMap() )
+ {
+ if ( rJobSetup.GetDriverData() )
{
mpDriverData = static_cast<sal_uInt8*>(rtl_allocateMemory( mnDriverDataLen ));
- memcpy( mpDriverData, rJobSetup.mpDriverData, mnDriverDataLen );
+ memcpy( mpDriverData, rJobSetup.GetDriverData(), mnDriverDataLen );
}
else
mpDriverData = nullptr;
- mbPapersizeFromSetup = rJobSetup.mbPapersizeFromSetup;
- maValueMap = rJobSetup.maValueMap;
}
ImplJobSetup::~ImplJobSetup()
@@ -93,131 +91,140 @@ ImplJobSetup::~ImplJobSetup()
rtl_freeMemory( mpDriverData );
}
-ImplJobSetup* JobSetup::ImplGetData()
+void ImplJobSetup::SetSystem(sal_uInt16 nSystem)
{
- if ( !mpData )
- mpData = new ImplJobSetup;
- else if ( mpData->mnRefCount != 1 )
- {
- mpData->mnRefCount--;
- mpData = new ImplJobSetup( *mpData );
- }
+ mnSystem = nSystem;
+}
- return mpData;
+void ImplJobSetup::SetPrinterName(const OUString& rPrinterName)
+{
+ maPrinterName = rPrinterName;
}
-ImplJobSetup* JobSetup::ImplGetConstData()
+void ImplJobSetup::SetDriver(const OUString& rDriver)
{
- if ( !mpData )
- mpData = new ImplJobSetup;
- return mpData;
+ maDriver = rDriver;
}
-const ImplJobSetup* JobSetup::ImplGetConstData() const
+void ImplJobSetup::SetOrientation(Orientation eOrientation)
{
- if ( !mpData )
- const_cast<JobSetup*>(this)->mpData = new ImplJobSetup;
- return mpData;
+ meOrientation = eOrientation;
}
-JobSetup::JobSetup()
+void ImplJobSetup::SetDuplexMode(DuplexMode eDuplexMode)
{
+ meDuplexMode = eDuplexMode;
+}
- mpData = nullptr;
+void ImplJobSetup::SetPaperBin(sal_uInt16 nPaperBin)
+{
+ mnPaperBin = nPaperBin;
}
-JobSetup::JobSetup( const JobSetup& rJobSetup )
+void ImplJobSetup::SetPaperFormat(Paper ePaperFormat)
{
- SAL_WARN_IF( rJobSetup.mpData && (rJobSetup.mpData->mnRefCount >= 0xFFFE), "vcl", "JobSetup: RefCount overflow" );
+ mePaperFormat = ePaperFormat;
+}
- mpData = rJobSetup.mpData;
- if ( mpData )
- mpData->mnRefCount++;
+void ImplJobSetup::SetPaperWidth(long nPaperWidth)
+{
+ mnPaperWidth = nPaperWidth;
}
-JobSetup::~JobSetup()
+void ImplJobSetup::SetPaperHeight(long nPaperHeight)
{
+ mnPaperHeight = nPaperHeight;
+}
- if ( mpData )
- {
- if ( mpData->mnRefCount == 1 )
- delete mpData;
- else
- mpData->mnRefCount--;
- }
+void ImplJobSetup::SetDriverDataLen(sal_uInt32 nDriverDataLen)
+{
+ mnDriverDataLen = nDriverDataLen;
}
-OUString JobSetup::GetPrinterName() const
+void ImplJobSetup::SetDriverData(sal_uInt8* pDriverData)
{
- if ( mpData )
- return mpData->maPrinterName;
- else
- return OUString();
+ mpDriverData = pDriverData;
}
-OUString JobSetup::GetDriverName() const
+void ImplJobSetup::SetPapersizeFromSetup(bool bPapersizeFromSetup)
{
- if ( mpData )
- return mpData->maDriver;
- else
- return OUString();
+ mbPapersizeFromSetup = bPapersizeFromSetup;
+}
+
+void ImplJobSetup::SetValueMap( const OUString& rKey, const OUString& rValue )
+{
+ maValueMap [ rKey ] = rValue;
}
JobSetup& JobSetup::operator=( const JobSetup& rJobSetup )
{
- SAL_WARN_IF( rJobSetup.mpData && (rJobSetup.mpData->mnRefCount) >= 0xFFFE, "vcl", "JobSetup: RefCount overflow" );
+ mpData = rJobSetup.mpData;
+ return *this;
+}
- // Increment refcount first, so that we can assign to ourselves
- if ( rJobSetup.mpData )
- rJobSetup.mpData->mnRefCount++;
+bool ImplJobSetup::operator==( const ImplJobSetup& rImplJobSetup ) const
+{
+ if ( mnSystem == rImplJobSetup.mnSystem &&
+ maPrinterName == rImplJobSetup.maPrinterName &&
+ maDriver == rImplJobSetup.maDriver &&
+ meOrientation == rImplJobSetup.meOrientation &&
+ meDuplexMode == rImplJobSetup.meDuplexMode &&
+ mnPaperBin == rImplJobSetup.mnPaperBin &&
+ mePaperFormat == rImplJobSetup.mePaperFormat &&
+ mnPaperWidth == rImplJobSetup.mnPaperWidth &&
+ mnPaperHeight == rImplJobSetup.mnPaperHeight &&
+ mnDriverDataLen == rImplJobSetup.mnDriverDataLen &&
+ maValueMap == rImplJobSetup.maValueMap &&
+ memcmp( mpDriverData, rImplJobSetup.mpDriverData, mnDriverDataLen ) == 0)
+ return true;
+ return false;
+}
- // If it's not static ImpData and the last reference, delete it, else
- // decrement refcount
- if ( mpData )
- {
- if ( mpData->mnRefCount == 1 )
- delete mpData;
- else
- mpData->mnRefCount--;
- }
+namespace
+{
+ struct theGlobalDefault :
+ public rtl::Static< JobSetup::ImplType, theGlobalDefault > {};
+}
- mpData = rJobSetup.mpData;
+JobSetup::JobSetup() : mpData(theGlobalDefault::get())
+{
+}
- return *this;
+JobSetup::JobSetup( const JobSetup& rJobSetup ) : mpData(rJobSetup.mpData)
+{
+}
+
+JobSetup::~JobSetup()
+{
}
bool JobSetup::operator==( const JobSetup& rJobSetup ) const
{
+ return mpData == rJobSetup.mpData;
+}
- if ( mpData == rJobSetup.mpData )
- return true;
+const ImplJobSetup& JobSetup::ImplGetConstData() const
+{
+ return *mpData;
+}
- if ( !mpData || !rJobSetup.mpData )
- return false;
-
- ImplJobSetup* pData1 = mpData;
- ImplJobSetup* pData2 = rJobSetup.mpData;
- if ( (pData1->mnSystem == pData2->mnSystem) &&
- (pData1->maPrinterName == pData2->maPrinterName) &&
- (pData1->maDriver == pData2->maDriver) &&
- (pData1->meOrientation == pData2->meOrientation) &&
- (pData1->meDuplexMode == pData2->meDuplexMode) &&
- (pData1->mnPaperBin == pData2->mnPaperBin) &&
- (pData1->mePaperFormat == pData2->mePaperFormat) &&
- (pData1->mnPaperWidth == pData2->mnPaperWidth) &&
- (pData1->mnPaperHeight == pData2->mnPaperHeight) &&
- (pData1->mnDriverDataLen == pData2->mnDriverDataLen) &&
- (memcmp( pData1->mpDriverData, pData2->mpDriverData, pData1->mnDriverDataLen ) == 0) &&
- (pData1->maValueMap == pData2->maValueMap)
- )
- return true;
+ImplJobSetup& JobSetup::ImplGetData()
+{
+ return *mpData;
+}
- return false;
+OUString JobSetup::GetPrinterName() const
+{
+ return mpData->GetPrinterName();
}
-SvStream& ReadJobSetup( SvStream& rIStream, JobSetup& rJobSetup )
+bool JobSetup::IsDefault() const
{
+ return mpData.same_object(theGlobalDefault::get());
+}
+SvStream& ReadJobSetup( SvStream& rIStream, JobSetup& rJobSetup )
+{
{
sal_uInt16 nLen = 0;
rIStream.ReadUInt16( nLen );
@@ -239,22 +246,15 @@ SvStream& ReadJobSetup( SvStream& rIStream, JobSetup& rJobSetup )
if (nRead >= sizeof(ImplOldJobSetupData))
{
ImplOldJobSetupData* pData = reinterpret_cast<ImplOldJobSetupData*>(pTempBuf.get());
- if ( rJobSetup.mpData )
- {
- if ( rJobSetup.mpData->mnRefCount == 1 )
- delete rJobSetup.mpData;
- else
- rJobSetup.mpData->mnRefCount--;
- }
rtl_TextEncoding aStreamEncoding = RTL_TEXTENCODING_UTF8;
if( nSystem == JOBSET_FILE364_SYSTEM )
aStreamEncoding = rIStream.GetStreamCharSet();
- rJobSetup.mpData = new ImplJobSetup;
- ImplJobSetup* pJobData = rJobSetup.mpData;
- pJobData->maPrinterName = OStringToOUString(pData->cPrinterName, aStreamEncoding);
- pJobData->maDriver = OStringToOUString(pData->cDriverName, aStreamEncoding);
+ ImplJobSetup& rJobData = rJobSetup.ImplGetData();
+
+ rJobData.SetPrinterName( OStringToOUString(pData->cPrinterName, aStreamEncoding) );
+ rJobData.SetDriver( OStringToOUString(pData->cDriverName, aStreamEncoding) );
// Are these our new JobSetup files?
if ( nSystem == JOBSET_FILE364_SYSTEM ||
@@ -262,23 +262,26 @@ SvStream& ReadJobSetup( SvStream& rIStream, JobSetup& rJobSetup )
{
Impl364JobSetupData* pOldJobData = reinterpret_cast<Impl364JobSetupData*>(pTempBuf.get() + sizeof( ImplOldJobSetupData ));
sal_uInt16 nOldJobDataSize = SVBT16ToShort( pOldJobData->nSize );
- pJobData->mnSystem = SVBT16ToShort( pOldJobData->nSystem );
- pJobData->mnDriverDataLen = SVBT32ToUInt32( pOldJobData->nDriverDataLen );
- pJobData->meOrientation = (Orientation)SVBT16ToShort( pOldJobData->nOrientation );
- pJobData->meDuplexMode = DUPLEX_UNKNOWN;
- pJobData->mnPaperBin = SVBT16ToShort( pOldJobData->nPaperBin );
- pJobData->mePaperFormat = (Paper)SVBT16ToShort( pOldJobData->nPaperFormat );
- pJobData->mnPaperWidth = (long)SVBT32ToUInt32( pOldJobData->nPaperWidth );
- pJobData->mnPaperHeight = (long)SVBT32ToUInt32( pOldJobData->nPaperHeight );
- if ( pJobData->mnDriverDataLen )
+ rJobData.SetSystem( SVBT16ToShort( pOldJobData->nSystem ) );
+ rJobData.SetDriverDataLen( SVBT32ToUInt32( pOldJobData->nDriverDataLen ) );
+ rJobData.SetOrientation( (Orientation)SVBT16ToShort( pOldJobData->nOrientation ) );
+ rJobData.SetDuplexMode( DUPLEX_UNKNOWN );
+ rJobData.SetPaperBin( SVBT16ToShort( pOldJobData->nPaperBin ) );
+ rJobData.SetPaperFormat( (Paper)SVBT16ToShort( pOldJobData->nPaperFormat ) );
+ rJobData.SetPaperWidth( (long)SVBT32ToUInt32( pOldJobData->nPaperWidth ) );
+ rJobData.SetPaperHeight( (long)SVBT32ToUInt32( pOldJobData->nPaperHeight ) );
+ if ( rJobData.GetDriverDataLen() )
{
- sal_uInt8* pDriverData = reinterpret_cast<sal_uInt8*>(pOldJobData) + nOldJobDataSize;
- pJobData->mpDriverData = static_cast<sal_uInt8*>(rtl_allocateMemory( pJobData->mnDriverDataLen ));
- memcpy( pJobData->mpDriverData, pDriverData, pJobData->mnDriverDataLen );
+ const sal_uInt8* pDriverData = reinterpret_cast<sal_uInt8*>(pOldJobData) + nOldJobDataSize;
+ sal_uInt8* pNewDriverData = static_cast<sal_uInt8*>(
+ rtl_allocateMemory( rJobData.GetDriverDataLen() ));
+ memcpy( pNewDriverData, pDriverData, rJobData.GetDriverDataLen() );
+ rJobData.SetDriverData( pNewDriverData );
}
if( nSystem == JOBSET_FILE605_SYSTEM )
{
- rIStream.Seek( nFirstPos + sizeof( ImplOldJobSetupData ) + sizeof( Impl364JobSetupData ) + pJobData->mnDriverDataLen );
+ rIStream.Seek( nFirstPos + sizeof( ImplOldJobSetupData ) +
+ sizeof( Impl364JobSetupData ) + rJobData.GetDriverDataLen() );
while( rIStream.Tell() < nFirstPos + nRead )
{
OUString aKey = read_uInt16_lenPrefixed_uInt8s_ToOUString(rIStream, RTL_TEXTENCODING_UTF8);
@@ -286,16 +289,16 @@ SvStream& ReadJobSetup( SvStream& rIStream, JobSetup& rJobSetup )
if( aKey == "COMPAT_DUPLEX_MODE" )
{
if( aValue == "DUPLEX_UNKNOWN" )
- pJobData->meDuplexMode = DUPLEX_UNKNOWN;
+ rJobData.SetDuplexMode( DUPLEX_UNKNOWN );
else if( aValue == "DUPLEX_OFF" )
- pJobData->meDuplexMode = DUPLEX_OFF;
+ rJobData.SetDuplexMode( DUPLEX_OFF );
else if( aValue == "DUPLEX_SHORTEDGE" )
- pJobData->meDuplexMode = DUPLEX_SHORTEDGE;
+ rJobData.SetDuplexMode( DUPLEX_SHORTEDGE );
else if( aValue == "DUPLEX_LONGEDGE" )
- pJobData->meDuplexMode = DUPLEX_LONGEDGE;
+ rJobData.SetDuplexMode( DUPLEX_LONGEDGE );
}
else
- pJobData->maValueMap[ aKey ] = aValue;
+ rJobData.SetValueMap(aKey, aValue);
}
SAL_WARN_IF( rIStream.Tell() != nFirstPos+nRead, "vcl", "corrupted job setup" );
// ensure correct stream position
@@ -310,48 +313,50 @@ SvStream& ReadJobSetup( SvStream& rIStream, JobSetup& rJobSetup )
SvStream& WriteJobSetup( SvStream& rOStream, const JobSetup& rJobSetup )
{
-
{
sal_uInt16 nLen = 0;
- if ( !rJobSetup.mpData )
+ if ( rJobSetup.IsDefault() )
rOStream.WriteUInt16( nLen );
else
{
sal_uInt16 nSystem = JOBSET_FILE605_SYSTEM;
- const ImplJobSetup* pJobData = rJobSetup.ImplGetConstData();
+ const ImplJobSetup& rJobData = rJobSetup.ImplGetConstData();
Impl364JobSetupData aOldJobData;
sal_uInt16 nOldJobDataSize = sizeof( aOldJobData );
ShortToSVBT16( nOldJobDataSize, aOldJobData.nSize );
- ShortToSVBT16( pJobData->mnSystem, aOldJobData.nSystem );
- UInt32ToSVBT32( pJobData->mnDriverDataLen, aOldJobData.nDriverDataLen );
- ShortToSVBT16( (sal_uInt16)(pJobData->meOrientation), aOldJobData.nOrientation );
- ShortToSVBT16( pJobData->mnPaperBin, aOldJobData.nPaperBin );
- ShortToSVBT16( (sal_uInt16)(pJobData->mePaperFormat), aOldJobData.nPaperFormat );
- UInt32ToSVBT32( (sal_uLong)(pJobData->mnPaperWidth), aOldJobData.nPaperWidth );
- UInt32ToSVBT32( (sal_uLong)(pJobData->mnPaperHeight), aOldJobData.nPaperHeight );
+ ShortToSVBT16( rJobData.GetSystem(), aOldJobData.nSystem );
+ UInt32ToSVBT32( rJobData.GetDriverDataLen(), aOldJobData.nDriverDataLen );
+ ShortToSVBT16( (sal_uInt16)(rJobData.GetOrientation()), aOldJobData.nOrientation );
+ ShortToSVBT16( rJobData.GetPaperBin(), aOldJobData.nPaperBin );
+ ShortToSVBT16( (sal_uInt16)(rJobData.GetPaperFormat()), aOldJobData.nPaperFormat );
+ UInt32ToSVBT32( (sal_uLong)(rJobData.GetPaperWidth()), aOldJobData.nPaperWidth );
+ UInt32ToSVBT32( (sal_uLong)(rJobData.GetPaperHeight()), aOldJobData.nPaperHeight );
ImplOldJobSetupData aOldData;
memset( &aOldData, 0, sizeof( aOldData ) );
- OString aPrnByteName(OUStringToOString(rJobSetup.GetPrinterName(), RTL_TEXTENCODING_UTF8));
+ OString aPrnByteName(OUStringToOString(rJobData.GetPrinterName(), RTL_TEXTENCODING_UTF8));
strncpy( aOldData.cPrinterName, aPrnByteName.getStr(), 63 );
- OString aDriverByteName(OUStringToOString(rJobSetup.GetDriverName(), RTL_TEXTENCODING_UTF8));
+ OString aDriverByteName(OUStringToOString(rJobData.GetDriver(), RTL_TEXTENCODING_UTF8));
strncpy( aOldData.cDriverName, aDriverByteName.getStr(), 31 );
-// nLen = sizeof( aOldData ) + 4 + nOldJobDataSize + pJobData->mnDriverDataLen;
int nPos = rOStream.Tell();
- rOStream.WriteUInt16( nLen );
+ rOStream.WriteUInt16( 0 );
rOStream.WriteUInt16( nSystem );
rOStream.WriteBytes( &aOldData, sizeof( aOldData ) );
rOStream.WriteBytes( &aOldJobData, nOldJobDataSize );
- rOStream.WriteBytes( pJobData->mpDriverData, pJobData->mnDriverDataLen );
+ rOStream.WriteBytes( rJobData.GetDriverData(), rJobData.GetDriverDataLen() );
+
std::unordered_map< OUString, OUString, OUStringHash >::const_iterator it;
- for( it = pJobData->maValueMap.begin(); it != pJobData->maValueMap.end(); ++it )
+ const std::unordered_map< OUString, OUString, OUStringHash >& rValueMap(
+ rJobData.GetValueMap());
+
+ for( it = rValueMap.begin(); it != rValueMap.end(); ++it )
{
write_uInt16_lenPrefixed_uInt8s_FromOUString(rOStream, it->first, RTL_TEXTENCODING_UTF8);
write_uInt16_lenPrefixed_uInt8s_FromOUString(rOStream, it->second, RTL_TEXTENCODING_UTF8);
}
write_uInt16_lenPrefixed_uInt8s_FromOString(rOStream, "COMPAT_DUPLEX_MODE");
- switch( pJobData->meDuplexMode )
+ switch( rJobData.GetDuplexMode() )
{
case DUPLEX_UNKNOWN:
write_uInt16_lenPrefixed_uInt8s_FromOString(rOStream, "DUPLEX_UNKNOWN");
diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx
index 23c93681df66..43bc44b3e244 100644
--- a/vcl/source/gdi/print.cxx
+++ b/vcl/source/gdi/print.cxx
@@ -65,23 +65,24 @@ namespace
void ImplUpdateJobSetupPaper( JobSetup& rJobSetup )
{
- const ImplJobSetup* pConstData = rJobSetup.ImplGetConstData();
+ const ImplJobSetup& rConstData = rJobSetup.ImplGetConstData();
- if ( !pConstData->mnPaperWidth || !pConstData->mnPaperHeight )
+ if ( !rConstData.GetPaperWidth() || !rConstData.GetPaperHeight() )
{
- if ( pConstData->mePaperFormat != PAPER_USER )
+ if ( rConstData.GetPaperFormat() != PAPER_USER )
{
- ImplJobSetup* pData = rJobSetup.ImplGetData();
- PaperInfo aInfo(pConstData->mePaperFormat);
- pData->mnPaperWidth = aInfo.getWidth();
- pData->mnPaperHeight = aInfo.getHeight();
+ PaperInfo aInfo(rConstData.GetPaperFormat());
+
+ ImplJobSetup& rData = rJobSetup.ImplGetData();
+ rData.SetPaperWidth( aInfo.getWidth() );
+ rData.SetPaperHeight( aInfo.getHeight() );
}
}
- else if ( pConstData->mePaperFormat == PAPER_USER )
+ else if ( rConstData.GetPaperFormat() == PAPER_USER )
{
- Paper ePaper = ImplGetPaperFormat( pConstData->mnPaperWidth, pConstData->mnPaperHeight );
+ Paper ePaper = ImplGetPaperFormat( rConstData.GetPaperWidth(), rConstData.GetPaperHeight() );
if ( ePaper != PAPER_USER )
- rJobSetup.ImplGetData()->mePaperFormat = ePaper;
+ rJobSetup.ImplGetData().SetPaperFormat(ePaper);
}
}
@@ -683,16 +684,15 @@ void Printer::ImplInit( SalPrinterQueueInfo* pInfo )
pSVData->mpDefInst->GetPrinterQueueState( pInfo );
// Test whether the driver actually matches the JobSetup
- ImplJobSetup* pJobSetup = maJobSetup.ImplGetData();
-
- if ( pJobSetup->mpDriverData )
+ ImplJobSetup& rData = maJobSetup.ImplGetData();
+ if ( rData.GetDriverData() )
{
- if ( (pJobSetup->maPrinterName != pInfo->maPrinterName) ||
- (pJobSetup->maDriver != pInfo->maDriver) )
+ if ( rData.GetPrinterName() != pInfo->maPrinterName ||
+ rData.GetDriver() != pInfo->maDriver )
{
- rtl_freeMemory( pJobSetup->mpDriverData );
- pJobSetup->mpDriverData = nullptr;
- pJobSetup->mnDriverDataLen = 0;
+ rtl_freeMemory( const_cast<sal_uInt8*>(rData.GetDriverData()) );
+ rData.SetDriverData(nullptr);
+ rData.SetDriverDataLen(0);
}
}
@@ -701,10 +701,10 @@ void Printer::ImplInit( SalPrinterQueueInfo* pInfo )
maDriver = pInfo->maDriver;
// Add printer name to JobSetup
- pJobSetup->maPrinterName = maPrinterName;
- pJobSetup->maDriver = maDriver;
+ rData.SetPrinterName( maPrinterName );
+ rData.SetDriver( maDriver );
- mpInfoPrinter = pSVData->mpDefInst->CreateInfoPrinter( pInfo, pJobSetup );
+ mpInfoPrinter = pSVData->mpDefInst->CreateInfoPrinter( pInfo, &rData );
mpPrinter = nullptr;
mpJobGraphics = nullptr;
ImplUpdateJobSetupPaper( maJobSetup );
@@ -884,7 +884,7 @@ void Printer::ImplUpdatePageData()
return;
mpGraphics->GetResolution( mnDPIX, mnDPIY );
- mpInfoPrinter->GetPageInfo( maJobSetup.ImplGetConstData(),
+ mpInfoPrinter->GetPageInfo( &maJobSetup.ImplGetConstData(),
mnOutWidth, mnOutHeight,
maPageOffset.X(), maPageOffset.Y(),
maPaperSize.Width(), maPaperSize.Height() );
@@ -921,8 +921,10 @@ Printer::Printer( const JobSetup& rJobSetup ) :
maJobSetup( rJobSetup )
{
ImplInitData();
- SalPrinterQueueInfo* pInfo = ImplGetQueueInfo( rJobSetup.mpData->maPrinterName,
- &rJobSetup.mpData->maDriver );
+ const ImplJobSetup& rConstData = rJobSetup.ImplGetConstData();
+ OUString aDriver = rConstData.GetDriver();
+ SalPrinterQueueInfo* pInfo = ImplGetQueueInfo( rConstData.GetPrinterName(),
+ &aDriver );
if ( pInfo )
{
ImplInit( pInfo );
@@ -1021,7 +1023,7 @@ sal_uInt32 Printer::GetCapabilities( PrinterCapType nType ) const
return 0;
if( mpInfoPrinter )
- return mpInfoPrinter->GetCapabilities( maJobSetup.ImplGetConstData(), nType );
+ return mpInfoPrinter->GetCapabilities( &maJobSetup.ImplGetConstData(), nType );
else
return 0;
}
@@ -1061,7 +1063,7 @@ bool Printer::SetJobSetup( const JobSetup& rSetup )
JobSetup aJobSetup = rSetup;
ReleaseGraphics();
- if ( mpInfoPrinter->SetPrinterData( aJobSetup.ImplGetData() ) )
+ if ( mpInfoPrinter->SetPrinterData( &aJobSetup.ImplGetData() ) )
{
ImplUpdateJobSetupPaper( aJobSetup );
mbNewJobSetup = true;
@@ -1083,8 +1085,8 @@ bool Printer::Setup( vcl::Window* pWindow, bool bPapersizeFromSetup )
return false;
JobSetup aJobSetup = maJobSetup;
- ImplJobSetup* pData = aJobSetup.ImplGetData();
- pData->mbPapersizeFromSetup = bPapersizeFromSetup;
+ ImplJobSetup& rData = aJobSetup.ImplGetData();
+ rData.SetPapersizeFromSetup( bPapersizeFromSetup );
SalFrame* pFrame;
if ( !pWindow )
pWindow = ImplGetDefaultWindow();
@@ -1096,7 +1098,7 @@ bool Printer::Setup( vcl::Window* pWindow, bool bPapersizeFromSetup )
ImplSVData* pSVData = ImplGetSVData();
pSVData->maAppData.mnModalMode++;
nImplSysDialog++;
- bool bSetup = mpInfoPrinter->Setup( pFrame, pData );
+ bool bSetup = mpInfoPrinter->Setup( pFrame, &rData );
pSVData->maAppData.mnModalMode--;
nImplSysDialog--;
if ( bSetup )
@@ -1222,11 +1224,12 @@ bool Printer::SetOrientation( Orientation eOrientation )
if ( mbInPrintPage )
return false;
- if ( maJobSetup.ImplGetConstData()->meOrientation != eOrientation )
+ if ( maJobSetup.ImplGetConstData().GetOrientation() != eOrientation )
{
- JobSetup aJobSetup = maJobSetup;
- ImplJobSetup* pSetupData = aJobSetup.ImplGetData();
- pSetupData->meOrientation = eOrientation;
+ JobSetup aJobSetup = maJobSetup;
+ ImplJobSetup& rData = aJobSetup.ImplGetData();
+
+ rData.SetOrientation(eOrientation);
if ( IsDisplayPrinter() )
{
@@ -1236,7 +1239,7 @@ bool Printer::SetOrientation( Orientation eOrientation )
}
ReleaseGraphics();
- if ( mpInfoPrinter->SetData( JobSetFlags::ORIENTATION, pSetupData ) )
+ if ( mpInfoPrinter->SetData( JobSetFlags::ORIENTATION, &rData ) )
{
ImplUpdateJobSetupPaper( aJobSetup );
mbNewJobSetup = true;
@@ -1254,7 +1257,7 @@ bool Printer::SetOrientation( Orientation eOrientation )
Orientation Printer::GetOrientation() const
{
- return maJobSetup.ImplGetConstData()->meOrientation;
+ return maJobSetup.ImplGetConstData().GetOrientation();
}
bool Printer::SetPaperBin( sal_uInt16 nPaperBin )
@@ -1262,12 +1265,12 @@ bool Printer::SetPaperBin( sal_uInt16 nPaperBin )
if ( mbInPrintPage )
return false;
- if ( (maJobSetup.ImplGetConstData()->mnPaperBin != nPaperBin) &&
- (nPaperBin < GetPaperBinCount()) )
+ if ( maJobSetup.ImplGetConstData().GetPaperBin() != nPaperBin &&
+ nPaperBin < GetPaperBinCount() )
{
- JobSetup aJobSetup = maJobSetup;
- ImplJobSetup* pSetupData = aJobSetup.ImplGetData();
- pSetupData->mnPaperBin = nPaperBin;
+ JobSetup aJobSetup = maJobSetup;
+ ImplJobSetup& rData = aJobSetup.ImplGetData();
+ rData.SetPaperBin(nPaperBin);
if ( IsDisplayPrinter() )
{
@@ -1277,7 +1280,7 @@ bool Printer::SetPaperBin( sal_uInt16 nPaperBin )
}
ReleaseGraphics();
- if ( mpInfoPrinter->SetData( JobSetFlags::PAPERBIN, pSetupData ) )
+ if ( mpInfoPrinter->SetData( JobSetFlags::PAPERBIN, &rData ) )
{
ImplUpdateJobSetupPaper( aJobSetup );
mbNewJobSetup = true;
@@ -1295,19 +1298,19 @@ bool Printer::SetPaperBin( sal_uInt16 nPaperBin )
sal_uInt16 Printer::GetPaperBin() const
{
- return maJobSetup.ImplGetConstData()->mnPaperBin;
+ return maJobSetup.ImplGetConstData().GetPaperBin();
}
// Map user paper format to a available printer paper formats
void Printer::ImplFindPaperFormatForUserSize( JobSetup& aJobSetup, bool bMatchNearest )
{
- ImplJobSetup* pSetupData = aJobSetup.ImplGetData();
+ ImplJobSetup& rData = aJobSetup.ImplGetData();
int nLandscapeAngle = GetLandscapeAngle();
int nPaperCount = GetPaperInfoCount();
bool bFound = false;
- PaperInfo aInfo(pSetupData->mnPaperWidth, pSetupData->mnPaperHeight);
+ PaperInfo aInfo(rData.GetPaperWidth(), rData.GetPaperHeight());
// Compare all paper formats and get the appropriate one
for ( int i = 0; i < nPaperCount; i++ )
@@ -1316,9 +1319,10 @@ void Printer::ImplFindPaperFormatForUserSize( JobSetup& aJobSetup, bool bMatchNe
if ( aInfo.sloppyEqual(rPaperInfo) )
{
- pSetupData->mePaperFormat = ImplGetPaperFormat( rPaperInfo.getWidth(),
- rPaperInfo.getHeight() );
- pSetupData->meOrientation = ORIENTATION_PORTRAIT;
+ rData.SetPaperFormat(
+ ImplGetPaperFormat( rPaperInfo.getWidth(),
+ rPaperInfo.getHeight() ));
+ rData.SetOrientation( ORIENTATION_PORTRAIT );
bFound = true;
break;
}
@@ -1327,12 +1331,12 @@ void Printer::ImplFindPaperFormatForUserSize( JobSetup& aJobSetup, bool bMatchNe
// If the printer supports landscape orientation, check paper sizes again
// with landscape orientation. This is necessary as a printer driver provides
// all paper sizes with portrait orientation only!!
- if ( pSetupData->mePaperFormat == PAPER_USER &&
+ if ( rData.GetPaperFormat() == PAPER_USER &&
nLandscapeAngle != 0 &&
HasSupport( PrinterSupport::SetOrientation ))
{
- const long nRotatedWidth = pSetupData->mnPaperHeight;
- const long nRotatedHeight = pSetupData->mnPaperWidth;
+ const long nRotatedWidth = rData.GetPaperHeight();
+ const long nRotatedHeight = rData.GetPaperWidth();
PaperInfo aRotatedInfo(nRotatedWidth, nRotatedHeight);
for ( int i = 0; i < nPaperCount; i++ )
@@ -1341,9 +1345,10 @@ void Printer::ImplFindPaperFormatForUserSize( JobSetup& aJobSetup, bool bMatchNe
if ( aRotatedInfo.sloppyEqual( rPaperInfo ) )
{
- pSetupData->mePaperFormat = ImplGetPaperFormat( rPaperInfo.getWidth(),
- rPaperInfo.getHeight() );
- pSetupData->meOrientation = ORIENTATION_LANDSCAPE;
+ rData.SetPaperFormat(
+ ImplGetPaperFormat( rPaperInfo.getWidth(),
+ rPaperInfo.getHeight() ));
+ rData.SetOrientation( ORIENTATION_LANDSCAPE );
bFound = true;
break;
}
@@ -1360,8 +1365,8 @@ void Printer::ImplFindPaperFormatForUserSize( JobSetup& aJobSetup, bool bMatchNe
const PaperInfo& rPaperInfo = GetPaperInfo( i );
// check portrait match
- sal_Int64 nDX = pSetupData->mnPaperWidth - rPaperInfo.getWidth();
- sal_Int64 nDY = pSetupData->mnPaperHeight - rPaperInfo.getHeight();
+ sal_Int64 nDX = rData.GetPaperWidth() - rPaperInfo.getWidth();
+ sal_Int64 nDY = rData.GetPaperHeight() - rPaperInfo.getHeight();
sal_Int64 nMatch = nDX*nDX + nDY*nDY;
if( nMatch < nBestMatch )
{
@@ -1371,8 +1376,8 @@ void Printer::ImplFindPaperFormatForUserSize( JobSetup& aJobSetup, bool bMatchNe
}
// check landscape match
- nDX = pSetupData->mnPaperWidth - rPaperInfo.getHeight();
- nDY = pSetupData->mnPaperHeight - rPaperInfo.getWidth();
+ nDX = rData.GetPaperWidth() - rPaperInfo.getHeight();
+ nDY = rData.GetPaperHeight() - rPaperInfo.getWidth();
nMatch = nDX*nDX + nDY*nDY;
if( nMatch < nBestMatch )
{
@@ -1382,9 +1387,10 @@ void Printer::ImplFindPaperFormatForUserSize( JobSetup& aJobSetup, bool bMatchNe
}
}
const PaperInfo& rBestInfo = GetPaperInfo( nBestIndex );
- pSetupData->mePaperFormat = ImplGetPaperFormat( rBestInfo.getWidth(),
- rBestInfo.getHeight() );
- pSetupData->meOrientation = eBestOrientation;
+ rData.SetPaperFormat(
+ ImplGetPaperFormat( rBestInfo.getWidth(),
+ rBestInfo.getHeight() ));
+ rData.SetOrientation(eBestOrientation);
}
}
@@ -1393,16 +1399,17 @@ bool Printer::SetPaper( Paper ePaper )
if ( mbInPrintPage )
return false;
- if ( maJobSetup.ImplGetConstData()->mePaperFormat != ePaper )
+ if ( maJobSetup.ImplGetConstData().GetPaperFormat() != ePaper )
{
- JobSetup aJobSetup = maJobSetup;
- ImplJobSetup* pSetupData = aJobSetup.ImplGetData();
- pSetupData->mePaperFormat = ePaper;
+ JobSetup aJobSetup = maJobSetup;
+ ImplJobSetup& rData = aJobSetup.ImplGetData();
+
+ rData.SetPaperFormat( ePaper );
if ( ePaper != PAPER_USER )
{
PaperInfo aInfo(ePaper);
- pSetupData->mnPaperWidth = aInfo.getWidth();
- pSetupData->mnPaperHeight = aInfo.getHeight();
+ rData.SetPaperWidth( aInfo.getWidth() );
+ rData.SetPaperHeight( aInfo.getHeight() );
}
if ( IsDisplayPrinter() )
@@ -1415,7 +1422,7 @@ bool Printer::SetPaper( Paper ePaper )
ReleaseGraphics();
if ( ePaper == PAPER_USER )
ImplFindPaperFormatForUserSize( aJobSetup, false );
- if ( mpInfoPrinter->SetData( JobSetFlags::PAPERSIZE | JobSetFlags::ORIENTATION, pSetupData ) )
+ if ( mpInfoPrinter->SetData( JobSetFlags::PAPERSIZE | JobSetFlags::ORIENTATION, &rData ))
{
ImplUpdateJobSetupPaper( aJobSetup );
mbNewJobSetup = true;
@@ -1443,29 +1450,29 @@ bool Printer::SetPaperSizeUser( const Size& rSize, bool bMatchNearest )
const Size aPixSize = LogicToPixel( rSize );
const Size aPageSize = PixelToLogic( aPixSize, MAP_100TH_MM );
- bool bNeedToChange(maJobSetup.ImplGetConstData()->mnPaperWidth != aPageSize.Width() ||
- maJobSetup.ImplGetConstData()->mnPaperHeight != aPageSize.Height());
+ bool bNeedToChange(maJobSetup.ImplGetConstData().GetPaperWidth() != aPageSize.Width() ||
+ maJobSetup.ImplGetConstData().GetPaperHeight() != aPageSize.Height());
if(!bNeedToChange)
{
// #i122984# only need to change when Paper is different from PAPER_USER and
// the mapped Paper which will created below in the call to ImplFindPaperFormatForUserSize
- // and will replace maJobSetup.ImplGetConstData()->mePaperFormat. This leads to
+ // and will replace maJobSetup.ImplGetConstData()->GetPaperFormat(). This leads to
// unnecessary JobSetups, e.g. when printing a multi-page fax, but also with
// normal print
const Paper aPaper = ImplGetPaperFormat(aPageSize.Width(), aPageSize.Height());
- bNeedToChange = maJobSetup.ImplGetConstData()->mePaperFormat != PAPER_USER &&
- maJobSetup.ImplGetConstData()->mePaperFormat != aPaper;
+ bNeedToChange = maJobSetup.ImplGetConstData().GetPaperFormat() != PAPER_USER &&
+ maJobSetup.ImplGetConstData().GetPaperFormat() != aPaper;
}
if(bNeedToChange)
{
- JobSetup aJobSetup = maJobSetup;
- ImplJobSetup* pSetupData = aJobSetup.ImplGetData();
- pSetupData->mePaperFormat = PAPER_USER;
- pSetupData->mnPaperWidth = aPageSize.Width();
- pSetupData->mnPaperHeight = aPageSize.Height();
+ JobSetup aJobSetup = maJobSetup;
+ ImplJobSetup& rData = aJobSetup.ImplGetData();
+ rData.SetPaperFormat( PAPER_USER );
+ rData.SetPaperWidth( aPageSize.Width() );
+ rData.SetPaperHeight( aPageSize.Height() );
if ( IsDisplayPrinter() )
{
@@ -1478,7 +1485,7 @@ bool Printer::SetPaperSizeUser( const Size& rSize, bool bMatchNearest )
ImplFindPaperFormatForUserSize( aJobSetup, bMatchNearest );
// Changing the paper size can also change the orientation!
- if ( mpInfoPrinter->SetData( JobSetFlags::PAPERSIZE | JobSetFlags::ORIENTATION, pSetupData ) )
+ if ( mpInfoPrinter->SetData( JobSetFlags::PAPERSIZE | JobSetFlags::ORIENTATION, &rData ))
{
ImplUpdateJobSetupPaper( aJobSetup );
mbNewJobSetup = true;
@@ -1499,7 +1506,7 @@ int Printer::GetPaperInfoCount() const
if( ! mpInfoPrinter )
return 0;
if( ! mpInfoPrinter->m_bPapersInit )
- mpInfoPrinter->InitPaperFormats( maJobSetup.ImplGetConstData() );
+ mpInfoPrinter->InitPaperFormats( &maJobSetup.ImplGetConstData() );
return mpInfoPrinter->m_aPaperFormats.size();
}
@@ -1547,7 +1554,7 @@ const PaperInfo& Printer::GetPaperInfo( int nPaper ) const
if( ! mpInfoPrinter )
return ImplGetEmptyPaper();
if( ! mpInfoPrinter->m_bPapersInit )
- mpInfoPrinter->InitPaperFormats( maJobSetup.ImplGetConstData() );
+ mpInfoPrinter->InitPaperFormats( &maJobSetup.ImplGetConstData() );
if( mpInfoPrinter->m_aPaperFormats.empty() || nPaper < 0 || nPaper >= int(mpInfoPrinter->m_aPaperFormats.size()) )
return ImplGetEmptyPaper();
return mpInfoPrinter->m_aPaperFormats[nPaper];
@@ -1558,11 +1565,12 @@ bool Printer::SetDuplexMode( DuplexMode eDuplex )
if ( mbInPrintPage )
return false;
- if ( maJobSetup.ImplGetConstData()->meDuplexMode != eDuplex )
+ if ( maJobSetup.ImplGetConstData().GetDuplexMode() != eDuplex )
{
- JobSetup aJobSetup = maJobSetup;
- ImplJobSetup* pSetupData = aJobSetup.ImplGetData();
- pSetupData->meDuplexMode = eDuplex;
+ JobSetup aJobSetup = maJobSetup;
+ ImplJobSetup& rData = aJobSetup.ImplGetData();
+
+ rData.SetDuplexMode( eDuplex );
if ( IsDisplayPrinter() )
{
@@ -1572,7 +1580,7 @@ bool Printer::SetDuplexMode( DuplexMode eDuplex )
}
ReleaseGraphics();
- if ( mpInfoPrinter->SetData( JobSetFlags::DUPLEXMODE, pSetupData ) )
+ if ( mpInfoPrinter->SetData( JobSetFlags::DUPLEXMODE, &rData ) )
{
ImplUpdateJobSetupPaper( aJobSetup );
mbNewJobSetup = true;
@@ -1590,12 +1598,12 @@ bool Printer::SetDuplexMode( DuplexMode eDuplex )
int Printer::GetLandscapeAngle() const
{
- return mpInfoPrinter ? mpInfoPrinter->GetLandscapeAngle( maJobSetup.ImplGetConstData() ) : 900;
+ return mpInfoPrinter ? mpInfoPrinter->GetLandscapeAngle( &maJobSetup.ImplGetConstData() ) : 900;
}
Paper Printer::GetPaper() const
{
- return maJobSetup.ImplGetConstData()->mePaperFormat;
+ return maJobSetup.ImplGetConstData().GetPaperFormat();
}
sal_uInt16 Printer::GetPaperBinCount() const
@@ -1603,7 +1611,7 @@ sal_uInt16 Printer::GetPaperBinCount() const
if ( IsDisplayPrinter() )
return 0;
- return (sal_uInt16)mpInfoPrinter->GetPaperBinCount( maJobSetup.ImplGetConstData() );
+ return (sal_uInt16)mpInfoPrinter->GetPaperBinCount( &maJobSetup.ImplGetConstData() );
}
OUString Printer::GetPaperBinName( sal_uInt16 nPaperBin ) const
@@ -1612,7 +1620,7 @@ OUString Printer::GetPaperBinName( sal_uInt16 nPaperBin ) const
return OUString();
if ( nPaperBin < GetPaperBinCount() )
- return mpInfoPrinter->GetPaperBinName( maJobSetup.ImplGetConstData(), nPaperBin );
+ return mpInfoPrinter->GetPaperBinName( &maJobSetup.ImplGetConstData(), nPaperBin );
else
return OUString();
}
@@ -1682,7 +1690,8 @@ void Printer::ImplStartPage()
if ( mpPrinter )
{
- SalGraphics* pGraphics = mpPrinter->StartPage( maJobSetup.ImplGetConstData(), mbNewJobSetup );
+ SalGraphics* pGraphics = mpPrinter->StartPage( &maJobSetup.ImplGetData(),
+ mbNewJobSetup );
if ( pGraphics )
{
ReleaseGraphics();
diff --git a/vcl/source/gdi/print3.cxx b/vcl/source/gdi/print3.cxx
index 3bc2fccad964..f1f24aca4eaa 100644
--- a/vcl/source/gdi/print3.cxx
+++ b/vcl/source/gdi/print3.cxx
@@ -603,7 +603,7 @@ bool Printer::StartJob( const OUString& i_rJobName, std::shared_ptr<vcl::Printer
if( mpPrinter->StartJob( pPrintFile,
i_rJobName,
Application::GetDisplayName(),
- maJobSetup.ImplGetConstData(),
+ &maJobSetup.ImplGetData(),
*i_xController) )
{
EndJob();
@@ -660,7 +660,7 @@ bool Printer::StartJob( const OUString& i_rJobName, std::shared_ptr<vcl::Printer
nCopies,
bCollateCopy,
i_xController->isDirectPrint(),
- maJobSetup.ImplGetConstData() ) )
+ &maJobSetup.ImplGetData() ) )
{
bool bAborted = false;
mbJobActive = true;
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index 9699a1705734..e61d164a5e43 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -20,7 +20,6 @@
#include "printdlg.hxx"
#include "svdata.hxx"
#include "svids.hrc"
-#include "jobset.h"
#include <vcl/print.hxx>
#include <vcl/dialog.hxx>
@@ -35,6 +34,7 @@
#include <vcl/unohelp.hxx>
#include <vcl/settings.hxx>
#include <vcl/builderfactory.hxx>
+#include "jobset.h"
#include "unotools/localedatawrapper.hxx"
diff --git a/vcl/unx/generic/print/genprnpsp.cxx b/vcl/unx/generic/print/genprnpsp.cxx
index 63495e9adec6..e9b9d87e6884 100644
--- a/vcl/unx/generic/print/genprnpsp.cxx
+++ b/vcl/unx/generic/print/genprnpsp.cxx
@@ -155,18 +155,20 @@ inline int TenMuToPt( int nUnits ) { return (int)((((double)nUnits)/35.27777778)
static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
{
- pJobSetup->meOrientation = (Orientation)(rData.m_eOrientation == orientation::Landscape ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT);
+ pJobSetup->SetOrientation( (Orientation)(rData.m_eOrientation == orientation::Landscape ?
+ ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT));
// copy page size
OUString aPaper;
int width, height;
rData.m_aContext.getPageSize( aPaper, width, height );
- pJobSetup->mePaperFormat = PaperInfo::fromPSName(OUStringToOString( aPaper, RTL_TEXTENCODING_ISO_8859_1 ));
+ pJobSetup->SetPaperFormat( PaperInfo::fromPSName(
+ OUStringToOString( aPaper, RTL_TEXTENCODING_ISO_8859_1 )));
- pJobSetup->mnPaperWidth = 0;
- pJobSetup->mnPaperHeight = 0;
- if( pJobSetup->mePaperFormat == PAPER_USER )
+ pJobSetup->SetPaperWidth( 0 );
+ pJobSetup->SetPaperHeight( 0 );
+ if( pJobSetup->GetPaperFormat() == PAPER_USER )
{
// transform to 100dth mm
width = PtTo10Mu( width );
@@ -174,13 +176,13 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
if( rData.m_eOrientation == psp::orientation::Portrait )
{
- pJobSetup->mnPaperWidth = width;
- pJobSetup->mnPaperHeight= height;
+ pJobSetup->SetPaperWidth( width );
+ pJobSetup->SetPaperHeight( height );
}
else
{
- pJobSetup->mnPaperWidth = height;
- pJobSetup->mnPaperHeight= width;
+ pJobSetup->SetPaperWidth( height );
+ pJobSetup->SetPaperHeight( width );
}
}
@@ -188,27 +190,28 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
const PPDKey* pKey = nullptr;
const PPDValue* pValue = nullptr;
- pJobSetup->mnPaperBin = 0;
+ pJobSetup->SetPaperBin( 0 );
if( rData.m_pParser )
pKey = rData.m_pParser->getKey( OUString("InputSlot") );
if( pKey )
pValue = rData.m_aContext.getValue( pKey );
if( pKey && pValue )
{
- for( pJobSetup->mnPaperBin = 0;
- pValue != pKey->getValue( pJobSetup->mnPaperBin ) &&
- pJobSetup->mnPaperBin < pKey->countValues();
- pJobSetup->mnPaperBin++ )
- ;
- if( pJobSetup->mnPaperBin >= pKey->countValues() )
- pJobSetup->mnPaperBin = 0;
+ sal_uInt16 nPaperBin;
+ for( nPaperBin = 0;
+ pValue != pKey->getValue( nPaperBin ) &&
+ nPaperBin < pKey->countValues();
+ nPaperBin++);
+ pJobSetup->SetPaperBin(nPaperBin);
+ if( pJobSetup->GetPaperBin() >= pKey->countValues() )
+ pJobSetup->SetPaperBin( 0 );
}
// copy duplex
pKey = nullptr;
pValue = nullptr;
- pJobSetup->meDuplexMode = DUPLEX_UNKNOWN;
+ pJobSetup->SetDuplexMode( DUPLEX_UNKNOWN );
if( rData.m_pParser )
pKey = rData.m_pParser->getKey( OUString("Duplex") );
if( pKey )
@@ -219,33 +222,33 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
pValue->m_aOption.startsWithIgnoreAsciiCase( "Simplex" )
)
{
- pJobSetup->meDuplexMode = DUPLEX_OFF;
+ pJobSetup->SetDuplexMode( DUPLEX_OFF);
}
else if( pValue->m_aOption.equalsIgnoreAsciiCase( "DuplexNoTumble" ) )
{
- pJobSetup->meDuplexMode = DUPLEX_LONGEDGE;
+ pJobSetup->SetDuplexMode( DUPLEX_LONGEDGE );
}
else if( pValue->m_aOption.equalsIgnoreAsciiCase( "DuplexTumble" ) )
{
- pJobSetup->meDuplexMode = DUPLEX_SHORTEDGE;
+ pJobSetup->SetDuplexMode( DUPLEX_SHORTEDGE );
}
}
// copy the whole context
- if( pJobSetup->mpDriverData )
- rtl_freeMemory( pJobSetup->mpDriverData );
+ if( pJobSetup->GetDriverData() )
+ rtl_freeMemory( const_cast<sal_uInt8*>(pJobSetup->GetDriverData()) );
sal_uInt32 nBytes;
void* pBuffer = nullptr;
if( rData.getStreamBuffer( pBuffer, nBytes ) )
{
- pJobSetup->mnDriverDataLen = nBytes;
- pJobSetup->mpDriverData = static_cast<sal_uInt8*>(pBuffer);
+ pJobSetup->SetDriverDataLen( nBytes );
+ pJobSetup->SetDriverData( static_cast<sal_uInt8*>(pBuffer) );
}
else
{
- pJobSetup->mnDriverDataLen = 0;
- pJobSetup->mpDriverData = nullptr;
+ pJobSetup->SetDriverDataLen( 0 );
+ pJobSetup->SetDriverData( nullptr );
}
}
@@ -382,18 +385,19 @@ void SalGenericInstance::configurePspInfoPrinter(PspSalInfoPrinter *pPrinter,
pPrinter->m_aJobData = aInfo;
pPrinter->m_aPrinterGfx.Init( pPrinter->m_aJobData );
- if( pJobSetup->mpDriverData )
- JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aInfo );
+ if( pJobSetup->GetDriverData() )
+ JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(),
+ pJobSetup->GetDriverDataLen(), aInfo );
- pJobSetup->mnSystem = JOBSETUP_SYSTEM_UNIX;
- pJobSetup->maPrinterName = pQueueInfo->maPrinterName;
- pJobSetup->maDriver = aInfo.m_aDriverName;
+ pJobSetup->SetSystem( JOBSETUP_SYSTEM_UNIX );
+ pJobSetup->SetPrinterName( pQueueInfo->maPrinterName );
+ pJobSetup->SetDriver( aInfo.m_aDriverName );
copyJobDataToJobSetup( pJobSetup, aInfo );
}
}
SalInfoPrinter* SalGenericInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo,
- ImplJobSetup* pJobSetup )
+ ImplJobSetup* pJobSetup )
{
mbPrinterInit = true;
// create and initialize SalInfoPrinter
@@ -553,42 +557,42 @@ bool PspSalInfoPrinter::Setup( SalFrame* pFrame, ImplJobSetup* pJobSetup )
PrinterInfoManager& rManager = PrinterInfoManager::get();
- PrinterInfo aInfo( rManager.getPrinterInfo( pJobSetup->maPrinterName ) );
- if ( pJobSetup->mpDriverData )
+ PrinterInfo aInfo( rManager.getPrinterInfo( pJobSetup->GetPrinterName() ) );
+ if ( pJobSetup->GetDriverData() )
{
SetData( JobSetFlags::ALL, pJobSetup );
- JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aInfo );
+ JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aInfo );
}
- aInfo.m_bPapersizeFromSetup = pJobSetup->mbPapersizeFromSetup;
+ aInfo.m_bPapersizeFromSetup = pJobSetup->GetPapersizeFromSetup();
if (SetupPrinterDriver(aInfo))
{
aInfo.resolveDefaultBackend();
- rtl_freeMemory( pJobSetup->mpDriverData );
- pJobSetup->mpDriverData = nullptr;
+ rtl_freeMemory( const_cast<sal_uInt8*>(pJobSetup->GetDriverData()) );
+ pJobSetup->SetDriverData( nullptr );
sal_uInt32 nBytes;
void* pBuffer = nullptr;
aInfo.getStreamBuffer( pBuffer, nBytes );
- pJobSetup->mnDriverDataLen = nBytes;
- pJobSetup->mpDriverData = static_cast<sal_uInt8*>(pBuffer);
+ pJobSetup->SetDriverDataLen( nBytes );
+ pJobSetup->SetDriverData( static_cast<sal_uInt8*>(pBuffer) );
// copy everything to job setup
copyJobDataToJobSetup( pJobSetup, aInfo );
- JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, m_aJobData );
+ JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), m_aJobData );
return true;
}
return false;
}
// This function gets the driver data and puts it into pJobSetup
-// If pJobSetup->mpDriverData is NOT NULL, then the independent
+// If pJobSetup->GetDriverData() is NOT NULL, then the independent
// data should be merged into the driver data
-// If pJobSetup->mpDriverData IS NULL, then the driver defaults
+// If pJobSetup->GetDriverData() IS NULL, then the driver defaults
// should be merged into the independent data
bool PspSalInfoPrinter::SetPrinterData( ImplJobSetup* pJobSetup )
{
- if( pJobSetup->mpDriverData )
+ if( pJobSetup->GetDriverData() )
return SetData( JobSetFlags::ALL, pJobSetup );
copyJobDataToJobSetup( pJobSetup, m_aJobData );
@@ -605,7 +609,7 @@ bool PspSalInfoPrinter::SetData(
ImplJobSetup* pJobSetup )
{
JobData aData;
- JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData );
+ JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData );
if( aData.m_pParser )
{
@@ -617,21 +621,21 @@ bool PspSalInfoPrinter::SetData(
{
OUString aPaper;
- if( pJobSetup->mePaperFormat == PAPER_USER )
+ if( pJobSetup->GetPaperFormat() == PAPER_USER )
aPaper = aData.m_pParser->matchPaper(
- TenMuToPt( pJobSetup->mnPaperWidth ),
- TenMuToPt( pJobSetup->mnPaperHeight ) );
+ TenMuToPt( pJobSetup->GetPaperWidth() ),
+ TenMuToPt( pJobSetup->GetPaperHeight() ) );
else
- aPaper = OStringToOUString(PaperInfo::toPSName(pJobSetup->mePaperFormat), RTL_TEXTENCODING_ISO_8859_1);
+ aPaper = OStringToOUString(PaperInfo::toPSName(pJobSetup->GetPaperFormat()), RTL_TEXTENCODING_ISO_8859_1);
pKey = aData.m_pParser->getKey( OUString("PageSize") );
pValue = pKey ? pKey->getValueCaseInsensitive( aPaper ) : nullptr;
// some PPD files do not specify the standard paper names (e.g. C5 instead of EnvC5)
// try to find the correct paper anyway using the size
- if( pKey && ! pValue && pJobSetup->mePaperFormat != PAPER_USER )
+ if( pKey && ! pValue && pJobSetup->GetPaperFormat() != PAPER_USER )
{
- PaperInfo aInfo( pJobSetup->mePaperFormat );
+ PaperInfo aInfo( pJobSetup->GetPaperFormat() );
aPaper = aData.m_pParser->matchPaper(
TenMuToPt( aInfo.getWidth() ),
TenMuToPt( aInfo.getHeight() ) );
@@ -648,11 +652,11 @@ bool PspSalInfoPrinter::SetData(
pKey = aData.m_pParser->getKey( OUString("InputSlot") );
if( pKey )
{
- int nPaperBin = pJobSetup->mnPaperBin;
+ int nPaperBin = pJobSetup->GetPaperBin();
if( nPaperBin >= pKey->countValues() )
pValue = pKey->getDefaultValue();
else
- pValue = pKey->getValue( pJobSetup->mnPaperBin );
+ pValue = pKey->getValue( pJobSetup->GetPaperBin() );
// may fail due to constraints;
// real paper bin is copied back to jobsetup in that case
@@ -664,7 +668,7 @@ bool PspSalInfoPrinter::SetData(
// merge orientation if necessary
if( nSetDataFlags & JobSetFlags::ORIENTATION )
- aData.m_eOrientation = pJobSetup->meOrientation == ORIENTATION_LANDSCAPE ? orientation::Landscape : orientation::Portrait;
+ aData.m_eOrientation = pJobSetup->GetOrientation() == ORIENTATION_LANDSCAPE ? orientation::Landscape : orientation::Portrait;
// merge duplex if necessary
if( nSetDataFlags & JobSetFlags::DUPLEXMODE )
@@ -673,7 +677,7 @@ bool PspSalInfoPrinter::SetData(
if( pKey )
{
pValue = nullptr;
- switch( pJobSetup->meDuplexMode )
+ switch( pJobSetup->GetDuplexMode() )
{
case DUPLEX_OFF:
pValue = pKey->getValue( OUString("None") );
@@ -715,7 +719,7 @@ void PspSalInfoPrinter::GetPageInfo(
return;
JobData aData;
- JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData );
+ JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData );
// get the selected page size
if( aData.m_pParser )
@@ -752,7 +756,7 @@ sal_uLong PspSalInfoPrinter::GetPaperBinCount( const ImplJobSetup* pJobSetup )
return 0;
JobData aData;
- JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData );
+ JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData );
const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey( OUString("InputSlot") ): nullptr;
return pKey ? pKey->countValues() : 0;
@@ -761,7 +765,7 @@ sal_uLong PspSalInfoPrinter::GetPaperBinCount( const ImplJobSetup* pJobSetup )
OUString PspSalInfoPrinter::GetPaperBinName( const ImplJobSetup* pJobSetup, sal_uLong nPaperBin )
{
JobData aData;
- JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData );
+ JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData );
OUString aRet;
if( aData.m_pParser )
@@ -808,9 +812,9 @@ sal_uInt32 PspSalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, Pr
{
// see if the PPD contains the fax4CUPS "Dial" option and that it's not set
// to "manually"
- JobData aData = PrinterInfoManager::get().getPrinterInfo(pJobSetup->maPrinterName);
- if( pJobSetup->mpDriverData )
- JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData );
+ JobData aData = PrinterInfoManager::get().getPrinterInfo(pJobSetup->GetPrinterName());
+ if( pJobSetup->GetDriverData() )
+ JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData );
const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey(OUString("Dial")) : nullptr;
const PPDValue* pValue = pKey ? aData.m_aContext.getValue(pKey) : nullptr;
if (pValue && !pValue->m_aOption.equalsIgnoreAsciiCase("Manually"))
@@ -819,24 +823,24 @@ sal_uInt32 PspSalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, Pr
}
case PrinterCapType::PDF:
- if( PrinterInfoManager::get().checkFeatureToken( pJobSetup->maPrinterName, "pdf" ) )
+ if( PrinterInfoManager::get().checkFeatureToken( pJobSetup->GetPrinterName(), "pdf" ) )
return 1;
else
{
// see if the PPD contains a value to set PDF device
- JobData aData = PrinterInfoManager::get().getPrinterInfo( pJobSetup->maPrinterName );
- if( pJobSetup->mpDriverData )
- JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData );
+ JobData aData = PrinterInfoManager::get().getPrinterInfo( pJobSetup->GetPrinterName() );
+ if( pJobSetup->GetDriverData() )
+ JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData );
return aData.m_nPDFDevice > 0 ? 1 : 0;
}
case PrinterCapType::ExternalDialog:
- return PrinterInfoManager::get().checkFeatureToken( pJobSetup->maPrinterName, "external_dialog" ) ? 1 : 0;
+ return PrinterInfoManager::get().checkFeatureToken( pJobSetup->GetPrinterName(), "external_dialog" ) ? 1 : 0;
case PrinterCapType::UsePullModel:
{
// see if the PPD contains a value to set PDF device
- JobData aData = PrinterInfoManager::get().getPrinterInfo( pJobSetup->maPrinterName );
- if( pJobSetup->mpDriverData )
- JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData );
+ JobData aData = PrinterInfoManager::get().getPrinterInfo( pJobSetup->GetPrinterName() );
+ if( pJobSetup->GetDriverData() )
+ JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), aData );
return aData.m_nPDFDevice > 0 ? 1 : 0;
}
default: break;
@@ -890,7 +894,7 @@ bool PspSalPrinter::StartJob(
m_nCopies = nCopies;
m_bCollate = bCollate;
- JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, m_aJobData );
+ JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), m_aJobData );
if( m_nCopies > 1 )
{
// in case user did not do anything (m_nCopies=1)
@@ -954,7 +958,7 @@ SalGraphics* PspSalPrinter::StartPage( ImplJobSetup* pJobSetup, bool )
{
OSL_TRACE("PspSalPrinter::StartPage");
- JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, m_aJobData );
+ JobData::constructFromStreamBuffer( pJobSetup->GetDriverData(), pJobSetup->GetDriverDataLen(), m_aJobData );
m_pGraphics = GetGenericInstance()->CreatePrintGraphics();
m_pGraphics->Init(&m_aJobData, &m_aPrinterGfx, m_pInfoPrinter);
@@ -1033,7 +1037,7 @@ bool PspSalPrinter::StartJob( const OUString* i_pFileName, const OUString& i_rJo
// update job data
if( i_pSetupData )
- JobData::constructFromStreamBuffer( i_pSetupData->mpDriverData, i_pSetupData->mnDriverDataLen, m_aJobData );
+ JobData::constructFromStreamBuffer( i_pSetupData->GetDriverData(), i_pSetupData->GetDriverDataLen(), m_aJobData );
OSL_ASSERT( m_aJobData.m_nPDFDevice > 0 );
m_aJobData.m_nPDFDevice = 1;
diff --git a/vcl/unx/generic/printer/jobdata.cxx b/vcl/unx/generic/printer/jobdata.cxx
index 730487dbc294..b9359429fd8a 100644
--- a/vcl/unx/generic/printer/jobdata.cxx
+++ b/vcl/unx/generic/printer/jobdata.cxx
@@ -186,9 +186,9 @@ bool JobData::getStreamBuffer( void*& pData, sal_uInt32& bytes )
return true;
}
-bool JobData::constructFromStreamBuffer( void* pData, sal_uInt32 bytes, JobData& rJobData )
+bool JobData::constructFromStreamBuffer( const void* pData, sal_uInt32 bytes, JobData& rJobData )
{
- SvMemoryStream aStream( pData, bytes, StreamMode::READ );
+ SvMemoryStream aStream( const_cast<void*>(pData), bytes, StreamMode::READ );
OString aLine;
bool bVersion = false;
bool bPrinter = false;
diff --git a/vcl/win/gdi/salprn.cxx b/vcl/win/gdi/salprn.cxx
index 465cfe3b1a20..140ecf3a8cd5 100644
--- a/vcl/win/gdi/salprn.cxx
+++ b/vcl/win/gdi/salprn.cxx
@@ -94,9 +94,9 @@ static char aImplDevice[] = "device";
static LPDEVMODEW SAL_DEVMODE_W( const ImplJobSetup* pSetupData )
{
LPDEVMODEW pRet = NULL;
- SalDriverData* pDrv = (SalDriverData*)pSetupData->mpDriverData;
- if( pSetupData->mnDriverDataLen >= sizeof(DEVMODEW)+sizeof(SalDriverData)-1 )
- pRet = ((LPDEVMODEW)((pSetupData->mpDriverData) + (pDrv->mnDriverOffset)));
+ SalDriverData* pDrv = (SalDriverData*)pSetupData->GetDriverData();
+ if( pSetupData->GetDriverDataLen() >= sizeof(DEVMODEW)+sizeof(SalDriverData)-1 )
+ pRet = ((LPDEVMODEW)((pSetupData->GetDriverData()) + (pDrv->mnDriverOffset)));
return pRet;
}
@@ -262,7 +262,7 @@ static DWORD ImplDeviceCaps( WinSalInfoPrinter* pPrinter, WORD nCaps,
BYTE* pOutput, const ImplJobSetup* pSetupData )
{
DEVMODEW* pDevMode;
- if ( !pSetupData || !pSetupData->mpDriverData )
+ if ( !pSetupData || !pSetupData->GetDriverData() )
pDevMode = NULL;
else
pDevMode = SAL_DEVMODE_W( pSetupData );
@@ -275,7 +275,7 @@ static DWORD ImplDeviceCaps( WinSalInfoPrinter* pPrinter, WORD nCaps,
static bool ImplTestSalJobSetup( WinSalInfoPrinter* pPrinter,
ImplJobSetup* pSetupData, bool bDelete )
{
- if ( pSetupData && pSetupData->mpDriverData )
+ if ( pSetupData && pSetupData->GetDriverData() )
{
// signature and size must fit to avoid using
// JobSetups from a wrong system
@@ -285,7 +285,7 @@ static bool ImplTestSalJobSetup( WinSalInfoPrinter* pPrinter,
DEVMODEW* pDevModeW = NULL;
LONG dmSpecVersion = -1;
LONG dmDriverVersion = -1;
- SalDriverData* pSalDriverData = (SalDriverData*)pSetupData->mpDriverData;
+ SalDriverData* pSalDriverData = (SalDriverData*)pSetupData->GetDriverData();
BYTE* pDriverData = ((BYTE*)pSalDriverData) + pSalDriverData->mnDriverOffset;
pDevModeW = (DEVMODEW*)pDriverData;
@@ -332,11 +332,11 @@ static bool ImplTestSalJobSetup( WinSalInfoPrinter* pPrinter,
ClosePrinter( hPrn );
}
- SalDriverData* pSetupDriverData = (SalDriverData*)(pSetupData->mpDriverData);
- if ( (pSetupData->mnSystem == JOBSETUP_SYSTEM_WINDOWS) &&
- (pPrinter->maDriverName == pSetupData->maDriver) &&
- (pSetupData->mnDriverDataLen > sizeof( SalDriverData )) &&
- (long)(pSetupData->mnDriverDataLen - pSetupDriverData->mnDriverOffset) == nSysJobSize &&
+ SalDriverData* pSetupDriverData = (SalDriverData*)(pSetupData->GetDriverData());
+ if ( (pSetupData->GetSystem() == JOBSETUP_SYSTEM_WINDOWS) &&
+ (pPrinter->maDriverName == pSetupData->GetDriver()) &&
+ (pSetupData->GetDriverDataLen() > sizeof( SalDriverData )) &&
+ (long)(pSetupData->GetDriverDataLen() - pSetupDriverData->mnDriverOffset) == nSysJobSize &&
pSetupDriverData->mnSysSignature == SAL_DRIVERDATA_SYSSIGN )
{
if( pDevModeW &&
@@ -346,9 +346,9 @@ static bool ImplTestSalJobSetup( WinSalInfoPrinter* pPrinter,
}
if ( bDelete )
{
- rtl_freeMemory( pSetupData->mpDriverData );
- pSetupData->mpDriverData = NULL;
- pSetupData->mnDriverDataLen = 0;
+ rtl_freeMemory( const_cast<sal_uInt8*>(pSetupData->GetDriverData()) );
+ pSetupData->SetDriverData( NULL );
+ pSetupData->SetDriverDataLen( 0 );
}
}
@@ -393,7 +393,7 @@ static bool ImplUpdateSalJobSetup( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS
// check if we have a suitable input buffer
if ( bIn && ImplTestSalJobSetup( pPrinter, pSetupData, FALSE ) )
{
- pInBuffer = (BYTE*)pSetupData->mpDriverData + ((SalDriverData*)pSetupData->mpDriverData)->mnDriverOffset;
+ pInBuffer = (BYTE*)pSetupData->GetDriverData() + ((SalDriverData*)pSetupData->GetDriverData())->mnDriverOffset;
nMode |= DM_IN_BUFFER;
}
@@ -438,11 +438,11 @@ static bool ImplUpdateSalJobSetup( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS
}
// update data
- if ( pSetupData->mpDriverData )
- rtl_freeMemory( pSetupData->mpDriverData );
- pSetupData->mnDriverDataLen = nDriverDataLen;
- pSetupData->mpDriverData = (BYTE*)pOutBuffer;
- pSetupData->mnSystem = JOBSETUP_SYSTEM_WINDOWS;
+ if ( pSetupData->GetDriverData() )
+ rtl_freeMemory( const_cast<sal_uInt8*>(pSetupData->GetDriverData()) );
+ pSetupData->SetDriverDataLen( nDriverDataLen );
+ pSetupData->SetDriverData((BYTE*)pOutBuffer );
+ pSetupData->SetSystem( JOBSETUP_SYSTEM_WINDOWS );
return TRUE;
}
@@ -457,7 +457,7 @@ static bool ImplUpdateSalJobSetup( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS
static void ImplDevModeToJobSetup( WinSalInfoPrinter* pPrinter, ImplJobSetup* pSetupData, JobSetFlags nFlags )
{
- if ( !pSetupData || !pSetupData->mpDriverData )
+ if ( !pSetupData || !pSetupData->GetDriverData() )
return;
DECLARE_DEVMODE( pSetupData );
@@ -466,9 +466,9 @@ static void ImplDevModeToJobSetup( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS
if ( nFlags & JobSetFlags::ORIENTATION )
{
if ( CHOOSE_DEVMODE(dmOrientation) == DMORIENT_PORTRAIT )
- pSetupData->meOrientation = ORIENTATION_PORTRAIT;
+ pSetupData->SetOrientation( ORIENTATION_PORTRAIT );
else if ( CHOOSE_DEVMODE(dmOrientation) == DMORIENT_LANDSCAPE )
- pSetupData->meOrientation = ORIENTATION_LANDSCAPE;
+ pSetupData->SetOrientation( ORIENTATION_LANDSCAPE );
}
// PaperBin
@@ -480,14 +480,14 @@ static void ImplDevModeToJobSetup( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS
{
WORD* pBins = (WORD*)rtl_allocateZeroMemory( nCount*sizeof(WORD) );
ImplDeviceCaps( pPrinter, DC_BINS, (BYTE*)pBins, pSetupData );
- pSetupData->mnPaperBin = 0;
+ pSetupData->SetPaperBin( 0 );
// search the right bin and assign index to mnPaperBin
for( DWORD i = 0; i < nCount; ++i )
{
if( CHOOSE_DEVMODE(dmDefaultSource) == pBins[ i ] )
{
- pSetupData->mnPaperBin = (sal_uInt16)i;
+ pSetupData->SetPaperBin( (sal_uInt16)i );
break;
}
}
@@ -501,8 +501,8 @@ static void ImplDevModeToJobSetup( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS
{
if( (CHOOSE_DEVMODE(dmFields) & (DM_PAPERWIDTH|DM_PAPERLENGTH)) == (DM_PAPERWIDTH|DM_PAPERLENGTH) )
{
- pSetupData->mnPaperWidth = CHOOSE_DEVMODE(dmPaperWidth)*10;
- pSetupData->mnPaperHeight = CHOOSE_DEVMODE(dmPaperLength)*10;
+ pSetupData->SetPaperWidth( CHOOSE_DEVMODE(dmPaperWidth)*10 );
+ pSetupData->SetPaperHeight( CHOOSE_DEVMODE(dmPaperLength)*10 );
}
else
{
@@ -526,8 +526,8 @@ static void ImplDevModeToJobSetup( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS
{
if( pPapers[ i ] == CHOOSE_DEVMODE(dmPaperSize) )
{
- pSetupData->mnPaperWidth = pPaperSizes[ i ].x*10;
- pSetupData->mnPaperHeight = pPaperSizes[ i ].y*10;
+ pSetupData->SetPaperWidth( pPaperSizes[ i ].x*10 );
+ pSetupData->SetPaperHeight( pPaperSizes[ i ].y*10 );
break;
}
}
@@ -540,31 +540,31 @@ static void ImplDevModeToJobSetup( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS
switch( CHOOSE_DEVMODE(dmPaperSize) )
{
case DMPAPER_LETTER:
- pSetupData->mePaperFormat = PAPER_LETTER;
+ pSetupData->SetPaperFormat( PAPER_LETTER );
break;
case DMPAPER_TABLOID:
- pSetupData->mePaperFormat = PAPER_TABLOID;
+ pSetupData->SetPaperFormat( PAPER_TABLOID );
break;
case DMPAPER_LEDGER:
- pSetupData->mePaperFormat = PAPER_LEDGER;
+ pSetupData->SetPaperFormat( PAPER_LEDGER );
break;
case DMPAPER_LEGAL:
- pSetupData->mePaperFormat = PAPER_LEGAL;
+ pSetupData->SetPaperFormat( PAPER_LEGAL );
break;
case DMPAPER_STATEMENT:
- pSetupData->mePaperFormat = PAPER_STATEMENT;
+ pSetupData->SetPaperFormat( PAPER_STATEMENT );
break;
case DMPAPER_EXECUTIVE:
- pSetupData->mePaperFormat = PAPER_EXECUTIVE;
+ pSetupData->SetPaperFormat( PAPER_EXECUTIVE );
break;
case DMPAPER_A3:
- pSetupData->mePaperFormat = PAPER_A3;
+ pSetupData->SetPaperFormat( PAPER_A3 );
break;
case DMPAPER_A4:
- pSetupData->mePaperFormat = PAPER_A4;
+ pSetupData->SetPaperFormat( PAPER_A4 );
break;
case DMPAPER_A5:
- pSetupData->mePaperFormat = PAPER_A5;
+ pSetupData->SetPaperFormat( PAPER_A5 );
break;
//See http://wiki.openoffice.org/wiki/DefaultPaperSize
//i.e.
@@ -580,127 +580,127 @@ static void ImplDevModeToJobSetup( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS
//which is bogus as it's either JIS 257 x 364 or ISO 250 x 353
//(cmc)
case DMPAPER_B4:
- pSetupData->mePaperFormat = PAPER_B4_JIS;
+ pSetupData->SetPaperFormat( PAPER_B4_JIS );
break;
case DMPAPER_B5:
- pSetupData->mePaperFormat = PAPER_B5_JIS;
+ pSetupData->SetPaperFormat( PAPER_B5_JIS );
break;
case DMPAPER_QUARTO:
- pSetupData->mePaperFormat = PAPER_QUARTO;
+ pSetupData->SetPaperFormat( PAPER_QUARTO );
break;
case DMPAPER_10X14:
- pSetupData->mePaperFormat = PAPER_10x14;
+ pSetupData->SetPaperFormat( PAPER_10x14 );
break;
case DMPAPER_NOTE:
- pSetupData->mePaperFormat = PAPER_LETTER;
+ pSetupData->SetPaperFormat( PAPER_LETTER );
break;
case DMPAPER_ENV_9:
- pSetupData->mePaperFormat = PAPER_ENV_9;
+ pSetupData->SetPaperFormat( PAPER_ENV_9 );
break;
case DMPAPER_ENV_10:
- pSetupData->mePaperFormat = PAPER_ENV_10;
+ pSetupData->SetPaperFormat( PAPER_ENV_10 );
break;
case DMPAPER_ENV_11:
- pSetupData->mePaperFormat = PAPER_ENV_11;
+ pSetupData->SetPaperFormat( PAPER_ENV_11 );
break;
case DMPAPER_ENV_12:
- pSetupData->mePaperFormat = PAPER_ENV_12;
+ pSetupData->SetPaperFormat( PAPER_ENV_12 );
break;
case DMPAPER_ENV_14:
- pSetupData->mePaperFormat = PAPER_ENV_14;
+ pSetupData->SetPaperFormat( PAPER_ENV_14 );
break;
case DMPAPER_CSHEET:
- pSetupData->mePaperFormat = PAPER_C;
+ pSetupData->SetPaperFormat( PAPER_C );
break;
case DMPAPER_DSHEET:
- pSetupData->mePaperFormat = PAPER_D;
+ pSetupData->SetPaperFormat( PAPER_D );
break;
case DMPAPER_ESHEET:
- pSetupData->mePaperFormat = PAPER_E;
+ pSetupData->SetPaperFormat( PAPER_E );
break;
case DMPAPER_ENV_DL:
- pSetupData->mePaperFormat = PAPER_ENV_DL;
+ pSetupData->SetPaperFormat( PAPER_ENV_DL );
break;
case DMPAPER_ENV_C5:
- pSetupData->mePaperFormat = PAPER_ENV_C5;
+ pSetupData->SetPaperFormat( PAPER_ENV_C5 );
break;
case DMPAPER_ENV_C3:
- pSetupData->mePaperFormat = PAPER_ENV_C3;
+ pSetupData->SetPaperFormat( PAPER_ENV_C3 );
break;
case DMPAPER_ENV_C4:
- pSetupData->mePaperFormat = PAPER_ENV_C4;
+ pSetupData->SetPaperFormat( PAPER_ENV_C4 );
break;
case DMPAPER_ENV_C6:
- pSetupData->mePaperFormat = PAPER_ENV_C6;
+ pSetupData->SetPaperFormat( PAPER_ENV_C6 );
break;
case DMPAPER_ENV_C65:
- pSetupData->mePaperFormat = PAPER_ENV_C65;
+ pSetupData->SetPaperFormat( PAPER_ENV_C65 );
break;
case DMPAPER_ENV_ITALY:
- pSetupData->mePaperFormat = PAPER_ENV_ITALY;
+ pSetupData->SetPaperFormat( PAPER_ENV_ITALY );
break;
case DMPAPER_ENV_MONARCH:
- pSetupData->mePaperFormat = PAPER_ENV_MONARCH;
+ pSetupData->SetPaperFormat( PAPER_ENV_MONARCH );
break;
case DMPAPER_ENV_PERSONAL:
- pSetupData->mePaperFormat = PAPER_ENV_PERSONAL;
+ pSetupData->SetPaperFormat( PAPER_ENV_PERSONAL );
break;
case DMPAPER_FANFOLD_US:
- pSetupData->mePaperFormat = PAPER_FANFOLD_US;
+ pSetupData->SetPaperFormat( PAPER_FANFOLD_US );
break;
case DMPAPER_FANFOLD_STD_GERMAN:
- pSetupData->mePaperFormat = PAPER_FANFOLD_DE;
+ pSetupData->SetPaperFormat( PAPER_FANFOLD_DE );
break;
case DMPAPER_FANFOLD_LGL_GERMAN:
- pSetupData->mePaperFormat = PAPER_FANFOLD_LEGAL_DE;
+ pSetupData->SetPaperFormat( PAPER_FANFOLD_LEGAL_DE );
break;
case DMPAPER_ISO_B4:
- pSetupData->mePaperFormat = PAPER_B4_ISO;
+ pSetupData->SetPaperFormat( PAPER_B4_ISO );
break;
case DMPAPER_JAPANESE_POSTCARD:
- pSetupData->mePaperFormat = PAPER_POSTCARD_JP;
+ pSetupData->SetPaperFormat( PAPER_POSTCARD_JP );
break;
case DMPAPER_9X11:
- pSetupData->mePaperFormat = PAPER_9x11;
+ pSetupData->SetPaperFormat( PAPER_9x11 );
break;
case DMPAPER_10X11:
- pSetupData->mePaperFormat = PAPER_10x11;
+ pSetupData->SetPaperFormat( PAPER_10x11 );
break;
case DMPAPER_15X11:
- pSetupData->mePaperFormat = PAPER_15x11;
+ pSetupData->SetPaperFormat( PAPER_15x11 );
break;
case DMPAPER_ENV_INVITE:
- pSetupData->mePaperFormat = PAPER_ENV_INVITE;
+ pSetupData->SetPaperFormat( PAPER_ENV_INVITE );
break;
case DMPAPER_A_PLUS:
- pSetupData->mePaperFormat = PAPER_A_PLUS;
+ pSetupData->SetPaperFormat( PAPER_A_PLUS );
break;
case DMPAPER_B_PLUS:
- pSetupData->mePaperFormat = PAPER_B_PLUS;
+ pSetupData->SetPaperFormat( PAPER_B_PLUS );
break;
case DMPAPER_LETTER_PLUS:
- pSetupData->mePaperFormat = PAPER_LETTER_PLUS;
+ pSetupData->SetPaperFormat( PAPER_LETTER_PLUS );
break;
case DMPAPER_A4_PLUS:
- pSetupData->mePaperFormat = PAPER_A4_PLUS;
+ pSetupData->SetPaperFormat( PAPER_A4_PLUS );
break;
case DMPAPER_A2:
- pSetupData->mePaperFormat = PAPER_A2;
+ pSetupData->SetPaperFormat( PAPER_A2 );
break;
case DMPAPER_DBL_JAPANESE_POSTCARD:
- pSetupData->mePaperFormat = PAPER_DOUBLEPOSTCARD_JP;
+ pSetupData->SetPaperFormat( PAPER_DOUBLEPOSTCARD_JP );
break;
case DMPAPER_A6:
- pSetupData->mePaperFormat = PAPER_A6;
+ pSetupData->SetPaperFormat( PAPER_A6 );
break;
case DMPAPER_B6_JIS:
- pSetupData->mePaperFormat = PAPER_B6_JIS;
+ pSetupData->SetPaperFormat( PAPER_B6_JIS );
break;
case DMPAPER_12X11:
- pSetupData->mePaperFormat = PAPER_12x11;
+ pSetupData->SetPaperFormat( PAPER_12x11 );
break;
default:
- pSetupData->mePaperFormat = PAPER_USER;
+ pSetupData->SetPaperFormat( PAPER_USER );
break;
}
}
@@ -717,13 +717,13 @@ static void ImplDevModeToJobSetup( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS
else if( CHOOSE_DEVMODE(dmDuplex) == DMDUP_HORIZONTAL )
eDuplex = DUPLEX_SHORTEDGE;
}
- pSetupData->meDuplexMode = eDuplex;
+ pSetupData->SetDuplexMode( eDuplex );
}
}
-static void ImplJobSetupToDevMode( WinSalInfoPrinter* pPrinter, ImplJobSetup* pSetupData, JobSetFlags nFlags )
+static void ImplJobSetupToDevMode( WinSalInfoPrinter* pPrinter, const ImplJobSetup* pSetupData, JobSetFlags nFlags )
{
- if ( !pSetupData || !pSetupData->mpDriverData )
+ if ( !pSetupData || !pSetupData->GetDriverData() )
return;
DECLARE_DEVMODE( pSetupData );
@@ -732,7 +732,7 @@ static void ImplJobSetupToDevMode( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS
if ( nFlags & JobSetFlags::ORIENTATION )
{
CHOOSE_DEVMODE(dmFields) |= DM_ORIENTATION;
- if ( pSetupData->meOrientation == ORIENTATION_PORTRAIT )
+ if ( pSetupData->GetOrientation() == ORIENTATION_PORTRAIT )
CHOOSE_DEVMODE(dmOrientation) = DMORIENT_PORTRAIT;
else
CHOOSE_DEVMODE(dmOrientation) = DMORIENT_LANDSCAPE;
@@ -748,7 +748,7 @@ static void ImplJobSetupToDevMode( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS
WORD* pBins = (WORD*)rtl_allocateZeroMemory(nCount*sizeof(WORD));
ImplDeviceCaps( pPrinter, DC_BINS, (BYTE*)pBins, pSetupData );
CHOOSE_DEVMODE(dmFields) |= DM_DEFAULTSOURCE;
- CHOOSE_DEVMODE(dmDefaultSource) = pBins[ pSetupData->mnPaperBin ];
+ CHOOSE_DEVMODE(dmDefaultSource) = pBins[ pSetupData->GetPaperBin() ];
rtl_freeMemory( pBins );
}
}
@@ -760,7 +760,7 @@ static void ImplJobSetupToDevMode( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS
CHOOSE_DEVMODE(dmPaperWidth) = 0;
CHOOSE_DEVMODE(dmPaperLength) = 0;
- switch( pSetupData->mePaperFormat )
+ switch( pSetupData->GetPaperFormat() )
{
case PAPER_A2:
CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_A2;
@@ -936,7 +936,7 @@ static void ImplJobSetupToDevMode( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS
}
if ( (nPaperSizeCount == nPaperCount) && pPapers && pPaperSizes )
{
- PaperInfo aInfo(pSetupData->mnPaperWidth, pSetupData->mnPaperHeight);
+ PaperInfo aInfo(pSetupData->GetPaperWidth(), pSetupData->GetPaperHeight());
// compare paper formats and select a good match
for ( DWORD i = 0; i < nPaperCount; ++i )
{
@@ -952,7 +952,7 @@ static void ImplJobSetupToDevMode( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS
// all paper sizes with portrait orientation only!!
if ( !nPaper && nLandscapeAngle != 0 )
{
- PaperInfo aRotatedInfo(pSetupData->mnPaperHeight, pSetupData->mnPaperWidth);
+ PaperInfo aRotatedInfo(pSetupData->GetPaperHeight(), pSetupData->GetPaperWidth());
for ( DWORD i = 0; i < nPaperCount; ++i )
{
if ( aRotatedInfo.sloppyEqual(PaperInfo(pPaperSizes[i].x*10, pPaperSizes[i].y*10)) )
@@ -971,8 +971,8 @@ static void ImplJobSetupToDevMode( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS
{
CHOOSE_DEVMODE(dmFields) |= DM_PAPERLENGTH | DM_PAPERWIDTH;
CHOOSE_DEVMODE(dmPaperSize) = DMPAPER_USER;
- CHOOSE_DEVMODE(dmPaperWidth) = (short)(pSetupData->mnPaperWidth/10);
- CHOOSE_DEVMODE(dmPaperLength) = (short)(pSetupData->mnPaperHeight/10);
+ CHOOSE_DEVMODE(dmPaperWidth) = (short)(pSetupData->GetPaperWidth()/10);
+ CHOOSE_DEVMODE(dmPaperLength) = (short)(pSetupData->GetPaperHeight()/10);
}
if ( pPapers )
@@ -986,7 +986,7 @@ static void ImplJobSetupToDevMode( WinSalInfoPrinter* pPrinter, ImplJobSetup* pS
}
if( (nFlags & JobSetFlags::DUPLEXMODE) )
{
- switch( pSetupData->meDuplexMode )
+ switch( pSetupData->GetDuplexMode() )
{
case DUPLEX_OFF:
CHOOSE_DEVMODE(dmFields) |= DM_DUPLEX;
@@ -1017,11 +1017,11 @@ static HDC ImplCreateICW_WithCatch( LPWSTR pDriver,
return hDC;
}
-static HDC ImplCreateSalPrnIC( WinSalInfoPrinter* pPrinter, ImplJobSetup* pSetupData )
+static HDC ImplCreateSalPrnIC( WinSalInfoPrinter* pPrinter, const ImplJobSetup* pSetupData )
{
HDC hDC = 0;
LPDEVMODEW pDevMode;
- if ( pSetupData && pSetupData->mpDriverData )
+ if ( pSetupData && pSetupData->GetDriverData() )
pDevMode = SAL_DEVMODE_W( pSetupData );
else
pDevMode = NULL;
@@ -1050,7 +1050,7 @@ static WinSalGraphics* ImplCreateSalPrnGraphics( HDC hDC )
return pGraphics;
}
-static bool ImplUpdateSalPrnIC( WinSalInfoPrinter* pPrinter, ImplJobSetup* pSetupData )
+static bool ImplUpdateSalPrnIC( WinSalInfoPrinter* pPrinter, const ImplJobSetup* pSetupData )
{
HDC hNewDC = ImplCreateSalPrnIC( pPrinter, pSetupData );
if ( !hNewDC )
@@ -1094,10 +1094,10 @@ SalInfoPrinter* WinSalInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueIn
pPrinter->mpGraphics = ImplCreateSalPrnGraphics( hDC );
pPrinter->mhDC = hDC;
- if ( !pSetupData->mpDriverData )
+ if ( !pSetupData->GetDriverData() )
ImplUpdateSalJobSetup( pPrinter, pSetupData, FALSE, NULL );
ImplDevModeToJobSetup( pPrinter, pSetupData, JobSetFlags::ALL );
- pSetupData->mnSystem = JOBSETUP_SYSTEM_WINDOWS;
+ pSetupData->SetSystem( JOBSETUP_SYSTEM_WINDOWS );
return pPrinter;
}
@@ -1458,7 +1458,7 @@ bool WinSalPrinter::StartJob( const OUString* pFileName,
LPDEVMODEW pOrgDevModeW = NULL;
LPDEVMODEW pDevModeW = NULL;
HDC hDC = 0;
- if ( pSetupData && pSetupData->mpDriverData )
+ if ( pSetupData && pSetupData->GetDriverData() )
{
pOrgDevModeW = SAL_DEVMODE_W( pSetupData );
pDevModeW = ImplSalSetCopies( pOrgDevModeW, nCopies, bCollate );
@@ -1610,7 +1610,7 @@ SalGraphics* WinSalPrinter::StartPage( ImplJobSetup* pSetupData, bool bNewJobDat
return NULL;
HDC hDC = mhDC;
- if ( pSetupData && pSetupData->mpDriverData && bNewJobData )
+ if ( pSetupData && pSetupData->GetDriverData() && bNewJobData )
{
LPDEVMODEW pOrgDevModeW;
LPDEVMODEW pDevModeW;