Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef _TOOLKIT_AWT_VCLXPRINTER_HXX_
21 : : #define _TOOLKIT_AWT_VCLXPRINTER_HXX_
22 : :
23 : :
24 : : #include <com/sun/star/awt/XPrinterPropertySet.hpp>
25 : : #include <com/sun/star/awt/XPrinter.hpp>
26 : : #include <com/sun/star/awt/XPrinterServer.hpp>
27 : : #include <com/sun/star/awt/XInfoPrinter.hpp>
28 : : #include <com/sun/star/lang/XTypeProvider.hpp>
29 : : #include <cppuhelper/weak.hxx>
30 : : #include <osl/mutex.hxx>
31 : :
32 : : #include <toolkit/helper/mutexandbroadcasthelper.hxx>
33 : : #include <cppuhelper/propshlp.hxx>
34 : :
35 : : #include "vcl/oldprintadaptor.hxx"
36 : :
37 : : // relevant properties for the printer:
38 : : /*
39 : : sal_Bool Horizontal
40 : : sal_uInt16 CopyCount;
41 : : sal_Bool Collate;
42 : : String FormDescriptor;
43 : : sal_uInt16 Orientation; // PORTRAIT, LANDSCAPE
44 : : */
45 : :
46 : : // ----------------------------------------------------
47 : : // class VCLXPrinterPropertySet
48 : : // ----------------------------------------------------
49 : :
50 : : class VCLXPrinterPropertySet : public ::com::sun::star::awt::XPrinterPropertySet,
51 : : public ::com::sun::star::lang::XTypeProvider,
52 : : public MutexAndBroadcastHelper,
53 : : public ::cppu::OPropertySetHelper
54 : : {
55 : : protected:
56 : : boost::shared_ptr<Printer> mpPrinter;
57 : : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > mxPrnDevice;
58 : :
59 : : sal_Int16 mnOrientation;
60 : : sal_Bool mbHorizontal;
61 : : public:
62 : : VCLXPrinterPropertySet( const String& rPrinterName );
63 : : virtual ~VCLXPrinterPropertySet();
64 : :
65 : 0 : Printer* GetPrinter() const { return mpPrinter.get(); }
66 : : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > GetDevice();
67 : :
68 : : // ::com::sun::star::uno::XInterface
69 : : ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
70 : :
71 : : // ::com::sun::star::lang::XTypeProvider
72 : : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException);
73 : : ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
74 : :
75 : : // ::com::sun::star::beans::XPropertySet
76 : : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
77 : 0 : void SAL_CALL setPropertyValue( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { OPropertySetHelper::setPropertyValue( rPropertyName, aValue ); }
78 : 0 : ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& rPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { return OPropertySetHelper::getPropertyValue( rPropertyName ); }
79 : 0 : void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { OPropertySetHelper::addPropertyChangeListener( rPropertyName, rxListener ); }
80 : 0 : void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { OPropertySetHelper::removePropertyChangeListener( rPropertyName, rxListener ); }
81 : 0 : void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { OPropertySetHelper::addVetoableChangeListener( rPropertyName, rxListener ); }
82 : 0 : void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { OPropertySetHelper::removeVetoableChangeListener( rPropertyName, rxListener ); }
83 : :
84 : : // ::cppu::OPropertySetHelper
85 : : ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper();
86 : : sal_Bool SAL_CALL 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);
87 : : void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception);
88 : : using cppu::OPropertySetHelper::getFastPropertyValue;
89 : : void SAL_CALL getFastPropertyValue( ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const;
90 : :
91 : : // ::com::sun::star::awt::XPrinterPropertySet
92 : : void SAL_CALL setHorizontal( sal_Bool bHorizontal ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
93 : : ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFormDescriptions( ) throw(::com::sun::star::uno::RuntimeException);
94 : : void SAL_CALL selectForm( const ::rtl::OUString& aFormDescription ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
95 : : ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBinarySetup( ) throw(::com::sun::star::uno::RuntimeException);
96 : : void SAL_CALL 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);
97 : : };
98 : :
99 : : // ----------------------------------------------------
100 : : // class VCLXPrinter
101 : : // ----------------------------------------------------
102 : :
103 : : class VCLXPrinter: public ::com::sun::star::awt::XPrinter,
104 : : public VCLXPrinterPropertySet,
105 : : public ::cppu::OWeakObject
106 : : {
107 : : boost::shared_ptr<vcl::OldStylePrintAdaptor> mpListener;
108 : : JobSetup maInitJobSetup;
109 : : public:
110 : : VCLXPrinter( const String& rPrinterName );
111 : : ~VCLXPrinter();
112 : :
113 : : // ::com::sun::star::uno::XInterface
114 : : ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
115 : 0 : void SAL_CALL acquire() throw() { OWeakObject::acquire(); }
116 : 0 : void SAL_CALL release() throw() { OWeakObject::release(); }
117 : :
118 : : // ::com::sun::star::lang::XTypeProvider
119 : : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException);
120 : : ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
121 : :
122 : :
123 : : // ::com::sun::star::beans::XPropertySet
124 : 0 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) { return VCLXPrinterPropertySet::getPropertySetInfo(); }
125 : 0 : void SAL_CALL setPropertyValue( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { VCLXPrinterPropertySet::setPropertyValue( rPropertyName, aValue ); }
126 : 0 : ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& rPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { return VCLXPrinterPropertySet::getPropertyValue( rPropertyName ); }
127 : 0 : void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { VCLXPrinterPropertySet::addPropertyChangeListener( rPropertyName, rxListener ); }
128 : 0 : void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { VCLXPrinterPropertySet::removePropertyChangeListener( rPropertyName, rxListener ); }
129 : 0 : void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { VCLXPrinterPropertySet::addVetoableChangeListener( rPropertyName, rxListener ); }
130 : 0 : void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { VCLXPrinterPropertySet::removeVetoableChangeListener( rPropertyName, rxListener ); }
131 : :
132 : : // ::com::sun::star::awt::XPrinterPropertySet
133 : 0 : void SAL_CALL setHorizontal( sal_Bool bHorizontal ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { VCLXPrinterPropertySet::setHorizontal( bHorizontal ); }
134 : 0 : ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFormDescriptions( ) throw(::com::sun::star::uno::RuntimeException) { return VCLXPrinterPropertySet::getFormDescriptions(); }
135 : 0 : void SAL_CALL selectForm( const ::rtl::OUString& aFormDescription ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { VCLXPrinterPropertySet::selectForm( aFormDescription ); }
136 : 0 : ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBinarySetup( ) throw(::com::sun::star::uno::RuntimeException) { return VCLXPrinterPropertySet::getBinarySetup(); }
137 : 0 : void SAL_CALL 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) { VCLXPrinterPropertySet::setBinarySetup( data ); }
138 : :
139 : : // ::com::sun::star::awt::XPrinter
140 : : sal_Bool SAL_CALL start( const ::rtl::OUString& nJobName, sal_Int16 nCopies, sal_Bool nCollate ) throw(::com::sun::star::awt::PrinterException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
141 : : void SAL_CALL end( ) throw(::com::sun::star::awt::PrinterException, ::com::sun::star::uno::RuntimeException);
142 : : void SAL_CALL terminate( ) throw(::com::sun::star::uno::RuntimeException);
143 : : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > SAL_CALL startPage( ) throw(::com::sun::star::awt::PrinterException, ::com::sun::star::uno::RuntimeException);
144 : : void SAL_CALL endPage( ) throw(::com::sun::star::awt::PrinterException, ::com::sun::star::uno::RuntimeException);
145 : : };
146 : :
147 : : // ----------------------------------------------------
148 : : // class VCLXInfoPrinter
149 : : // ----------------------------------------------------
150 : :
151 : : class VCLXInfoPrinter: public ::com::sun::star::awt::XInfoPrinter,
152 : : public VCLXPrinterPropertySet,
153 : : public ::cppu::OWeakObject
154 : : {
155 : : public:
156 : : VCLXInfoPrinter( const String& rPrinterName );
157 : : ~VCLXInfoPrinter();
158 : :
159 : : // ::com::sun::star::uno::XInterface
160 : : ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
161 : 0 : void SAL_CALL acquire() throw() { OWeakObject::acquire(); }
162 : 0 : void SAL_CALL release() throw() { OWeakObject::release(); }
163 : :
164 : : // ::com::sun::star::lang::XTypeProvider
165 : : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException);
166 : : ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
167 : :
168 : :
169 : : // ::com::sun::star::beans::XPropertySet
170 : 0 : ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException) { return VCLXPrinterPropertySet::getPropertySetInfo(); }
171 : 0 : void SAL_CALL setPropertyValue( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { VCLXPrinterPropertySet::setPropertyValue( rPropertyName, aValue ); }
172 : 0 : ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& rPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { return VCLXPrinterPropertySet::getPropertyValue( rPropertyName ); }
173 : 0 : void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { VCLXPrinterPropertySet::addPropertyChangeListener( rPropertyName, rxListener ); }
174 : 0 : void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { VCLXPrinterPropertySet::removePropertyChangeListener( rPropertyName, rxListener ); }
175 : 0 : void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { VCLXPrinterPropertySet::addVetoableChangeListener( rPropertyName, rxListener ); }
176 : 0 : void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& rPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& rxListener ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) { VCLXPrinterPropertySet::removeVetoableChangeListener( rPropertyName, rxListener ); }
177 : :
178 : : // ::com::sun::star::awt::XPrinterPropertySet
179 : 0 : void SAL_CALL setHorizontal( sal_Bool bHorizontal ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { VCLXPrinterPropertySet::setHorizontal( bHorizontal ); }
180 : 0 : ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getFormDescriptions( ) throw(::com::sun::star::uno::RuntimeException) { return VCLXPrinterPropertySet::getFormDescriptions(); }
181 : 0 : void SAL_CALL selectForm( const ::rtl::OUString& aFormDescription ) throw(::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException) { VCLXPrinterPropertySet::selectForm( aFormDescription ); }
182 : 0 : ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBinarySetup( ) throw(::com::sun::star::uno::RuntimeException) { return VCLXPrinterPropertySet::getBinarySetup(); }
183 : 0 : void SAL_CALL 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) { VCLXPrinterPropertySet::setBinarySetup( data ); }
184 : :
185 : : // ::com::sun::star::awt::XInfoPrinter
186 : : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XDevice > SAL_CALL createDevice( ) throw(::com::sun::star::uno::RuntimeException);
187 : : };
188 : :
189 : : // ----------------------------------------------------
190 : : // class VCLXPrinterServer
191 : : // ----------------------------------------------------
192 : :
193 [ # # ][ # # ]: 0 : class VCLXPrinterServer : public ::com::sun::star::awt::XPrinterServer,
194 : : public ::cppu::OWeakObject
195 : : {
196 : : public:
197 : :
198 : : // ::com::sun::star::uno::XInterface
199 : : ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
200 : 0 : void SAL_CALL acquire() throw() { OWeakObject::acquire(); }
201 : 0 : void SAL_CALL release() throw() { OWeakObject::release(); }
202 : :
203 : : // ::com::sun::star::lang::XTypeProvider
204 : : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() throw(::com::sun::star::uno::RuntimeException);
205 : : ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() throw(::com::sun::star::uno::RuntimeException);
206 : :
207 : : // ::com::sun::star::awt::XPrinterServer
208 : : ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getPrinterNames( ) throw(::com::sun::star::uno::RuntimeException);
209 : : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPrinter > SAL_CALL createPrinter( const ::rtl::OUString& printerName ) throw(::com::sun::star::uno::RuntimeException);
210 : : ::com::sun::star::uno::Reference< ::com::sun::star::awt::XInfoPrinter > SAL_CALL createInfoPrinter( const ::rtl::OUString& printerName ) throw(::com::sun::star::uno::RuntimeException);
211 : : };
212 : :
213 : :
214 : :
215 : :
216 : : #endif // _TOOLKIT_AWT_VCLXPRINTER_HXX_
217 : :
218 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|