Avoid potential negative array index access to cached text.
[LibreOffice.git] / vcl / inc / salprn.hxx
blob05dca2fcabec79751e0df43cafc1535ded8503f4
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 #ifndef INCLUDED_VCL_INC_SALPRN_HXX
21 #define INCLUDED_VCL_INC_SALPRN_HXX
23 #include <i18nutil/paper.hxx>
24 #include <rtl/ustring.hxx>
25 #include <vcl/prntypes.hxx>
26 #include <vcl/dllapi.h>
27 #include <tools/gen.hxx>
29 #include "salptype.hxx"
31 #include <vector>
32 #include <optional>
34 class SalGraphics;
35 class SalFrame;
36 class ImplJobSetup;
37 namespace vcl { class PrinterController; }
38 namespace weld { class Window; }
40 struct VCL_PLUGIN_PUBLIC SalPrinterQueueInfo
42 OUString maPrinterName;
43 OUString maDriver;
44 OUString maLocation;
45 OUString maComment;
46 PrintQueueFlags mnStatus;
47 sal_uInt32 mnJobs;
48 std::optional<OUString> moPortName; // only used by Windows backend
50 SalPrinterQueueInfo();
51 ~SalPrinterQueueInfo();
54 class VCL_PLUGIN_PUBLIC SalInfoPrinter
56 public:
57 std::vector< PaperInfo > m_aPaperFormats; // all printer supported formats
58 bool m_bPapersInit; // set to true after InitPaperFormats
60 SalInfoPrinter() : m_bPapersInit( false ) {}
61 virtual ~SalInfoPrinter();
63 // SalGraphics or NULL, but two Graphics for all SalFrames
64 // must be returned
65 virtual SalGraphics* AcquireGraphics() = 0;
66 virtual void ReleaseGraphics( SalGraphics* pGraphics ) = 0;
68 virtual bool Setup(weld::Window* pFrame, ImplJobSetup* pSetupData) = 0;
69 // This function set the driver data and
70 // set the new indepen data in pSetupData
71 virtual bool SetPrinterData( ImplJobSetup* pSetupData ) = 0;
72 // This function merged the indepen driver data
73 // and set the new indepen data in pSetupData
74 // Only the data must changed, where the bit
75 // in nFlags is set
76 virtual bool SetData( JobSetFlags nFlags, ImplJobSetup* pSetupData ) = 0;
78 virtual void GetPageInfo( const ImplJobSetup* pSetupData,
79 tools::Long& rOutWidth, tools::Long& rOutHeight,
80 Point& rPageOffset,
81 Size& rPaperSize ) = 0;
82 virtual sal_uInt32 GetCapabilities( const ImplJobSetup* pSetupData, PrinterCapType nType ) = 0;
83 virtual sal_uInt16 GetPaperBinCount( const ImplJobSetup* pSetupData ) = 0;
84 virtual OUString GetPaperBinName( const ImplJobSetup* pSetupData, sal_uInt16 nPaperBin ) = 0;
85 virtual sal_uInt16 GetPaperBinBySourceIndex(const ImplJobSetup* pSetupData,
86 sal_uInt16 nPaperSource) = 0;
87 virtual sal_uInt16 GetSourceIndexByPaperBin(const ImplJobSetup* pSetupData,
88 sal_uInt16 nPaperSource) = 0;
90 // fills m_aPaperFormats and sets m_bPapersInit to true
91 virtual void InitPaperFormats( const ImplJobSetup* pSetupData ) = 0;
92 // returns angle that a landscape page will be turned counterclockwise wrt to portrait
93 virtual int GetLandscapeAngle( const ImplJobSetup* pSetupData ) = 0;
96 class VCL_PLUGIN_PUBLIC SalPrinter
98 SalPrinter( const SalPrinter& ) = delete;
99 SalPrinter& operator=( const SalPrinter& ) = delete;
101 public:
102 SalPrinter() {}
103 virtual ~SalPrinter();
105 virtual bool StartJob( const OUString* pFileName,
106 const OUString& rJobName,
107 const OUString& rAppName,
108 sal_uInt32 nCopies,
109 bool bCollate,
110 bool bDirect,
111 ImplJobSetup* pSetupData ) = 0;
113 // implement for pull model print systems only,
114 // default implementations (see salvtables.cxx) just returns false
115 virtual bool StartJob( const OUString* pFileName,
116 const OUString& rJobName,
117 const OUString& rAppName,
118 ImplJobSetup* pSetupData,
119 vcl::PrinterController& rController );
121 virtual bool EndJob() = 0;
122 virtual SalGraphics* StartPage( ImplJobSetup* pSetupData, bool bNewJobData ) = 0;
123 virtual void EndPage() = 0;
124 virtual SalPrinterError GetErrorCode() { return SalPrinterError::NONE; }
128 #endif // INCLUDED_VCL_INC_SALPRN_HXX
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */