Avoid potential negative array index access to cached text.
[LibreOffice.git] / toolkit / inc / awt / vclxprinter.hxx
blobe5440f38aac4ac8b2e433c28e850fb52661558a4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #pragma once
23 #include <com/sun/star/awt/XPrinterPropertySet.hpp>
24 #include <com/sun/star/awt/XPrinterServer2.hpp>
25 #include <com/sun/star/awt/XInfoPrinter.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
28 #include <comphelper/broadcasthelper.hxx>
29 #include <cppuhelper/propshlp.hxx>
30 #include <cppuhelper/implbase.hxx>
31 #include <comphelper/uno3.hxx>
32 #include <vcl/vclptr.hxx>
33 #include <vcl/jobset.hxx>
35 #include <memory>
37 namespace com::sun::star::awt { class XPrinter; }
38 namespace vcl { class OldStylePrintAdaptor; }
39 class Printer;
41 // relevant properties for the printer:
43 sal_Bool Horizontal
44 sal_uInt16 CopyCount;
45 sal_Bool Collate;
46 String FormDescriptor;
47 sal_uInt16 Orientation; // PORTRAIT, LANDSCAPE
53 typedef ::cppu::WeakImplHelper < css::awt::XPrinterPropertySet
54 > VCLXPrinterPropertySet_Base;
55 class VCLXPrinterPropertySet :public VCLXPrinterPropertySet_Base
56 ,public comphelper::OMutexAndBroadcastHelper
57 ,public ::cppu::OPropertySetHelper
59 protected:
60 VclPtr<Printer> mxPrinter;
61 css::uno::Reference< css::awt::XDevice > mxPrnDevice;
63 sal_Int16 mnOrientation;
64 bool mbHorizontal;
65 public:
66 VCLXPrinterPropertySet( const OUString& rPrinterName );
67 virtual ~VCLXPrinterPropertySet() override;
69 Printer* GetPrinter() const { return mxPrinter.get(); }
70 css::uno::Reference< css::awt::XDevice > const & GetDevice();
72 // css::uno::XInterface
73 DECLARE_XINTERFACE();
75 // css::lang::XTypeProvider
76 DECLARE_XTYPEPROVIDER();
78 // css::beans::XPropertySet
79 css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override;
80 void SAL_CALL setPropertyValue( const OUString& rPropertyName, const css::uno::Any& aValue ) override { OPropertySetHelper::setPropertyValue( rPropertyName, aValue ); }
81 css::uno::Any SAL_CALL getPropertyValue( const OUString& rPropertyName ) override { return OPropertySetHelper::getPropertyValue( rPropertyName ); }
82 void SAL_CALL addPropertyChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& rxListener ) override { OPropertySetHelper::addPropertyChangeListener( rPropertyName, rxListener ); }
83 void SAL_CALL removePropertyChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& rxListener ) override { OPropertySetHelper::removePropertyChangeListener( rPropertyName, rxListener ); }
84 void SAL_CALL addVetoableChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& rxListener ) override { OPropertySetHelper::addVetoableChangeListener( rPropertyName, rxListener ); }
85 void SAL_CALL removeVetoableChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& rxListener ) override { OPropertySetHelper::removeVetoableChangeListener( rPropertyName, rxListener ); }
87 // ::cppu::OPropertySetHelper
88 ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override;
89 sal_Bool SAL_CALL convertFastPropertyValue( css::uno::Any & rConvertedValue, css::uno::Any & rOldValue, sal_Int32 nHandle, const css::uno::Any& rValue ) override;
90 void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const css::uno::Any& rValue ) override;
91 using cppu::OPropertySetHelper::getFastPropertyValue;
92 void SAL_CALL getFastPropertyValue( css::uno::Any& rValue, sal_Int32 nHandle ) const override;
94 // css::awt::XPrinterPropertySet
95 void SAL_CALL setHorizontal( sal_Bool bHorizontal ) override;
96 css::uno::Sequence< OUString > SAL_CALL getFormDescriptions( ) override;
97 void SAL_CALL selectForm( const OUString& aFormDescription ) override;
98 css::uno::Sequence< sal_Int8 > SAL_CALL getBinarySetup( ) override;
99 void SAL_CALL setBinarySetup( const css::uno::Sequence< sal_Int8 >& data ) override;
105 typedef ::cppu::ImplInheritanceHelper < VCLXPrinterPropertySet
106 , css::awt::XPrinter
107 > VCLXPrinter_Base;
108 class VCLXPrinter final : public VCLXPrinter_Base
110 std::shared_ptr<vcl::OldStylePrintAdaptor> mxListener;
111 JobSetup maInitJobSetup;
112 public:
113 VCLXPrinter( const OUString& rPrinterName );
114 virtual ~VCLXPrinter() override;
116 // css::beans::XPropertySet
117 css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override { return VCLXPrinterPropertySet::getPropertySetInfo(); }
118 void SAL_CALL setPropertyValue( const OUString& rPropertyName, const css::uno::Any& aValue ) override { VCLXPrinterPropertySet::setPropertyValue( rPropertyName, aValue ); }
119 css::uno::Any SAL_CALL getPropertyValue( const OUString& rPropertyName ) override { return VCLXPrinterPropertySet::getPropertyValue( rPropertyName ); }
120 void SAL_CALL addPropertyChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& rxListener ) override { VCLXPrinterPropertySet::addPropertyChangeListener( rPropertyName, rxListener ); }
121 void SAL_CALL removePropertyChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& rxListener ) override { VCLXPrinterPropertySet::removePropertyChangeListener( rPropertyName, rxListener ); }
122 void SAL_CALL addVetoableChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& rxListener ) override { VCLXPrinterPropertySet::addVetoableChangeListener( rPropertyName, rxListener ); }
123 void SAL_CALL removeVetoableChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& rxListener ) override { VCLXPrinterPropertySet::removeVetoableChangeListener( rPropertyName, rxListener ); }
125 // css::awt::XPrinterPropertySet
126 void SAL_CALL setHorizontal( sal_Bool bHorizontal ) override { VCLXPrinterPropertySet::setHorizontal( bHorizontal ); }
127 css::uno::Sequence< OUString > SAL_CALL getFormDescriptions( ) override { return VCLXPrinterPropertySet::getFormDescriptions(); }
128 void SAL_CALL selectForm( const OUString& aFormDescription ) override { VCLXPrinterPropertySet::selectForm( aFormDescription ); }
129 css::uno::Sequence< sal_Int8 > SAL_CALL getBinarySetup( ) override { return VCLXPrinterPropertySet::getBinarySetup(); }
130 void SAL_CALL setBinarySetup( const css::uno::Sequence< sal_Int8 >& data ) override { VCLXPrinterPropertySet::setBinarySetup( data ); }
132 // css::awt::XPrinter
133 sal_Bool SAL_CALL start( const OUString& nJobName, sal_Int16 nCopies, sal_Bool nCollate ) override;
134 void SAL_CALL end( ) override;
135 void SAL_CALL terminate( ) override;
136 css::uno::Reference< css::awt::XDevice > SAL_CALL startPage( ) override;
137 void SAL_CALL endPage( ) override;
143 typedef ::cppu::ImplInheritanceHelper < VCLXPrinterPropertySet
144 , css::awt::XInfoPrinter
145 > VCLXInfoPrinter_Base;
146 class VCLXInfoPrinter final : public VCLXInfoPrinter_Base
148 public:
149 VCLXInfoPrinter( const OUString& rPrinterName );
150 virtual ~VCLXInfoPrinter() override;
152 // css::beans::XPropertySet
153 css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) override { return VCLXPrinterPropertySet::getPropertySetInfo(); }
154 void SAL_CALL setPropertyValue( const OUString& rPropertyName, const css::uno::Any& aValue ) override { VCLXPrinterPropertySet::setPropertyValue( rPropertyName, aValue ); }
155 css::uno::Any SAL_CALL getPropertyValue( const OUString& rPropertyName ) override { return VCLXPrinterPropertySet::getPropertyValue( rPropertyName ); }
156 void SAL_CALL addPropertyChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& rxListener ) override { VCLXPrinterPropertySet::addPropertyChangeListener( rPropertyName, rxListener ); }
157 void SAL_CALL removePropertyChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener >& rxListener ) override { VCLXPrinterPropertySet::removePropertyChangeListener( rPropertyName, rxListener ); }
158 void SAL_CALL addVetoableChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& rxListener ) override { VCLXPrinterPropertySet::addVetoableChangeListener( rPropertyName, rxListener ); }
159 void SAL_CALL removeVetoableChangeListener( const OUString& rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener >& rxListener ) override { VCLXPrinterPropertySet::removeVetoableChangeListener( rPropertyName, rxListener ); }
161 // css::awt::XPrinterPropertySet
162 void SAL_CALL setHorizontal( sal_Bool bHorizontal ) override { VCLXPrinterPropertySet::setHorizontal( bHorizontal ); }
163 css::uno::Sequence< OUString > SAL_CALL getFormDescriptions( ) override { return VCLXPrinterPropertySet::getFormDescriptions(); }
164 void SAL_CALL selectForm( const OUString& aFormDescription ) override { VCLXPrinterPropertySet::selectForm( aFormDescription ); }
165 css::uno::Sequence< sal_Int8 > SAL_CALL getBinarySetup( ) override { return VCLXPrinterPropertySet::getBinarySetup(); }
166 void SAL_CALL setBinarySetup( const css::uno::Sequence< sal_Int8 >& data ) override { VCLXPrinterPropertySet::setBinarySetup( data ); }
168 // css::awt::XInfoPrinter
169 css::uno::Reference< css::awt::XDevice > SAL_CALL createDevice( ) override;
175 typedef ::cppu::WeakImplHelper < css::awt::XPrinterServer2,
176 css::lang::XServiceInfo
177 > VCLXPrinterServer_Base;
178 class VCLXPrinterServer final : public VCLXPrinterServer_Base
180 public:
181 // css::awt::XPrinterServer2
182 css::uno::Sequence< OUString > SAL_CALL getPrinterNames( ) override;
183 OUString SAL_CALL getDefaultPrinterName() override;
184 css::uno::Reference< css::awt::XPrinter > SAL_CALL createPrinter( const OUString& printerName ) override;
185 css::uno::Reference< css::awt::XInfoPrinter > SAL_CALL createInfoPrinter( const OUString& printerName ) override;
187 OUString SAL_CALL getImplementationName() override;
189 sal_Bool SAL_CALL supportsService(OUString const & ServiceName) override;
191 css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */