1*9f62ea84SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*9f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*9f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*9f62ea84SAndrew Rist * distributed with this work for additional information 6*9f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*9f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*9f62ea84SAndrew Rist * "License"); you may not use this file except in compliance 9*9f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*9f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*9f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*9f62ea84SAndrew Rist * software distributed under the License is distributed on an 15*9f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9f62ea84SAndrew Rist * KIND, either express or implied. See the License for the 17*9f62ea84SAndrew Rist * specific language governing permissions and limitations 18*9f62ea84SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*9f62ea84SAndrew Rist *************************************************************/ 21*9f62ea84SAndrew Rist 22*9f62ea84SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_vcl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <tools/debug.hxx> 28cdf0e10cSrcweir #include <tools/stream.hxx> 29cdf0e10cSrcweir 30cdf0e10cSrcweir #include <rtl/alloc.h> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <vcl/jobset.hxx> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <jobset.h> 35cdf0e10cSrcweir 36cdf0e10cSrcweir // ======================================================================= 37cdf0e10cSrcweir 38cdf0e10cSrcweir DBG_NAME( JobSetup ) 39cdf0e10cSrcweir 40cdf0e10cSrcweir #define JOBSET_FILEFORMAT2 3780 41cdf0e10cSrcweir #define JOBSET_FILE364_SYSTEM ((sal_uInt16)0xFFFF) 42cdf0e10cSrcweir #define JOBSET_FILE605_SYSTEM ((sal_uInt16)0xFFFE) 43cdf0e10cSrcweir 44cdf0e10cSrcweir struct ImplOldJobSetupData 45cdf0e10cSrcweir { 46cdf0e10cSrcweir char cPrinterName[64]; 47cdf0e10cSrcweir char cDeviceName[32]; 48cdf0e10cSrcweir char cPortName[32]; 49cdf0e10cSrcweir char cDriverName[32]; 50cdf0e10cSrcweir }; 51cdf0e10cSrcweir 52cdf0e10cSrcweir struct Impl364JobSetupData 53cdf0e10cSrcweir { 54cdf0e10cSrcweir SVBT16 nSize; 55cdf0e10cSrcweir SVBT16 nSystem; 56cdf0e10cSrcweir SVBT32 nDriverDataLen; 57cdf0e10cSrcweir SVBT16 nOrientation; 58cdf0e10cSrcweir SVBT16 nPaperBin; 59cdf0e10cSrcweir SVBT16 nPaperFormat; 60cdf0e10cSrcweir SVBT32 nPaperWidth; 61cdf0e10cSrcweir SVBT32 nPaperHeight; 62cdf0e10cSrcweir }; 63cdf0e10cSrcweir 64cdf0e10cSrcweir // ======================================================================= 65cdf0e10cSrcweir 66cdf0e10cSrcweir ImplJobSetup::ImplJobSetup() 67cdf0e10cSrcweir { 68cdf0e10cSrcweir mnRefCount = 1; 69cdf0e10cSrcweir mnSystem = 0; 70cdf0e10cSrcweir meOrientation = ORIENTATION_PORTRAIT; 71cdf0e10cSrcweir meDuplexMode = DUPLEX_UNKNOWN; 72cdf0e10cSrcweir mnPaperBin = 0; 73cdf0e10cSrcweir mePaperFormat = PAPER_USER; 74cdf0e10cSrcweir mnPaperWidth = 0; 75cdf0e10cSrcweir mnPaperHeight = 0; 76cdf0e10cSrcweir mnDriverDataLen = 0; 77cdf0e10cSrcweir mpDriverData = NULL; 78cdf0e10cSrcweir } 79cdf0e10cSrcweir 80cdf0e10cSrcweir // ----------------------------------------------------------------------- 81cdf0e10cSrcweir 82cdf0e10cSrcweir ImplJobSetup::ImplJobSetup( const ImplJobSetup& rJobSetup ) : 83cdf0e10cSrcweir maPrinterName( rJobSetup.maPrinterName ), 84cdf0e10cSrcweir maDriver( rJobSetup.maDriver ) 85cdf0e10cSrcweir { 86cdf0e10cSrcweir mnRefCount = 1; 87cdf0e10cSrcweir mnSystem = rJobSetup.mnSystem; 88cdf0e10cSrcweir meOrientation = rJobSetup.meOrientation; 89cdf0e10cSrcweir meDuplexMode = rJobSetup.meDuplexMode; 90cdf0e10cSrcweir mnPaperBin = rJobSetup.mnPaperBin; 91cdf0e10cSrcweir mePaperFormat = rJobSetup.mePaperFormat; 92cdf0e10cSrcweir mnPaperWidth = rJobSetup.mnPaperWidth; 93cdf0e10cSrcweir mnPaperHeight = rJobSetup.mnPaperHeight; 94cdf0e10cSrcweir mnDriverDataLen = rJobSetup.mnDriverDataLen; 95cdf0e10cSrcweir if ( rJobSetup.mpDriverData ) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir mpDriverData = (sal_uInt8*)rtl_allocateMemory( mnDriverDataLen ); 98cdf0e10cSrcweir memcpy( mpDriverData, rJobSetup.mpDriverData, mnDriverDataLen ); 99cdf0e10cSrcweir } 100cdf0e10cSrcweir else 101cdf0e10cSrcweir mpDriverData = NULL; 102cdf0e10cSrcweir maValueMap = rJobSetup.maValueMap; 103cdf0e10cSrcweir } 104cdf0e10cSrcweir 105cdf0e10cSrcweir // ----------------------------------------------------------------------- 106cdf0e10cSrcweir 107cdf0e10cSrcweir ImplJobSetup::~ImplJobSetup() 108cdf0e10cSrcweir { 109cdf0e10cSrcweir rtl_freeMemory( mpDriverData ); 110cdf0e10cSrcweir } 111cdf0e10cSrcweir 112cdf0e10cSrcweir // ======================================================================= 113cdf0e10cSrcweir 114cdf0e10cSrcweir ImplJobSetup* JobSetup::ImplGetData() 115cdf0e10cSrcweir { 116cdf0e10cSrcweir if ( !mpData ) 117cdf0e10cSrcweir mpData = new ImplJobSetup; 118cdf0e10cSrcweir else if ( mpData->mnRefCount != 1 ) 119cdf0e10cSrcweir { 120cdf0e10cSrcweir mpData->mnRefCount--; 121cdf0e10cSrcweir mpData = new ImplJobSetup( *mpData ); 122cdf0e10cSrcweir } 123cdf0e10cSrcweir 124cdf0e10cSrcweir return mpData; 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir // ----------------------------------------------------------------------- 128cdf0e10cSrcweir 129cdf0e10cSrcweir ImplJobSetup* JobSetup::ImplGetConstData() 130cdf0e10cSrcweir { 131cdf0e10cSrcweir if ( !mpData ) 132cdf0e10cSrcweir mpData = new ImplJobSetup; 133cdf0e10cSrcweir return mpData; 134cdf0e10cSrcweir } 135cdf0e10cSrcweir 136cdf0e10cSrcweir // ----------------------------------------------------------------------- 137cdf0e10cSrcweir 138cdf0e10cSrcweir const ImplJobSetup* JobSetup::ImplGetConstData() const 139cdf0e10cSrcweir { 140cdf0e10cSrcweir if ( !mpData ) 141cdf0e10cSrcweir ((JobSetup*)this)->mpData = new ImplJobSetup; 142cdf0e10cSrcweir return mpData; 143cdf0e10cSrcweir } 144cdf0e10cSrcweir 145cdf0e10cSrcweir // ======================================================================= 146cdf0e10cSrcweir 147cdf0e10cSrcweir JobSetup::JobSetup() 148cdf0e10cSrcweir { 149cdf0e10cSrcweir DBG_CTOR( JobSetup, NULL ); 150cdf0e10cSrcweir 151cdf0e10cSrcweir mpData = NULL; 152cdf0e10cSrcweir } 153cdf0e10cSrcweir 154cdf0e10cSrcweir // ----------------------------------------------------------------------- 155cdf0e10cSrcweir 156cdf0e10cSrcweir JobSetup::JobSetup( const JobSetup& rJobSetup ) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir DBG_CTOR( JobSetup, NULL ); 159cdf0e10cSrcweir DBG_CHKOBJ( &rJobSetup, JobSetup, NULL ); 160cdf0e10cSrcweir DBG_ASSERT( !rJobSetup.mpData || (rJobSetup.mpData->mnRefCount < 0xFFFE), "JobSetup: RefCount overflow" ); 161cdf0e10cSrcweir 162cdf0e10cSrcweir mpData = rJobSetup.mpData; 163cdf0e10cSrcweir if ( mpData ) 164cdf0e10cSrcweir mpData->mnRefCount++; 165cdf0e10cSrcweir } 166cdf0e10cSrcweir 167cdf0e10cSrcweir // ----------------------------------------------------------------------- 168cdf0e10cSrcweir 169cdf0e10cSrcweir JobSetup::~JobSetup() 170cdf0e10cSrcweir { 171cdf0e10cSrcweir DBG_DTOR( JobSetup, NULL ); 172cdf0e10cSrcweir 173cdf0e10cSrcweir if ( mpData ) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir if ( mpData->mnRefCount == 1 ) 176cdf0e10cSrcweir delete mpData; 177cdf0e10cSrcweir else 178cdf0e10cSrcweir mpData->mnRefCount--; 179cdf0e10cSrcweir } 180cdf0e10cSrcweir } 181cdf0e10cSrcweir 182cdf0e10cSrcweir // ----------------------------------------------------------------------- 183cdf0e10cSrcweir 184cdf0e10cSrcweir XubString JobSetup::GetPrinterName() const 185cdf0e10cSrcweir { 186cdf0e10cSrcweir if ( mpData ) 187cdf0e10cSrcweir return mpData->maPrinterName; 188cdf0e10cSrcweir else 189cdf0e10cSrcweir { 190cdf0e10cSrcweir XubString aName; 191cdf0e10cSrcweir return aName; 192cdf0e10cSrcweir } 193cdf0e10cSrcweir } 194cdf0e10cSrcweir 195cdf0e10cSrcweir // ----------------------------------------------------------------------- 196cdf0e10cSrcweir 197cdf0e10cSrcweir XubString JobSetup::GetDriverName() const 198cdf0e10cSrcweir { 199cdf0e10cSrcweir if ( mpData ) 200cdf0e10cSrcweir return mpData->maDriver; 201cdf0e10cSrcweir else 202cdf0e10cSrcweir { 203cdf0e10cSrcweir XubString aDriver; 204cdf0e10cSrcweir return aDriver; 205cdf0e10cSrcweir } 206cdf0e10cSrcweir } 207cdf0e10cSrcweir 208cdf0e10cSrcweir // ----------------------------------------------------------------------- 209cdf0e10cSrcweir 210cdf0e10cSrcweir String JobSetup::GetValue( const String& rKey ) const 211cdf0e10cSrcweir { 212cdf0e10cSrcweir if( mpData ) 213cdf0e10cSrcweir { 214cdf0e10cSrcweir ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash >::const_iterator it; 215cdf0e10cSrcweir it = mpData->maValueMap.find( rKey ); 216cdf0e10cSrcweir return it != mpData->maValueMap.end() ? String( it->second ) : String(); 217cdf0e10cSrcweir } 218cdf0e10cSrcweir return String(); 219cdf0e10cSrcweir } 220cdf0e10cSrcweir 221cdf0e10cSrcweir // ----------------------------------------------------------------------- 222cdf0e10cSrcweir 223cdf0e10cSrcweir void JobSetup::SetValue( const String& rKey, const String& rValue ) 224cdf0e10cSrcweir { 225cdf0e10cSrcweir if( ! mpData ) 226cdf0e10cSrcweir mpData = new ImplJobSetup(); 227cdf0e10cSrcweir 228cdf0e10cSrcweir mpData->maValueMap[ rKey ] = rValue; 229cdf0e10cSrcweir } 230cdf0e10cSrcweir 231cdf0e10cSrcweir // ----------------------------------------------------------------------- 232cdf0e10cSrcweir 233cdf0e10cSrcweir JobSetup& JobSetup::operator=( const JobSetup& rJobSetup ) 234cdf0e10cSrcweir { 235cdf0e10cSrcweir DBG_CHKTHIS( JobSetup, NULL ); 236cdf0e10cSrcweir DBG_CHKOBJ( &rJobSetup, JobSetup, NULL ); 237cdf0e10cSrcweir DBG_ASSERT( !rJobSetup.mpData || (rJobSetup.mpData->mnRefCount) < 0xFFFE, "JobSetup: RefCount overflow" ); 238cdf0e10cSrcweir 239cdf0e10cSrcweir // Zuerst Referenzcounter erhoehen, damit man sich selbst zuweisen kann 240cdf0e10cSrcweir if ( rJobSetup.mpData ) 241cdf0e10cSrcweir rJobSetup.mpData->mnRefCount++; 242cdf0e10cSrcweir 243cdf0e10cSrcweir // Wenn es keine statischen ImpDaten sind, dann loeschen, wenn es 244cdf0e10cSrcweir // die letzte Referenz ist, sonst Referenzcounter decrementieren 245cdf0e10cSrcweir if ( mpData ) 246cdf0e10cSrcweir { 247cdf0e10cSrcweir if ( mpData->mnRefCount == 1 ) 248cdf0e10cSrcweir delete mpData; 249cdf0e10cSrcweir else 250cdf0e10cSrcweir mpData->mnRefCount--; 251cdf0e10cSrcweir } 252cdf0e10cSrcweir 253cdf0e10cSrcweir mpData = rJobSetup.mpData; 254cdf0e10cSrcweir 255cdf0e10cSrcweir return *this; 256cdf0e10cSrcweir } 257cdf0e10cSrcweir 258cdf0e10cSrcweir // ----------------------------------------------------------------------- 259cdf0e10cSrcweir 260cdf0e10cSrcweir sal_Bool JobSetup::operator==( const JobSetup& rJobSetup ) const 261cdf0e10cSrcweir { 262cdf0e10cSrcweir DBG_CHKTHIS( JobSetup, NULL ); 263cdf0e10cSrcweir DBG_CHKOBJ( &rJobSetup, JobSetup, NULL ); 264cdf0e10cSrcweir 265cdf0e10cSrcweir if ( mpData == rJobSetup.mpData ) 266cdf0e10cSrcweir return sal_True; 267cdf0e10cSrcweir 268cdf0e10cSrcweir if ( !mpData || !rJobSetup.mpData ) 269cdf0e10cSrcweir return sal_False; 270cdf0e10cSrcweir 271cdf0e10cSrcweir ImplJobSetup* pData1 = mpData; 272cdf0e10cSrcweir ImplJobSetup* pData2 = rJobSetup.mpData; 273cdf0e10cSrcweir if ( (pData1->mnSystem == pData2->mnSystem) && 274cdf0e10cSrcweir (pData1->maPrinterName == pData2->maPrinterName) && 275cdf0e10cSrcweir (pData1->maDriver == pData2->maDriver) && 276cdf0e10cSrcweir (pData1->meOrientation == pData2->meOrientation) && 277cdf0e10cSrcweir (pData1->meDuplexMode == pData2->meDuplexMode) && 278cdf0e10cSrcweir (pData1->mnPaperBin == pData2->mnPaperBin) && 279cdf0e10cSrcweir (pData1->mePaperFormat == pData2->mePaperFormat) && 280cdf0e10cSrcweir (pData1->mnPaperWidth == pData2->mnPaperWidth) && 281cdf0e10cSrcweir (pData1->mnPaperHeight == pData2->mnPaperHeight) && 282cdf0e10cSrcweir (pData1->mnDriverDataLen == pData2->mnDriverDataLen) && 283cdf0e10cSrcweir (memcmp( pData1->mpDriverData, pData2->mpDriverData, pData1->mnDriverDataLen ) == 0) && 284cdf0e10cSrcweir (pData1->maValueMap == pData2->maValueMap) 285cdf0e10cSrcweir ) 286cdf0e10cSrcweir return sal_True; 287cdf0e10cSrcweir 288cdf0e10cSrcweir return sal_False; 289cdf0e10cSrcweir } 290cdf0e10cSrcweir 291cdf0e10cSrcweir // ----------------------------------------------------------------------- 292cdf0e10cSrcweir 293cdf0e10cSrcweir SvStream& operator>>( SvStream& rIStream, JobSetup& rJobSetup ) 294cdf0e10cSrcweir { 295cdf0e10cSrcweir DBG_ASSERTWARNING( rIStream.GetVersion(), "JobSetup::>> - Solar-Version not set on rOStream" ); 296cdf0e10cSrcweir 297cdf0e10cSrcweir // Zur Zeit haben wir noch kein neues FileFormat 298cdf0e10cSrcweir // if ( rIStream.GetVersion() < JOBSET_FILEFORMAT2 ) 299cdf0e10cSrcweir { 300cdf0e10cSrcweir sal_Size nFirstPos = rIStream.Tell(); 301cdf0e10cSrcweir 302cdf0e10cSrcweir sal_uInt16 nLen = 0; 303cdf0e10cSrcweir rIStream >> nLen; 304cdf0e10cSrcweir if ( !nLen ) 305cdf0e10cSrcweir return rIStream; 306cdf0e10cSrcweir 307cdf0e10cSrcweir sal_uInt16 nSystem = 0; 308cdf0e10cSrcweir rIStream >> nSystem; 309cdf0e10cSrcweir 310cdf0e10cSrcweir char* pTempBuf = new char[nLen]; 311cdf0e10cSrcweir rIStream.Read( pTempBuf, nLen - sizeof( nLen ) - sizeof( nSystem ) ); 312cdf0e10cSrcweir if ( nLen >= sizeof(ImplOldJobSetupData)+4 ) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir ImplOldJobSetupData* pData = (ImplOldJobSetupData*)pTempBuf; 315cdf0e10cSrcweir if ( rJobSetup.mpData ) 316cdf0e10cSrcweir { 317cdf0e10cSrcweir if ( rJobSetup.mpData->mnRefCount == 1 ) 318cdf0e10cSrcweir delete rJobSetup.mpData; 319cdf0e10cSrcweir else 320cdf0e10cSrcweir rJobSetup.mpData->mnRefCount--; 321cdf0e10cSrcweir } 322cdf0e10cSrcweir 323cdf0e10cSrcweir rtl_TextEncoding aStreamEncoding = RTL_TEXTENCODING_UTF8; 324cdf0e10cSrcweir if( nSystem == JOBSET_FILE364_SYSTEM ) 325cdf0e10cSrcweir aStreamEncoding = rIStream.GetStreamCharSet(); 326cdf0e10cSrcweir 327cdf0e10cSrcweir rJobSetup.mpData = new ImplJobSetup; 328cdf0e10cSrcweir ImplJobSetup* pJobData = rJobSetup.mpData; 329cdf0e10cSrcweir pJobData->maPrinterName = UniString( pData->cPrinterName, aStreamEncoding ); 330cdf0e10cSrcweir pJobData->maDriver = UniString( pData->cDriverName, aStreamEncoding ); 331cdf0e10cSrcweir 332cdf0e10cSrcweir // Sind es unsere neuen JobSetup-Daten? 333cdf0e10cSrcweir if ( nSystem == JOBSET_FILE364_SYSTEM || 334cdf0e10cSrcweir nSystem == JOBSET_FILE605_SYSTEM ) 335cdf0e10cSrcweir { 336cdf0e10cSrcweir Impl364JobSetupData* pOldJobData = (Impl364JobSetupData*)(pTempBuf + sizeof( ImplOldJobSetupData )); 337cdf0e10cSrcweir sal_uInt16 nOldJobDataSize = SVBT16ToShort( pOldJobData->nSize ); 338cdf0e10cSrcweir pJobData->mnSystem = SVBT16ToShort( pOldJobData->nSystem ); 339cdf0e10cSrcweir pJobData->mnDriverDataLen = SVBT32ToUInt32( pOldJobData->nDriverDataLen ); 340cdf0e10cSrcweir pJobData->meOrientation = (Orientation)SVBT16ToShort( pOldJobData->nOrientation ); 341cdf0e10cSrcweir pJobData->meDuplexMode = DUPLEX_UNKNOWN; 342cdf0e10cSrcweir pJobData->mnPaperBin = SVBT16ToShort( pOldJobData->nPaperBin ); 343cdf0e10cSrcweir pJobData->mePaperFormat = (Paper)SVBT16ToShort( pOldJobData->nPaperFormat ); 344cdf0e10cSrcweir pJobData->mnPaperWidth = (long)SVBT32ToUInt32( pOldJobData->nPaperWidth ); 345cdf0e10cSrcweir pJobData->mnPaperHeight = (long)SVBT32ToUInt32( pOldJobData->nPaperHeight ); 346cdf0e10cSrcweir if ( pJobData->mnDriverDataLen ) 347cdf0e10cSrcweir { 348cdf0e10cSrcweir sal_uInt8* pDriverData = ((sal_uInt8*)pOldJobData) + nOldJobDataSize; 349cdf0e10cSrcweir pJobData->mpDriverData = (sal_uInt8*)rtl_allocateMemory( pJobData->mnDriverDataLen ); 350cdf0e10cSrcweir memcpy( pJobData->mpDriverData, pDriverData, pJobData->mnDriverDataLen ); 351cdf0e10cSrcweir } 352cdf0e10cSrcweir if( nSystem == JOBSET_FILE605_SYSTEM ) 353cdf0e10cSrcweir { 354cdf0e10cSrcweir rIStream.Seek( nFirstPos + sizeof( ImplOldJobSetupData ) + 4 + sizeof( Impl364JobSetupData ) + pJobData->mnDriverDataLen ); 355cdf0e10cSrcweir while( rIStream.Tell() < nFirstPos + nLen ) 356cdf0e10cSrcweir { 357cdf0e10cSrcweir String aKey, aValue; 358cdf0e10cSrcweir rIStream.ReadByteString( aKey, RTL_TEXTENCODING_UTF8 ); 359cdf0e10cSrcweir rIStream.ReadByteString( aValue, RTL_TEXTENCODING_UTF8 ); 360cdf0e10cSrcweir if( aKey.EqualsAscii( "COMPAT_DUPLEX_MODE" ) ) 361cdf0e10cSrcweir { 362cdf0e10cSrcweir if( aValue.EqualsAscii( "DUPLEX_UNKNOWN" ) ) 363cdf0e10cSrcweir pJobData->meDuplexMode = DUPLEX_UNKNOWN; 364cdf0e10cSrcweir else if( aValue.EqualsAscii( "DUPLEX_OFF" ) ) 365cdf0e10cSrcweir pJobData->meDuplexMode = DUPLEX_OFF; 366cdf0e10cSrcweir else if( aValue.EqualsAscii( "DUPLEX_SHORTEDGE" ) ) 367cdf0e10cSrcweir pJobData->meDuplexMode = DUPLEX_SHORTEDGE; 368cdf0e10cSrcweir else if( aValue.EqualsAscii( "DUPLEX_LONGEDGE" ) ) 369cdf0e10cSrcweir pJobData->meDuplexMode = DUPLEX_LONGEDGE; 370cdf0e10cSrcweir } 371cdf0e10cSrcweir else 372cdf0e10cSrcweir pJobData->maValueMap[ aKey ] = aValue; 373cdf0e10cSrcweir } 374cdf0e10cSrcweir DBG_ASSERT( rIStream.Tell() == nFirstPos+nLen, "corrupted job setup" ); 375cdf0e10cSrcweir // ensure correct stream position 376cdf0e10cSrcweir rIStream.Seek( nFirstPos + nLen ); 377cdf0e10cSrcweir } 378cdf0e10cSrcweir } 379cdf0e10cSrcweir } 380cdf0e10cSrcweir delete[] pTempBuf; 381cdf0e10cSrcweir } 382cdf0e10cSrcweir /* 383cdf0e10cSrcweir else 384cdf0e10cSrcweir { 385cdf0e10cSrcweir } 386cdf0e10cSrcweir */ 387cdf0e10cSrcweir 388cdf0e10cSrcweir return rIStream; 389cdf0e10cSrcweir } 390cdf0e10cSrcweir 391cdf0e10cSrcweir // ----------------------------------------------------------------------- 392cdf0e10cSrcweir 393cdf0e10cSrcweir SvStream& operator<<( SvStream& rOStream, const JobSetup& rJobSetup ) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir DBG_ASSERTWARNING( rOStream.GetVersion(), "JobSetup::<< - Solar-Version not set on rOStream" ); 396cdf0e10cSrcweir 397cdf0e10cSrcweir // Zur Zeit haben wir noch kein neues FileFormat 398cdf0e10cSrcweir // if ( rOStream.GetVersion() < JOBSET_FILEFORMAT2 ) 399cdf0e10cSrcweir { 400cdf0e10cSrcweir sal_uInt16 nLen = 0; 401cdf0e10cSrcweir if ( !rJobSetup.mpData ) 402cdf0e10cSrcweir rOStream << nLen; 403cdf0e10cSrcweir else 404cdf0e10cSrcweir { 405cdf0e10cSrcweir sal_uInt16 nSystem = JOBSET_FILE605_SYSTEM; 406cdf0e10cSrcweir 407cdf0e10cSrcweir const ImplJobSetup* pJobData = rJobSetup.ImplGetConstData(); 408cdf0e10cSrcweir Impl364JobSetupData aOldJobData; 409cdf0e10cSrcweir sal_uInt16 nOldJobDataSize = sizeof( aOldJobData ); 410cdf0e10cSrcweir ShortToSVBT16( nOldJobDataSize, aOldJobData.nSize ); 411cdf0e10cSrcweir ShortToSVBT16( pJobData->mnSystem, aOldJobData.nSystem ); 412cdf0e10cSrcweir UInt32ToSVBT32( pJobData->mnDriverDataLen, aOldJobData.nDriverDataLen ); 413cdf0e10cSrcweir ShortToSVBT16( (sal_uInt16)(pJobData->meOrientation), aOldJobData.nOrientation ); 414cdf0e10cSrcweir ShortToSVBT16( pJobData->mnPaperBin, aOldJobData.nPaperBin ); 415cdf0e10cSrcweir ShortToSVBT16( (sal_uInt16)(pJobData->mePaperFormat), aOldJobData.nPaperFormat ); 416cdf0e10cSrcweir UInt32ToSVBT32( (sal_uLong)(pJobData->mnPaperWidth), aOldJobData.nPaperWidth ); 417cdf0e10cSrcweir UInt32ToSVBT32( (sal_uLong)(pJobData->mnPaperHeight), aOldJobData.nPaperHeight ); 418cdf0e10cSrcweir 419cdf0e10cSrcweir ImplOldJobSetupData aOldData; 420cdf0e10cSrcweir memset( &aOldData, 0, sizeof( aOldData ) ); 421cdf0e10cSrcweir ByteString aPrnByteName( rJobSetup.GetPrinterName(), RTL_TEXTENCODING_UTF8 ); 422cdf0e10cSrcweir strncpy( aOldData.cPrinterName, aPrnByteName.GetBuffer(), 63 ); 423cdf0e10cSrcweir ByteString aDriverByteName( rJobSetup.GetDriverName(), RTL_TEXTENCODING_UTF8 ); 424cdf0e10cSrcweir strncpy( aOldData.cDriverName, aDriverByteName.GetBuffer(), 31 ); 425cdf0e10cSrcweir // nLen = sizeof( aOldData ) + 4 + nOldJobDataSize + pJobData->mnDriverDataLen; 426cdf0e10cSrcweir int nPos = rOStream.Tell(); 427cdf0e10cSrcweir rOStream << nLen; 428cdf0e10cSrcweir rOStream << nSystem; 429cdf0e10cSrcweir rOStream.Write( (char*)&aOldData, sizeof( aOldData ) ); 430cdf0e10cSrcweir rOStream.Write( (char*)&aOldJobData, nOldJobDataSize ); 431cdf0e10cSrcweir rOStream.Write( (char*)pJobData->mpDriverData, pJobData->mnDriverDataLen ); 432cdf0e10cSrcweir ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash >::const_iterator it; 433cdf0e10cSrcweir for( it = pJobData->maValueMap.begin(); it != pJobData->maValueMap.end(); ++it ) 434cdf0e10cSrcweir { 435cdf0e10cSrcweir rOStream.WriteByteString( it->first, RTL_TEXTENCODING_UTF8 ); 436cdf0e10cSrcweir rOStream.WriteByteString( it->second, RTL_TEXTENCODING_UTF8 ); 437cdf0e10cSrcweir } 438cdf0e10cSrcweir rOStream.WriteByteString( "COMPAT_DUPLEX_MODE" ) ; 439cdf0e10cSrcweir switch( pJobData->meDuplexMode ) 440cdf0e10cSrcweir { 441cdf0e10cSrcweir case DUPLEX_UNKNOWN: rOStream.WriteByteString( "DUPLEX_UNKNOWN" );break; 442cdf0e10cSrcweir case DUPLEX_OFF: rOStream.WriteByteString( "DUPLEX_OFF" );break; 443cdf0e10cSrcweir case DUPLEX_SHORTEDGE: rOStream.WriteByteString( "DUPLEX_SHORTEDGE" );break; 444cdf0e10cSrcweir case DUPLEX_LONGEDGE: rOStream.WriteByteString( "DUPLEX_LONGEDGE" );break; 445cdf0e10cSrcweir } 446cdf0e10cSrcweir nLen = sal::static_int_cast<sal_uInt16>(rOStream.Tell() - nPos); 447cdf0e10cSrcweir rOStream.Seek( nPos ); 448cdf0e10cSrcweir rOStream << nLen; 449cdf0e10cSrcweir rOStream.Seek( nPos + nLen ); 450cdf0e10cSrcweir } 451cdf0e10cSrcweir } 452cdf0e10cSrcweir /* 453cdf0e10cSrcweir else 454cdf0e10cSrcweir { 455cdf0e10cSrcweir } 456cdf0e10cSrcweir */ 457cdf0e10cSrcweir 458cdf0e10cSrcweir return rOStream; 459cdf0e10cSrcweir } 460