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
2405b7ab28SAriel Constenla-Haile // MARKER(update_precomp.py): autogen include statement, do not remove
2505b7ab28SAriel Constenla-Haile #include "precompiled_toolkit.hxx"
2605b7ab28SAriel Constenla-Haile
2705b7ab28SAriel Constenla-Haile
2805b7ab28SAriel Constenla-Haile #include <toolkit/awt/vclxprinter.hxx>
2905b7ab28SAriel Constenla-Haile #include <toolkit/helper/macros.hxx>
3005b7ab28SAriel Constenla-Haile #include <cppuhelper/typeprovider.hxx>
3105b7ab28SAriel Constenla-Haile #include <rtl/memory.h>
3205b7ab28SAriel Constenla-Haile #include <rtl/uuid.h>
3305b7ab28SAriel Constenla-Haile
3405b7ab28SAriel Constenla-Haile
3505b7ab28SAriel Constenla-Haile #include <vcl/print.hxx>
3605b7ab28SAriel Constenla-Haile #include <vcl/jobset.hxx>
3705b7ab28SAriel Constenla-Haile #include <vcl/svapp.hxx>
3805b7ab28SAriel Constenla-Haile
3905b7ab28SAriel Constenla-Haile #include <tools/debug.hxx>
4005b7ab28SAriel Constenla-Haile #include <tools/stream.hxx>
4105b7ab28SAriel Constenla-Haile
4205b7ab28SAriel Constenla-Haile #include <toolkit/awt/vclxdevice.hxx>
4305b7ab28SAriel Constenla-Haile
4405b7ab28SAriel Constenla-Haile
4505b7ab28SAriel Constenla-Haile #define BINARYSETUPMARKER 0x23864691
4605b7ab28SAriel Constenla-Haile
4705b7ab28SAriel Constenla-Haile #define PROPERTY_Orientation 0
4805b7ab28SAriel Constenla-Haile #define PROPERTY_Horizontal 1
4905b7ab28SAriel Constenla-Haile
ImplGetProperties(sal_uInt16 & rElementCount)5005b7ab28SAriel Constenla-Haile ::com::sun::star::beans::Property* ImplGetProperties( sal_uInt16& rElementCount )
5105b7ab28SAriel Constenla-Haile {
5205b7ab28SAriel Constenla-Haile static ::com::sun::star::beans::Property* pProperties = NULL;
5305b7ab28SAriel Constenla-Haile static sal_uInt16 nElements = 0;
5405b7ab28SAriel Constenla-Haile if( !pProperties )
5505b7ab28SAriel Constenla-Haile {
5605b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() );
5705b7ab28SAriel Constenla-Haile if( !pProperties )
5805b7ab28SAriel Constenla-Haile {
5905b7ab28SAriel Constenla-Haile static ::com::sun::star::beans::Property __FAR_DATA aPropTable[] =
6005b7ab28SAriel Constenla-Haile {
6105b7ab28SAriel Constenla-Haile ::com::sun::star::beans::Property( ::rtl::OUString::createFromAscii( "Orientation" ), PROPERTY_Orientation, ::getCppuType((const sal_Int16*)0), 0 ),
6205b7ab28SAriel Constenla-Haile ::com::sun::star::beans::Property( ::rtl::OUString::createFromAscii( "Horizontal" ), PROPERTY_Horizontal, ::getBooleanCppuType(), 0 )
6305b7ab28SAriel Constenla-Haile };
6405b7ab28SAriel Constenla-Haile pProperties = aPropTable;
6505b7ab28SAriel Constenla-Haile nElements = sizeof( aPropTable ) / sizeof( ::com::sun::star::beans::Property );
6605b7ab28SAriel Constenla-Haile }
6705b7ab28SAriel Constenla-Haile }
6805b7ab28SAriel Constenla-Haile rElementCount = nElements;
6905b7ab28SAriel Constenla-Haile return pProperties;
7005b7ab28SAriel Constenla-Haile }
7105b7ab28SAriel Constenla-Haile
7205b7ab28SAriel Constenla-Haile // ----------------------------------------------------
7305b7ab28SAriel Constenla-Haile // class VCLXPrinterPropertySet
7405b7ab28SAriel Constenla-Haile // ----------------------------------------------------
7505b7ab28SAriel Constenla-Haile
IMPLEMENT_FORWARD_XINTERFACE2(VCLXPrinterPropertySet,VCLXPrinterPropertySet_Base,OPropertySetHelper)7605b7ab28SAriel Constenla-Haile IMPLEMENT_FORWARD_XINTERFACE2( VCLXPrinterPropertySet, VCLXPrinterPropertySet_Base, OPropertySetHelper )
7705b7ab28SAriel Constenla-Haile IMPLEMENT_FORWARD_XTYPEPROVIDER2( VCLXPrinterPropertySet, VCLXPrinterPropertySet_Base, ::cppu::OPropertySetHelper )
7805b7ab28SAriel Constenla-Haile
7905b7ab28SAriel Constenla-Haile VCLXPrinterPropertySet::VCLXPrinterPropertySet( const String& rPrinterName )
8005b7ab28SAriel Constenla-Haile : OPropertySetHelper( BrdcstHelper )
8105b7ab28SAriel Constenla-Haile , mpPrinter( new Printer( rPrinterName ) )
8205b7ab28SAriel Constenla-Haile {
8305b7ab28SAriel Constenla-Haile osl::Guard< vos::IMutex > aSolarGuard( Application::GetSolarMutex() );
8405b7ab28SAriel Constenla-Haile
8505b7ab28SAriel Constenla-Haile mnOrientation = 0;
8605b7ab28SAriel Constenla-Haile mbHorizontal = sal_False;
8705b7ab28SAriel Constenla-Haile }
8805b7ab28SAriel Constenla-Haile
~VCLXPrinterPropertySet()8905b7ab28SAriel Constenla-Haile VCLXPrinterPropertySet::~VCLXPrinterPropertySet()
9005b7ab28SAriel Constenla-Haile {
9105b7ab28SAriel Constenla-Haile osl::Guard< vos::IMutex > aSolarGuard( Application::GetSolarMutex() );
9205b7ab28SAriel Constenla-Haile mpPrinter.reset();
9305b7ab28SAriel Constenla-Haile }
9405b7ab28SAriel Constenla-Haile
GetDevice()9505b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXPrinterPropertySet::GetDevice()
9605b7ab28SAriel Constenla-Haile {
9705b7ab28SAriel Constenla-Haile if ( !mxPrnDevice.is() )
9805b7ab28SAriel Constenla-Haile {
9905b7ab28SAriel Constenla-Haile VCLXDevice* pDev = new VCLXDevice;
10005b7ab28SAriel Constenla-Haile pDev->SetOutputDevice( GetPrinter() );
10105b7ab28SAriel Constenla-Haile mxPrnDevice = pDev;
10205b7ab28SAriel Constenla-Haile }
10305b7ab28SAriel Constenla-Haile return mxPrnDevice;
10405b7ab28SAriel Constenla-Haile }
10505b7ab28SAriel Constenla-Haile
getPropertySetInfo()10605b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > VCLXPrinterPropertySet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
10705b7ab28SAriel Constenla-Haile {
10805b7ab28SAriel Constenla-Haile static ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > xInfo( createPropertySetInfo( getInfoHelper() ) );
10905b7ab28SAriel Constenla-Haile return xInfo;
11005b7ab28SAriel Constenla-Haile }
11105b7ab28SAriel Constenla-Haile
getInfoHelper()11205b7ab28SAriel Constenla-Haile ::cppu::IPropertyArrayHelper& VCLXPrinterPropertySet::getInfoHelper()
11305b7ab28SAriel Constenla-Haile {
11405b7ab28SAriel Constenla-Haile static ::cppu::OPropertyArrayHelper* pPropertyArrayHelper = NULL;
11505b7ab28SAriel Constenla-Haile if ( !pPropertyArrayHelper )
11605b7ab28SAriel Constenla-Haile {
11705b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() );
11805b7ab28SAriel Constenla-Haile if( !pPropertyArrayHelper )
11905b7ab28SAriel Constenla-Haile {
12005b7ab28SAriel Constenla-Haile sal_uInt16 nElements;
12105b7ab28SAriel Constenla-Haile ::com::sun::star::beans::Property* pProps = ImplGetProperties( nElements );
12205b7ab28SAriel Constenla-Haile pPropertyArrayHelper = new ::cppu::OPropertyArrayHelper( pProps, nElements, sal_False );
12305b7ab28SAriel Constenla-Haile }
12405b7ab28SAriel Constenla-Haile }
12505b7ab28SAriel Constenla-Haile return *pPropertyArrayHelper ;
12605b7ab28SAriel Constenla-Haile }
12705b7ab28SAriel Constenla-Haile
convertFastPropertyValue(::com::sun::star::uno::Any & rConvertedValue,::com::sun::star::uno::Any & rOldValue,sal_Int32 nHandle,const::com::sun::star::uno::Any & rValue)12805b7ab28SAriel 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)
12905b7ab28SAriel Constenla-Haile {
13005b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex );
13105b7ab28SAriel Constenla-Haile
13205b7ab28SAriel Constenla-Haile sal_Bool bDifferent = sal_False;
13305b7ab28SAriel Constenla-Haile switch ( nHandle )
13405b7ab28SAriel Constenla-Haile {
13505b7ab28SAriel Constenla-Haile case PROPERTY_Orientation:
13605b7ab28SAriel Constenla-Haile {
13705b7ab28SAriel Constenla-Haile sal_Int16 n;
13805b7ab28SAriel Constenla-Haile if( ( rValue >>= n ) && ( n != mnOrientation ) )
13905b7ab28SAriel Constenla-Haile {
14005b7ab28SAriel Constenla-Haile rConvertedValue <<= n;
14105b7ab28SAriel Constenla-Haile rOldValue <<= mnOrientation;
14205b7ab28SAriel Constenla-Haile bDifferent = sal_True;
14305b7ab28SAriel Constenla-Haile }
14405b7ab28SAriel Constenla-Haile }
14505b7ab28SAriel Constenla-Haile break;
14605b7ab28SAriel Constenla-Haile case PROPERTY_Horizontal:
14705b7ab28SAriel Constenla-Haile {
14805b7ab28SAriel Constenla-Haile sal_Bool b;
14905b7ab28SAriel Constenla-Haile if( ( rValue >>= b ) && ( b != mbHorizontal ) )
15005b7ab28SAriel Constenla-Haile {
15105b7ab28SAriel Constenla-Haile rConvertedValue <<= b;
15205b7ab28SAriel Constenla-Haile rOldValue <<= mbHorizontal;
15305b7ab28SAriel Constenla-Haile bDifferent = sal_True;
15405b7ab28SAriel Constenla-Haile }
15505b7ab28SAriel Constenla-Haile }
15605b7ab28SAriel Constenla-Haile break;
15705b7ab28SAriel Constenla-Haile default:
15805b7ab28SAriel Constenla-Haile {
15905b7ab28SAriel Constenla-Haile DBG_ERROR( "VCLXPrinterPropertySet_Impl::convertFastPropertyValue - invalid Handle" );
16005b7ab28SAriel Constenla-Haile }
16105b7ab28SAriel Constenla-Haile }
16205b7ab28SAriel Constenla-Haile return bDifferent;
16305b7ab28SAriel Constenla-Haile }
16405b7ab28SAriel Constenla-Haile
setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const::com::sun::star::uno::Any & rValue)16505b7ab28SAriel Constenla-Haile void VCLXPrinterPropertySet::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception)
16605b7ab28SAriel Constenla-Haile {
16705b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex );
16805b7ab28SAriel Constenla-Haile
16905b7ab28SAriel Constenla-Haile switch( nHandle )
17005b7ab28SAriel Constenla-Haile {
17105b7ab28SAriel Constenla-Haile case PROPERTY_Orientation:
17205b7ab28SAriel Constenla-Haile {
17305b7ab28SAriel Constenla-Haile rValue >>= mnOrientation;
17405b7ab28SAriel Constenla-Haile }
17505b7ab28SAriel Constenla-Haile break;
17605b7ab28SAriel Constenla-Haile case PROPERTY_Horizontal:
17705b7ab28SAriel Constenla-Haile {
17805b7ab28SAriel Constenla-Haile rValue >>= mbHorizontal;
17905b7ab28SAriel Constenla-Haile }
18005b7ab28SAriel Constenla-Haile break;
18105b7ab28SAriel Constenla-Haile default:
18205b7ab28SAriel Constenla-Haile {
18305b7ab28SAriel Constenla-Haile DBG_ERROR( "VCLXPrinterPropertySet_Impl::convertFastPropertyValue - invalid Handle" );
18405b7ab28SAriel Constenla-Haile }
18505b7ab28SAriel Constenla-Haile }
18605b7ab28SAriel Constenla-Haile }
18705b7ab28SAriel Constenla-Haile
getFastPropertyValue(::com::sun::star::uno::Any & rValue,sal_Int32 nHandle) const18805b7ab28SAriel Constenla-Haile void VCLXPrinterPropertySet::getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const
18905b7ab28SAriel Constenla-Haile {
19005b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( ((VCLXPrinterPropertySet*)this)->Mutex );
19105b7ab28SAriel Constenla-Haile
19205b7ab28SAriel Constenla-Haile switch( nHandle )
19305b7ab28SAriel Constenla-Haile {
19405b7ab28SAriel Constenla-Haile case PROPERTY_Orientation:
19505b7ab28SAriel Constenla-Haile rValue <<= mnOrientation;
19605b7ab28SAriel Constenla-Haile break;
19705b7ab28SAriel Constenla-Haile case PROPERTY_Horizontal:
19805b7ab28SAriel Constenla-Haile rValue <<= mbHorizontal;
19905b7ab28SAriel Constenla-Haile break;
20005b7ab28SAriel Constenla-Haile default:
20105b7ab28SAriel Constenla-Haile {
20205b7ab28SAriel Constenla-Haile DBG_ERROR( "VCLXPrinterPropertySet_Impl::convertFastPropertyValue - invalid Handle" );
20305b7ab28SAriel Constenla-Haile }
20405b7ab28SAriel Constenla-Haile }
20505b7ab28SAriel Constenla-Haile }
20605b7ab28SAriel Constenla-Haile
20705b7ab28SAriel Constenla-Haile // ::com::sun::star::awt::XPrinterPropertySet
setHorizontal(sal_Bool bHorizontal)20805b7ab28SAriel Constenla-Haile void VCLXPrinterPropertySet::setHorizontal( sal_Bool bHorizontal ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
20905b7ab28SAriel Constenla-Haile {
21005b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex );
21105b7ab28SAriel Constenla-Haile
21205b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Any aValue;
21305b7ab28SAriel Constenla-Haile aValue <<= bHorizontal;
21405b7ab28SAriel Constenla-Haile setFastPropertyValue( PROPERTY_Horizontal, aValue );
21505b7ab28SAriel Constenla-Haile }
21605b7ab28SAriel Constenla-Haile
getFormDescriptions()21705b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Sequence< ::rtl::OUString > VCLXPrinterPropertySet::getFormDescriptions( ) throw(::com::sun::star::uno::RuntimeException)
21805b7ab28SAriel Constenla-Haile {
21905b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex );
22005b7ab28SAriel Constenla-Haile
22105b7ab28SAriel Constenla-Haile sal_uInt16 nPaperBinCount = GetPrinter()->GetPaperBinCount();
22205b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Sequence< ::rtl::OUString > aDescriptions( nPaperBinCount );
22305b7ab28SAriel Constenla-Haile for ( sal_uInt16 n = 0; n < nPaperBinCount; n++ )
22405b7ab28SAriel Constenla-Haile {
22505b7ab28SAriel Constenla-Haile // Format: <DisplayFormName;FormNameId;DisplayPaperBinName;PaperBinNameId;DisplayPaperName;PaperNameId>
22605b7ab28SAriel Constenla-Haile String aDescr( RTL_CONSTASCII_USTRINGPARAM( "*;*;" ) );
22705b7ab28SAriel Constenla-Haile aDescr += GetPrinter()->GetPaperBinName( n );
22805b7ab28SAriel Constenla-Haile aDescr += ';';
22905b7ab28SAriel Constenla-Haile aDescr += n;
23005b7ab28SAriel Constenla-Haile aDescr.AppendAscii( ";*;*", 4 );
23105b7ab28SAriel Constenla-Haile
23205b7ab28SAriel Constenla-Haile aDescriptions.getArray()[n] = aDescr;
23305b7ab28SAriel Constenla-Haile }
23405b7ab28SAriel Constenla-Haile return aDescriptions;
23505b7ab28SAriel Constenla-Haile }
23605b7ab28SAriel Constenla-Haile
selectForm(const::rtl::OUString & rFormDescription)23705b7ab28SAriel 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)
23805b7ab28SAriel Constenla-Haile {
23905b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex );
24005b7ab28SAriel Constenla-Haile
24105b7ab28SAriel Constenla-Haile sal_Int32 nIndex = 0;
24205b7ab28SAriel Constenla-Haile sal_uInt16 nPaperBin = sal::static_int_cast< sal_uInt16 >(
24305b7ab28SAriel Constenla-Haile rFormDescription.getToken( 3, ';', nIndex ).toInt32());
24405b7ab28SAriel Constenla-Haile GetPrinter()->SetPaperBin( nPaperBin );
24505b7ab28SAriel Constenla-Haile }
24605b7ab28SAriel Constenla-Haile
getBinarySetup()24705b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Sequence< sal_Int8 > VCLXPrinterPropertySet::getBinarySetup( ) throw(::com::sun::star::uno::RuntimeException)
24805b7ab28SAriel Constenla-Haile {
24905b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex );
25005b7ab28SAriel Constenla-Haile
25105b7ab28SAriel Constenla-Haile SvMemoryStream aMem;
25205b7ab28SAriel Constenla-Haile aMem << BINARYSETUPMARKER;
25305b7ab28SAriel Constenla-Haile aMem << GetPrinter()->GetJobSetup();
25405b7ab28SAriel Constenla-Haile return ::com::sun::star::uno::Sequence<sal_Int8>( (sal_Int8*) aMem.GetData(), aMem.Tell() );
25505b7ab28SAriel Constenla-Haile }
25605b7ab28SAriel Constenla-Haile
setBinarySetup(const::com::sun::star::uno::Sequence<sal_Int8> & data)25705b7ab28SAriel 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)
25805b7ab28SAriel Constenla-Haile {
25905b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex );
26005b7ab28SAriel Constenla-Haile
26105b7ab28SAriel Constenla-Haile SvMemoryStream aMem( (char*) data.getConstArray(), data.getLength(), STREAM_READ );
26205b7ab28SAriel Constenla-Haile sal_uInt32 nMarker;
26305b7ab28SAriel Constenla-Haile aMem >> nMarker;
26405b7ab28SAriel Constenla-Haile DBG_ASSERT( nMarker == BINARYSETUPMARKER, "setBinarySetup - invalid!" );
26505b7ab28SAriel Constenla-Haile if ( nMarker == BINARYSETUPMARKER )
26605b7ab28SAriel Constenla-Haile {
26705b7ab28SAriel Constenla-Haile JobSetup aSetup;
26805b7ab28SAriel Constenla-Haile aMem >> aSetup;
26905b7ab28SAriel Constenla-Haile GetPrinter()->SetJobSetup( aSetup );
27005b7ab28SAriel Constenla-Haile }
27105b7ab28SAriel Constenla-Haile }
27205b7ab28SAriel Constenla-Haile
27305b7ab28SAriel Constenla-Haile
27405b7ab28SAriel Constenla-Haile // ----------------------------------------------------
27505b7ab28SAriel Constenla-Haile // class VCLXPrinter
27605b7ab28SAriel Constenla-Haile // ----------------------------------------------------
VCLXPrinter(const String & rPrinterName)27705b7ab28SAriel Constenla-Haile VCLXPrinter::VCLXPrinter( const String& rPrinterName )
27805b7ab28SAriel Constenla-Haile : VCLXPrinter_Base( rPrinterName )
27905b7ab28SAriel Constenla-Haile {
28005b7ab28SAriel Constenla-Haile }
28105b7ab28SAriel Constenla-Haile
~VCLXPrinter()28205b7ab28SAriel Constenla-Haile VCLXPrinter::~VCLXPrinter()
28305b7ab28SAriel Constenla-Haile {
28405b7ab28SAriel Constenla-Haile }
28505b7ab28SAriel Constenla-Haile
start(const::rtl::OUString &,sal_Int16,sal_Bool)28605b7ab28SAriel 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)
28705b7ab28SAriel Constenla-Haile {
28805b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex );
28905b7ab28SAriel Constenla-Haile
29005b7ab28SAriel Constenla-Haile sal_Bool bDone = sal_True;
291*44b09b52SAriel Constenla-Haile if ( mpPrinter.get() )
29205b7ab28SAriel Constenla-Haile {
29305b7ab28SAriel Constenla-Haile maInitJobSetup = mpPrinter->GetJobSetup();
29405b7ab28SAriel Constenla-Haile mpListener.reset( new vcl::OldStylePrintAdaptor( mpPrinter ) );
29505b7ab28SAriel Constenla-Haile }
29605b7ab28SAriel Constenla-Haile
29705b7ab28SAriel Constenla-Haile return bDone;
29805b7ab28SAriel Constenla-Haile }
29905b7ab28SAriel Constenla-Haile
end()30005b7ab28SAriel Constenla-Haile void VCLXPrinter::end( ) throw(::com::sun::star::awt::PrinterException, ::com::sun::star::uno::RuntimeException)
30105b7ab28SAriel Constenla-Haile {
30205b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex );
30305b7ab28SAriel Constenla-Haile
30405b7ab28SAriel Constenla-Haile if ( mpListener.get() )
30505b7ab28SAriel Constenla-Haile {
30605b7ab28SAriel Constenla-Haile Printer::PrintJob( mpListener, maInitJobSetup );
30705b7ab28SAriel Constenla-Haile mpListener.reset();
30805b7ab28SAriel Constenla-Haile }
30905b7ab28SAriel Constenla-Haile }
31005b7ab28SAriel Constenla-Haile
terminate()31105b7ab28SAriel Constenla-Haile void VCLXPrinter::terminate( ) throw(::com::sun::star::uno::RuntimeException)
31205b7ab28SAriel Constenla-Haile {
31305b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex );
31405b7ab28SAriel Constenla-Haile
31505b7ab28SAriel Constenla-Haile mpListener.reset();
31605b7ab28SAriel Constenla-Haile }
31705b7ab28SAriel Constenla-Haile
startPage()31805b7ab28SAriel 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)
31905b7ab28SAriel Constenla-Haile {
32005b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex );
32105b7ab28SAriel Constenla-Haile
32205b7ab28SAriel Constenla-Haile if ( mpListener.get() )
32305b7ab28SAriel Constenla-Haile {
32405b7ab28SAriel Constenla-Haile mpListener->StartPage();
32505b7ab28SAriel Constenla-Haile }
32605b7ab28SAriel Constenla-Haile return GetDevice();
32705b7ab28SAriel Constenla-Haile }
32805b7ab28SAriel Constenla-Haile
endPage()32905b7ab28SAriel Constenla-Haile void VCLXPrinter::endPage( ) throw(::com::sun::star::awt::PrinterException, ::com::sun::star::uno::RuntimeException)
33005b7ab28SAriel Constenla-Haile {
33105b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex );
33205b7ab28SAriel Constenla-Haile
33305b7ab28SAriel Constenla-Haile if ( mpListener.get() )
33405b7ab28SAriel Constenla-Haile {
33505b7ab28SAriel Constenla-Haile mpListener->EndPage();
33605b7ab28SAriel Constenla-Haile }
33705b7ab28SAriel Constenla-Haile }
33805b7ab28SAriel Constenla-Haile
33905b7ab28SAriel Constenla-Haile
34005b7ab28SAriel Constenla-Haile // ----------------------------------------------------
34105b7ab28SAriel Constenla-Haile // class VCLXInfoPrinter
34205b7ab28SAriel Constenla-Haile // ----------------------------------------------------
34305b7ab28SAriel Constenla-Haile
VCLXInfoPrinter(const String & rPrinterName)34405b7ab28SAriel Constenla-Haile VCLXInfoPrinter::VCLXInfoPrinter( const String& rPrinterName )
34505b7ab28SAriel Constenla-Haile : VCLXInfoPrinter_Base( rPrinterName )
34605b7ab28SAriel Constenla-Haile {
34705b7ab28SAriel Constenla-Haile }
34805b7ab28SAriel Constenla-Haile
~VCLXInfoPrinter()34905b7ab28SAriel Constenla-Haile VCLXInfoPrinter::~VCLXInfoPrinter()
35005b7ab28SAriel Constenla-Haile {
35105b7ab28SAriel Constenla-Haile }
35205b7ab28SAriel Constenla-Haile
35305b7ab28SAriel Constenla-Haile // ::com::sun::star::awt::XInfoPrinter
createDevice()35405b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > VCLXInfoPrinter::createDevice( ) throw(::com::sun::star::uno::RuntimeException)
35505b7ab28SAriel Constenla-Haile {
35605b7ab28SAriel Constenla-Haile ::osl::Guard< ::osl::Mutex > aGuard( Mutex );
35705b7ab28SAriel Constenla-Haile
35805b7ab28SAriel Constenla-Haile return GetDevice();
35905b7ab28SAriel Constenla-Haile }
36005b7ab28SAriel Constenla-Haile
36105b7ab28SAriel Constenla-Haile // ----------------------------------------------------
36205b7ab28SAriel Constenla-Haile // class VCLXPrinterServer
36305b7ab28SAriel Constenla-Haile // ----------------------------------------------------
36405b7ab28SAriel Constenla-Haile
36505b7ab28SAriel Constenla-Haile // ::com::sun::star::awt::XPrinterServer
getPrinterNames()36605b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Sequence< ::rtl::OUString > VCLXPrinterServer::getPrinterNames( ) throw(::com::sun::star::uno::RuntimeException)
36705b7ab28SAriel Constenla-Haile {
36805b7ab28SAriel Constenla-Haile const std::vector<rtl::OUString>& rQueues = Printer::GetPrinterQueues();
36905b7ab28SAriel Constenla-Haile sal_uInt32 nPrinters = rQueues.size();
37005b7ab28SAriel Constenla-Haile
37105b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Sequence< ::rtl::OUString > aNames( nPrinters );
37205b7ab28SAriel Constenla-Haile for ( sal_uInt32 n = 0; n < nPrinters; n++ )
37305b7ab28SAriel Constenla-Haile aNames.getArray()[n] = rQueues[n];
37405b7ab28SAriel Constenla-Haile
37505b7ab28SAriel Constenla-Haile return aNames;
37605b7ab28SAriel Constenla-Haile }
37705b7ab28SAriel Constenla-Haile
createPrinter(const::rtl::OUString & rPrinterName)37805b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPrinter > VCLXPrinterServer::createPrinter( const ::rtl::OUString& rPrinterName ) throw(::com::sun::star::uno::RuntimeException)
37905b7ab28SAriel Constenla-Haile {
38005b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPrinter > xP;
38105b7ab28SAriel Constenla-Haile xP = new VCLXPrinter( rPrinterName );
38205b7ab28SAriel Constenla-Haile return xP;
38305b7ab28SAriel Constenla-Haile }
38405b7ab28SAriel Constenla-Haile
createInfoPrinter(const::rtl::OUString & rPrinterName)38505b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Reference< ::com::sun::star::awt::XInfoPrinter > VCLXPrinterServer::createInfoPrinter( const ::rtl::OUString& rPrinterName ) throw(::com::sun::star::uno::RuntimeException)
38605b7ab28SAriel Constenla-Haile {
38705b7ab28SAriel Constenla-Haile ::com::sun::star::uno::Reference< ::com::sun::star::awt::XInfoPrinter > xP;
38805b7ab28SAriel Constenla-Haile xP = new VCLXInfoPrinter( rPrinterName );
38905b7ab28SAriel Constenla-Haile return xP;
39005b7ab28SAriel Constenla-Haile }
39105b7ab28SAriel Constenla-Haile
39205b7ab28SAriel Constenla-Haile
393