1b0724fc6SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3b0724fc6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4b0724fc6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5b0724fc6SAndrew Rist * distributed with this work for additional information 6b0724fc6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7b0724fc6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8b0724fc6SAndrew Rist * "License"); you may not use this file except in compliance 9b0724fc6SAndrew Rist * with the License. You may obtain a copy of the License at 10b0724fc6SAndrew Rist * 11b0724fc6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12b0724fc6SAndrew Rist * 13b0724fc6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14b0724fc6SAndrew Rist * software distributed under the License is distributed on an 15b0724fc6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16b0724fc6SAndrew Rist * KIND, either express or implied. See the License for the 17b0724fc6SAndrew Rist * specific language governing permissions and limitations 18b0724fc6SAndrew Rist * under the License. 19b0724fc6SAndrew Rist * 20b0724fc6SAndrew Rist *************************************************************/ 21b0724fc6SAndrew Rist 22b0724fc6SAndrew Rist 23cdf0e10cSrcweir 24*05b7ab28SAriel Constenla-Haile // MARKER(update_precomp.py): autogen include statement, do not remove 25*05b7ab28SAriel Constenla-Haile #include "precompiled_toolkit.hxx" 26*05b7ab28SAriel Constenla-Haile 27*05b7ab28SAriel Constenla-Haile 28*05b7ab28SAriel Constenla-Haile #include <toolkit/awt/vclxprinter.hxx> 29*05b7ab28SAriel Constenla-Haile #include <toolkit/helper/macros.hxx> 30*05b7ab28SAriel Constenla-Haile #include <cppuhelper/typeprovider.hxx> 31*05b7ab28SAriel Constenla-Haile #include <rtl/memory.h> 32*05b7ab28SAriel Constenla-Haile #include <rtl/uuid.h> 33*05b7ab28SAriel Constenla-Haile 34*05b7ab28SAriel Constenla-Haile 35*05b7ab28SAriel Constenla-Haile #include <vcl/print.hxx> 36*05b7ab28SAriel Constenla-Haile #include <vcl/jobset.hxx> 37*05b7ab28SAriel Constenla-Haile #include <vcl/svapp.hxx> 38*05b7ab28SAriel Constenla-Haile 39*05b7ab28SAriel Constenla-Haile #include <tools/debug.hxx> 40*05b7ab28SAriel Constenla-Haile #include <tools/stream.hxx> 41*05b7ab28SAriel Constenla-Haile 42*05b7ab28SAriel Constenla-Haile #include <toolkit/awt/vclxdevice.hxx> 43*05b7ab28SAriel Constenla-Haile 44*05b7ab28SAriel Constenla-Haile 45*05b7ab28SAriel Constenla-Haile #define BINARYSETUPMARKER 0x23864691 46*05b7ab28SAriel Constenla-Haile 47*05b7ab28SAriel Constenla-Haile #define PROPERTY_Orientation 0 48*05b7ab28SAriel Constenla-Haile #define PROPERTY_Horizontal 1 49*05b7ab28SAriel Constenla-Haile 50*05b7ab28SAriel Constenla-Haile ::com::sun::star::beans::Property* ImplGetProperties( sal_uInt16& rElementCount ) 51*05b7ab28SAriel Constenla-Haile { 52*05b7ab28SAriel Constenla-Haile static ::com::sun::star::beans::Property* pProperties = NULL; 53*05b7ab28SAriel Constenla-Haile static sal_uInt16 nElements = 0; 54*05b7ab28SAriel Constenla-Haile if( !pProperties ) 55*05b7ab28SAriel Constenla-Haile { 56*05b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ); 57*05b7ab28SAriel Constenla-Haile if( !pProperties ) 58*05b7ab28SAriel Constenla-Haile { 59*05b7ab28SAriel Constenla-Haile static ::com::sun::star::beans::Property __FAR_DATA aPropTable[] = 60*05b7ab28SAriel Constenla-Haile { 61*05b7ab28SAriel Constenla-Haile ::com::sun::star::beans::Property( ::rtl::OUString::createFromAscii( "Orientation" ), PROPERTY_Orientation, ::getCppuType((const sal_Int16*)0), 0 ), 62*05b7ab28SAriel Constenla-Haile ::com::sun::star::beans::Property( ::rtl::OUString::createFromAscii( "Horizontal" ), PROPERTY_Horizontal, ::getBooleanCppuType(), 0 ) 63*05b7ab28SAriel Constenla-Haile }; 64*05b7ab28SAriel Constenla-Haile pProperties = aPropTable; 65*05b7ab28SAriel Constenla-Haile nElements = sizeof( aPropTable ) / sizeof( ::com::sun::star::beans::Property ); 66*05b7ab28SAriel Constenla-Haile } 67*05b7ab28SAriel Constenla-Haile } 68*05b7ab28SAriel Constenla-Haile rElementCount = nElements; 69*05b7ab28SAriel Constenla-Haile return pProperties; 70*05b7ab28SAriel Constenla-Haile } 71*05b7ab28SAriel Constenla-Haile 72*05b7ab28SAriel Constenla-Haile // ---------------------------------------------------- 73*05b7ab28SAriel Constenla-Haile // class VCLXPrinterPropertySet 74*05b7ab28SAriel Constenla-Haile // ---------------------------------------------------- 75*05b7ab28SAriel Constenla-Haile 76*05b7ab28SAriel Constenla-Haile IMPLEMENT_FORWARD_XINTERFACE2( VCLXPrinterPropertySet, VCLXPrinterPropertySet_Base, OPropertySetHelper ) 77*05b7ab28SAriel Constenla-Haile IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXPrinterPropertySet, VCLXPrinterPropertySet_Base, ::cppu::OPropertySetHelper ) 78*05b7ab28SAriel Constenla-Haile 79*05b7ab28SAriel Constenla-Haile VCLXPrinterPropertySet::VCLXPrinterPropertySet( const String& rPrinterName ) 80*05b7ab28SAriel Constenla-Haile : OPropertySetHelper( BrdcstHelper ) 81*05b7ab28SAriel Constenla-Haile , mpPrinter( new Printer( rPrinterName ) ) 82*05b7ab28SAriel Constenla-Haile { 83*05b7ab28SAriel Constenla-Haile osl::Guard< vos::IMutex > aSolarGuard( Application::GetSolarMutex() ); 84*05b7ab28SAriel Constenla-Haile 85*05b7ab28SAriel Constenla-Haile mnOrientation = 0; 86*05b7ab28SAriel Constenla-Haile mbHorizontal = sal_False; 87*05b7ab28SAriel Constenla-Haile } 88*05b7ab28SAriel Constenla-Haile 89*05b7ab28SAriel Constenla-Haile VCLXPrinterPropertySet::~VCLXPrinterPropertySet() 90*05b7ab28SAriel Constenla-Haile { 91*05b7ab28SAriel Constenla-Haile osl::Guard< vos::IMutex > aSolarGuard( Application::GetSolarMutex() ); 92*05b7ab28SAriel Constenla-Haile mpPrinter.reset(); 93*05b7ab28SAriel Constenla-Haile } 94*05b7ab28SAriel Constenla-Haile 95*05b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXPrinterPropertySet::GetDevice() 96*05b7ab28SAriel Constenla-Haile { 97*05b7ab28SAriel Constenla-Haile if ( !mxPrnDevice.is() ) 98*05b7ab28SAriel Constenla-Haile { 99*05b7ab28SAriel Constenla-Haile VCLXDevice* pDev = new VCLXDevice; 100*05b7ab28SAriel Constenla-Haile pDev->SetOutputDevice( GetPrinter() ); 101*05b7ab28SAriel Constenla-Haile mxPrnDevice = pDev; 102*05b7ab28SAriel Constenla-Haile } 103*05b7ab28SAriel Constenla-Haile return mxPrnDevice; 104*05b7ab28SAriel Constenla-Haile } 105*05b7ab28SAriel Constenla-Haile 106*05b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > VCLXPrinterPropertySet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) 107*05b7ab28SAriel Constenla-Haile { 108*05b7ab28SAriel Constenla-Haile static ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) ); 109*05b7ab28SAriel Constenla-Haile return xInfo; 110*05b7ab28SAriel Constenla-Haile } 111*05b7ab28SAriel Constenla-Haile 112*05b7ab28SAriel Constenla-Haile ::cppu::IPropertyArrayHelper& VCLXPrinterPropertySet::getInfoHelper() 113*05b7ab28SAriel Constenla-Haile { 114*05b7ab28SAriel Constenla-Haile static ::cppu::OPropertyArrayHelper* pPropertyArrayHelper = NULL; 115*05b7ab28SAriel Constenla-Haile if ( !pPropertyArrayHelper ) 116*05b7ab28SAriel Constenla-Haile { 117*05b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() ); 118*05b7ab28SAriel Constenla-Haile if( !pPropertyArrayHelper ) 119*05b7ab28SAriel Constenla-Haile { 120*05b7ab28SAriel Constenla-Haile sal_uInt16 nElements; 121*05b7ab28SAriel Constenla-Haile ::com::sun::star::beans::Property* pProps = ImplGetProperties( nElements ); 122*05b7ab28SAriel Constenla-Haile pPropertyArrayHelper = new ::cppu::OPropertyArrayHelper( pProps, nElements, sal_False ); 123*05b7ab28SAriel Constenla-Haile } 124*05b7ab28SAriel Constenla-Haile } 125*05b7ab28SAriel Constenla-Haile return *pPropertyArrayHelper ; 126*05b7ab28SAriel Constenla-Haile } 127*05b7ab28SAriel Constenla-Haile 128*05b7ab28SAriel Constenla-Haile sal_Bool VCLXPrinterPropertySet::convertFastPropertyValue( ::com::sun::star::uno::Any & rConvertedValue, ::com::sun::star::uno::Any & rOldValue, sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::lang::IllegalArgumentException) 129*05b7ab28SAriel Constenla-Haile { 130*05b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); 131*05b7ab28SAriel Constenla-Haile 132*05b7ab28SAriel Constenla-Haile sal_Bool bDifferent = sal_False; 133*05b7ab28SAriel Constenla-Haile switch ( nHandle ) 134*05b7ab28SAriel Constenla-Haile { 135*05b7ab28SAriel Constenla-Haile case PROPERTY_Orientation: 136*05b7ab28SAriel Constenla-Haile { 137*05b7ab28SAriel Constenla-Haile sal_Int16 n; 138*05b7ab28SAriel Constenla-Haile if( ( rValue >>= n ) && ( n != mnOrientation ) ) 139*05b7ab28SAriel Constenla-Haile { 140*05b7ab28SAriel Constenla-Haile rConvertedValue <<= n; 141*05b7ab28SAriel Constenla-Haile rOldValue <<= mnOrientation; 142*05b7ab28SAriel Constenla-Haile bDifferent = sal_True; 143*05b7ab28SAriel Constenla-Haile } 144*05b7ab28SAriel Constenla-Haile } 145*05b7ab28SAriel Constenla-Haile break; 146*05b7ab28SAriel Constenla-Haile case PROPERTY_Horizontal: 147*05b7ab28SAriel Constenla-Haile { 148*05b7ab28SAriel Constenla-Haile sal_Bool b; 149*05b7ab28SAriel Constenla-Haile if( ( rValue >>= b ) && ( b != mbHorizontal ) ) 150*05b7ab28SAriel Constenla-Haile { 151*05b7ab28SAriel Constenla-Haile rConvertedValue <<= b; 152*05b7ab28SAriel Constenla-Haile rOldValue <<= mbHorizontal; 153*05b7ab28SAriel Constenla-Haile bDifferent = sal_True; 154*05b7ab28SAriel Constenla-Haile } 155*05b7ab28SAriel Constenla-Haile } 156*05b7ab28SAriel Constenla-Haile break; 157*05b7ab28SAriel Constenla-Haile default: 158*05b7ab28SAriel Constenla-Haile { 159*05b7ab28SAriel Constenla-Haile DBG_ERROR( "VCLXPrinterPropertySet_Impl::convertFastPropertyValue - invalid Handle" ); 160*05b7ab28SAriel Constenla-Haile } 161*05b7ab28SAriel Constenla-Haile } 162*05b7ab28SAriel Constenla-Haile return bDifferent; 163*05b7ab28SAriel Constenla-Haile } 164*05b7ab28SAriel Constenla-Haile 165*05b7ab28SAriel Constenla-Haile void VCLXPrinterPropertySet::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception) 166*05b7ab28SAriel Constenla-Haile { 167*05b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); 168*05b7ab28SAriel Constenla-Haile 169*05b7ab28SAriel Constenla-Haile switch( nHandle ) 170*05b7ab28SAriel Constenla-Haile { 171*05b7ab28SAriel Constenla-Haile case PROPERTY_Orientation: 172*05b7ab28SAriel Constenla-Haile { 173*05b7ab28SAriel Constenla-Haile rValue >>= mnOrientation; 174*05b7ab28SAriel Constenla-Haile } 175*05b7ab28SAriel Constenla-Haile break; 176*05b7ab28SAriel Constenla-Haile case PROPERTY_Horizontal: 177*05b7ab28SAriel Constenla-Haile { 178*05b7ab28SAriel Constenla-Haile rValue >>= mbHorizontal; 179*05b7ab28SAriel Constenla-Haile } 180*05b7ab28SAriel Constenla-Haile break; 181*05b7ab28SAriel Constenla-Haile default: 182*05b7ab28SAriel Constenla-Haile { 183*05b7ab28SAriel Constenla-Haile DBG_ERROR( "VCLXPrinterPropertySet_Impl::convertFastPropertyValue - invalid Handle" ); 184*05b7ab28SAriel Constenla-Haile } 185*05b7ab28SAriel Constenla-Haile } 186*05b7ab28SAriel Constenla-Haile } 187*05b7ab28SAriel Constenla-Haile 188*05b7ab28SAriel Constenla-Haile void VCLXPrinterPropertySet::getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const 189*05b7ab28SAriel Constenla-Haile { 190*05b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( ((VCLXPrinterPropertySet*)this)->Mutex ); 191*05b7ab28SAriel Constenla-Haile 192*05b7ab28SAriel Constenla-Haile switch( nHandle ) 193*05b7ab28SAriel Constenla-Haile { 194*05b7ab28SAriel Constenla-Haile case PROPERTY_Orientation: 195*05b7ab28SAriel Constenla-Haile rValue <<= mnOrientation; 196*05b7ab28SAriel Constenla-Haile break; 197*05b7ab28SAriel Constenla-Haile case PROPERTY_Horizontal: 198*05b7ab28SAriel Constenla-Haile rValue <<= mbHorizontal; 199*05b7ab28SAriel Constenla-Haile break; 200*05b7ab28SAriel Constenla-Haile default: 201*05b7ab28SAriel Constenla-Haile { 202*05b7ab28SAriel Constenla-Haile DBG_ERROR( "VCLXPrinterPropertySet_Impl::convertFastPropertyValue - invalid Handle" ); 203*05b7ab28SAriel Constenla-Haile } 204*05b7ab28SAriel Constenla-Haile } 205*05b7ab28SAriel Constenla-Haile } 206*05b7ab28SAriel Constenla-Haile 207*05b7ab28SAriel Constenla-Haile // ::com::sun::star::awt::XPrinterPropertySet 208*05b7ab28SAriel Constenla-Haile void VCLXPrinterPropertySet::setHorizontal( sal_Bool bHorizontal ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 209*05b7ab28SAriel Constenla-Haile { 210*05b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); 211*05b7ab28SAriel Constenla-Haile 212*05b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Any aValue; 213*05b7ab28SAriel Constenla-Haile aValue <<= bHorizontal; 214*05b7ab28SAriel Constenla-Haile setFastPropertyValue( PROPERTY_Horizontal, aValue ); 215*05b7ab28SAriel Constenla-Haile } 216*05b7ab28SAriel Constenla-Haile 217*05b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Sequence< ::rtl::OUString > VCLXPrinterPropertySet::getFormDescriptions( ) throw(::com::sun::star::uno::RuntimeException) 218*05b7ab28SAriel Constenla-Haile { 219*05b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); 220*05b7ab28SAriel Constenla-Haile 221*05b7ab28SAriel Constenla-Haile sal_uInt16 nPaperBinCount = GetPrinter()->GetPaperBinCount(); 222*05b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Sequence< ::rtl::OUString > aDescriptions( nPaperBinCount ); 223*05b7ab28SAriel Constenla-Haile for ( sal_uInt16 n = 0; n < nPaperBinCount; n++ ) 224*05b7ab28SAriel Constenla-Haile { 225*05b7ab28SAriel Constenla-Haile // Format: <DisplayFormName;FormNameId;DisplayPaperBinName;PaperBinNameId;DisplayPaperName;PaperNameId> 226*05b7ab28SAriel Constenla-Haile String aDescr( RTL_CONSTASCII_USTRINGPARAM( "*;*;" ) ); 227*05b7ab28SAriel Constenla-Haile aDescr += GetPrinter()->GetPaperBinName( n ); 228*05b7ab28SAriel Constenla-Haile aDescr += ';'; 229*05b7ab28SAriel Constenla-Haile aDescr += n; 230*05b7ab28SAriel Constenla-Haile aDescr.AppendAscii( ";*;*", 4 ); 231*05b7ab28SAriel Constenla-Haile 232*05b7ab28SAriel Constenla-Haile aDescriptions.getArray()[n] = aDescr; 233*05b7ab28SAriel Constenla-Haile } 234*05b7ab28SAriel Constenla-Haile return aDescriptions; 235*05b7ab28SAriel Constenla-Haile } 236*05b7ab28SAriel Constenla-Haile 237*05b7ab28SAriel Constenla-Haile void VCLXPrinterPropertySet::selectForm( const ::rtl::OUString& rFormDescription ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 238*05b7ab28SAriel Constenla-Haile { 239*05b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); 240*05b7ab28SAriel Constenla-Haile 241*05b7ab28SAriel Constenla-Haile sal_Int32 nIndex = 0; 242*05b7ab28SAriel Constenla-Haile sal_uInt16 nPaperBin = sal::static_int_cast< sal_uInt16 >( 243*05b7ab28SAriel Constenla-Haile rFormDescription.getToken( 3, ';', nIndex ).toInt32()); 244*05b7ab28SAriel Constenla-Haile GetPrinter()->SetPaperBin( nPaperBin ); 245*05b7ab28SAriel Constenla-Haile } 246*05b7ab28SAriel Constenla-Haile 247*05b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Sequence< sal_Int8 > VCLXPrinterPropertySet::getBinarySetup( ) throw(::com::sun::star::uno::RuntimeException) 248*05b7ab28SAriel Constenla-Haile { 249*05b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); 250*05b7ab28SAriel Constenla-Haile 251*05b7ab28SAriel Constenla-Haile SvMemoryStream aMem; 252*05b7ab28SAriel Constenla-Haile aMem << BINARYSETUPMARKER; 253*05b7ab28SAriel Constenla-Haile aMem << GetPrinter()->GetJobSetup(); 254*05b7ab28SAriel Constenla-Haile return ::com::sun::star::uno::Sequence<sal_Int8>( (sal_Int8*) aMem.GetData(), aMem.Tell() ); 255*05b7ab28SAriel Constenla-Haile } 256*05b7ab28SAriel Constenla-Haile 257*05b7ab28SAriel Constenla-Haile void VCLXPrinterPropertySet::setBinarySetup( const ::com::sun::star::uno::Sequence< sal_Int8 >& data ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 258*05b7ab28SAriel Constenla-Haile { 259*05b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); 260*05b7ab28SAriel Constenla-Haile 261*05b7ab28SAriel Constenla-Haile SvMemoryStream aMem( (char*) data.getConstArray(), data.getLength(), STREAM_READ ); 262*05b7ab28SAriel Constenla-Haile sal_uInt32 nMarker; 263*05b7ab28SAriel Constenla-Haile aMem >> nMarker; 264*05b7ab28SAriel Constenla-Haile DBG_ASSERT( nMarker == BINARYSETUPMARKER, "setBinarySetup - invalid!" ); 265*05b7ab28SAriel Constenla-Haile if ( nMarker == BINARYSETUPMARKER ) 266*05b7ab28SAriel Constenla-Haile { 267*05b7ab28SAriel Constenla-Haile JobSetup aSetup; 268*05b7ab28SAriel Constenla-Haile aMem >> aSetup; 269*05b7ab28SAriel Constenla-Haile GetPrinter()->SetJobSetup( aSetup ); 270*05b7ab28SAriel Constenla-Haile } 271*05b7ab28SAriel Constenla-Haile } 272*05b7ab28SAriel Constenla-Haile 273*05b7ab28SAriel Constenla-Haile 274*05b7ab28SAriel Constenla-Haile // ---------------------------------------------------- 275*05b7ab28SAriel Constenla-Haile // class VCLXPrinter 276*05b7ab28SAriel Constenla-Haile // ---------------------------------------------------- 277*05b7ab28SAriel Constenla-Haile VCLXPrinter::VCLXPrinter( const String& rPrinterName ) 278*05b7ab28SAriel Constenla-Haile : VCLXPrinter_Base( rPrinterName ) 279*05b7ab28SAriel Constenla-Haile { 280*05b7ab28SAriel Constenla-Haile } 281*05b7ab28SAriel Constenla-Haile 282*05b7ab28SAriel Constenla-Haile VCLXPrinter::~VCLXPrinter() 283*05b7ab28SAriel Constenla-Haile { 284*05b7ab28SAriel Constenla-Haile } 285*05b7ab28SAriel Constenla-Haile 286*05b7ab28SAriel Constenla-Haile sal_Bool VCLXPrinter::start( const ::rtl::OUString& /*rJobName*/, sal_Int16 /*nCopies*/, sal_Bool /*bCollate*/ ) throw(::com::sun::star::awt::PrinterException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) 287*05b7ab28SAriel Constenla-Haile { 288*05b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); 289*05b7ab28SAriel Constenla-Haile 290*05b7ab28SAriel Constenla-Haile sal_Bool bDone = sal_True; 291*05b7ab28SAriel Constenla-Haile if ( mpListener.get() ) 292*05b7ab28SAriel Constenla-Haile { 293*05b7ab28SAriel Constenla-Haile maInitJobSetup = mpPrinter->GetJobSetup(); 294*05b7ab28SAriel Constenla-Haile mpListener.reset( new vcl::OldStylePrintAdaptor( mpPrinter ) ); 295*05b7ab28SAriel Constenla-Haile } 296*05b7ab28SAriel Constenla-Haile 297*05b7ab28SAriel Constenla-Haile return bDone; 298*05b7ab28SAriel Constenla-Haile } 299*05b7ab28SAriel Constenla-Haile 300*05b7ab28SAriel Constenla-Haile void VCLXPrinter::end( ) throw(::com::sun::star::awt::PrinterException, ::com::sun::star::uno::RuntimeException) 301*05b7ab28SAriel Constenla-Haile { 302*05b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); 303*05b7ab28SAriel Constenla-Haile 304*05b7ab28SAriel Constenla-Haile if ( mpListener.get() ) 305*05b7ab28SAriel Constenla-Haile { 306*05b7ab28SAriel Constenla-Haile Printer::PrintJob( mpListener, maInitJobSetup ); 307*05b7ab28SAriel Constenla-Haile mpListener.reset(); 308*05b7ab28SAriel Constenla-Haile } 309*05b7ab28SAriel Constenla-Haile } 310*05b7ab28SAriel Constenla-Haile 311*05b7ab28SAriel Constenla-Haile void VCLXPrinter::terminate( ) throw(::com::sun::star::uno::RuntimeException) 312*05b7ab28SAriel Constenla-Haile { 313*05b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); 314*05b7ab28SAriel Constenla-Haile 315*05b7ab28SAriel Constenla-Haile mpListener.reset(); 316*05b7ab28SAriel Constenla-Haile } 317*05b7ab28SAriel Constenla-Haile 318*05b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXPrinter::startPage( ) throw(::com::sun::star::awt::PrinterException, ::com::sun::star::uno::RuntimeException) 319*05b7ab28SAriel Constenla-Haile { 320*05b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); 321*05b7ab28SAriel Constenla-Haile 322*05b7ab28SAriel Constenla-Haile if ( mpListener.get() ) 323*05b7ab28SAriel Constenla-Haile { 324*05b7ab28SAriel Constenla-Haile mpListener->StartPage(); 325*05b7ab28SAriel Constenla-Haile } 326*05b7ab28SAriel Constenla-Haile return GetDevice(); 327*05b7ab28SAriel Constenla-Haile } 328*05b7ab28SAriel Constenla-Haile 329*05b7ab28SAriel Constenla-Haile void VCLXPrinter::endPage( ) throw(::com::sun::star::awt::PrinterException, ::com::sun::star::uno::RuntimeException) 330*05b7ab28SAriel Constenla-Haile { 331*05b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); 332*05b7ab28SAriel Constenla-Haile 333*05b7ab28SAriel Constenla-Haile if ( mpListener.get() ) 334*05b7ab28SAriel Constenla-Haile { 335*05b7ab28SAriel Constenla-Haile mpListener->EndPage(); 336*05b7ab28SAriel Constenla-Haile } 337*05b7ab28SAriel Constenla-Haile } 338*05b7ab28SAriel Constenla-Haile 339*05b7ab28SAriel Constenla-Haile 340*05b7ab28SAriel Constenla-Haile // ---------------------------------------------------- 341*05b7ab28SAriel Constenla-Haile // class VCLXInfoPrinter 342*05b7ab28SAriel Constenla-Haile // ---------------------------------------------------- 343*05b7ab28SAriel Constenla-Haile 344*05b7ab28SAriel Constenla-Haile VCLXInfoPrinter::VCLXInfoPrinter( const String& rPrinterName ) 345*05b7ab28SAriel Constenla-Haile : VCLXInfoPrinter_Base( rPrinterName ) 346*05b7ab28SAriel Constenla-Haile { 347*05b7ab28SAriel Constenla-Haile } 348*05b7ab28SAriel Constenla-Haile 349*05b7ab28SAriel Constenla-Haile VCLXInfoPrinter::~VCLXInfoPrinter() 350*05b7ab28SAriel Constenla-Haile { 351*05b7ab28SAriel Constenla-Haile } 352*05b7ab28SAriel Constenla-Haile 353*05b7ab28SAriel Constenla-Haile // ::com::sun::star::awt::XInfoPrinter 354*05b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXInfoPrinter::createDevice( ) throw(::com::sun::star::uno::RuntimeException) 355*05b7ab28SAriel Constenla-Haile { 356*05b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex ); 357*05b7ab28SAriel Constenla-Haile 358*05b7ab28SAriel Constenla-Haile return GetDevice(); 359*05b7ab28SAriel Constenla-Haile } 360*05b7ab28SAriel Constenla-Haile 361*05b7ab28SAriel Constenla-Haile // ---------------------------------------------------- 362*05b7ab28SAriel Constenla-Haile // class VCLXPrinterServer 363*05b7ab28SAriel Constenla-Haile // ---------------------------------------------------- 364*05b7ab28SAriel Constenla-Haile 365*05b7ab28SAriel Constenla-Haile // ::com::sun::star::awt::XPrinterServer 366*05b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Sequence< ::rtl::OUString > VCLXPrinterServer::getPrinterNames( ) throw(::com::sun::star::uno::RuntimeException) 367*05b7ab28SAriel Constenla-Haile { 368*05b7ab28SAriel Constenla-Haile const std::vector<rtl::OUString>& rQueues = Printer::GetPrinterQueues(); 369*05b7ab28SAriel Constenla-Haile sal_uInt32 nPrinters = rQueues.size(); 370*05b7ab28SAriel Constenla-Haile 371*05b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Sequence< ::rtl::OUString > aNames( nPrinters ); 372*05b7ab28SAriel Constenla-Haile for ( sal_uInt32 n = 0; n < nPrinters; n++ ) 373*05b7ab28SAriel Constenla-Haile aNames.getArray()[n] = rQueues[n]; 374*05b7ab28SAriel Constenla-Haile 375*05b7ab28SAriel Constenla-Haile return aNames; 376*05b7ab28SAriel Constenla-Haile } 377*05b7ab28SAriel Constenla-Haile 378*05b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPrinter > VCLXPrinterServer::createPrinter( const ::rtl::OUString& rPrinterName ) throw(::com::sun::star::uno::RuntimeException) 379*05b7ab28SAriel Constenla-Haile { 380*05b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPrinter > xP; 381*05b7ab28SAriel Constenla-Haile xP = new VCLXPrinter( rPrinterName ); 382*05b7ab28SAriel Constenla-Haile return xP; 383*05b7ab28SAriel Constenla-Haile } 384*05b7ab28SAriel Constenla-Haile 385*05b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Reference< ::com::sun::star::awt::XInfoPrinter > VCLXPrinterServer::createInfoPrinter( const ::rtl::OUString& rPrinterName ) throw(::com::sun::star::uno::RuntimeException) 386*05b7ab28SAriel Constenla-Haile { 387*05b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Reference< ::com::sun::star::awt::XInfoPrinter > xP; 388*05b7ab28SAriel Constenla-Haile xP = new VCLXInfoPrinter( rPrinterName ); 389*05b7ab28SAriel Constenla-Haile return xP; 390*05b7ab28SAriel Constenla-Haile } 391*05b7ab28SAriel Constenla-Haile 392*05b7ab28SAriel Constenla-Haile 393