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