LibreOffice Module vcl (master) 1
osx/salprn.h
Go to the documentation of this file.
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 INCLUDED_VCL_INC_OSX_SALPRN_H
21#define INCLUDED_VCL_INC_OSX_SALPRN_H
22
23#include <sal/config.h>
24
25#include <tools/long.hxx>
26
27#include <osx/osxvcltypes.h>
28
29#include <salprn.hxx>
30
31#include <memory>
32
33class AquaSalGraphics;
34
36{
42 bool mbJob;
43
45 NSPrinter* mpPrinter;
47 NSPrintInfo* mpPrintInfo;
48
52 CGContextRef mrContext;
54 std::unique_ptr<sal_uInt8[]> mpContextMemory;
55
56 // since changes to NSPrintInfo during a job are ignored
57 // we have to care for some settings ourselves
58 // currently we do this for orientation;
59 // really needed however is a solution for paper formats
61
66
67 public:
69 virtual ~AquaSalInfoPrinter() override;
70
71 void SetupPrinterGraphics( CGContextRef i_xContext ) const;
72
73 virtual SalGraphics* AcquireGraphics() override;
74 virtual void ReleaseGraphics( SalGraphics* i_pGraphics ) override;
75 virtual bool Setup( weld::Window* i_pFrame, ImplJobSetup* i_pSetupData ) override;
76 virtual bool SetPrinterData( ImplJobSetup* pSetupData ) override;
77 virtual bool SetData( JobSetFlags i_nFlags, ImplJobSetup* i_pSetupData ) override;
78 virtual void GetPageInfo( const ImplJobSetup* i_pSetupData,
79 tools::Long& o_rOutWidth, tools::Long& o_rOutHeight,
80 Point& rPageOffset,
81 Size& rPaperSize ) override;
82 virtual sal_uInt32 GetCapabilities( const ImplJobSetup* i_pSetupData, PrinterCapType i_nType ) override;
83 virtual sal_uInt16 GetPaperBinCount( const ImplJobSetup* i_pSetupData ) override;
84 virtual OUString GetPaperBinName( const ImplJobSetup* i_pSetupData, sal_uInt16 i_nPaperBin ) override;
85 virtual void InitPaperFormats( const ImplJobSetup* i_pSetupData ) override;
86 virtual int GetLandscapeAngle( const ImplJobSetup* i_pSetupData ) override;
87
88 // the artificial separation between InfoPrinter and Printer
89 // is not really useful for us
90 // so let's make AquaSalPrinter just a forwarder to AquaSalInfoPrinter
91 // and concentrate the real work in one class
92 // implement pull model print system
93 bool StartJob( const OUString* i_pFileName,
94 const OUString& rJobName,
95 ImplJobSetup* i_pSetupData,
96 vcl::PrinterController& i_rController );
97 bool EndJob();
98 bool AbortJob();
99 SalGraphics* StartPage( ImplJobSetup* i_pSetupData, bool i_bNewJobData );
100 bool EndPage();
101
102 NSPrintInfo* getPrintInfo() const { return mpPrintInfo; }
103 void setStartPageOffset( int nOffsetX, int nOffsetY ) { mnStartPageOffsetX = nOffsetX; mnStartPageOffsetY = nOffsetY; }
104 sal_Int32 getCurPageRangeStart() const { return mnCurPageRangeStart; }
105 sal_Int32 getCurPageRangeCount() const { return mnCurPageRangeCount; }
106
107 // match width/height against known paper formats, possibly switching orientation
109 tools::Long i_nWidth, tools::Long i_nHeight, Orientation& o_rOrientation ) const;
110 void setPaperSize( tools::Long i_nWidth, tools::Long i_nHeight, Orientation i_eSetOrientation );
111
112 private:
115};
116
117
119{
120 AquaSalInfoPrinter* mpInfoPrinter; // pointer to the compatible InfoPrinter
121 public:
123 virtual ~AquaSalPrinter() override;
124
125 virtual bool StartJob( const OUString* i_pFileName,
126 const OUString& i_rJobName,
127 const OUString& i_rAppName,
128 sal_uInt32 i_nCopies,
129 bool i_bCollate,
130 bool i_bDirect,
131 ImplJobSetup* i_pSetupData ) override;
132 // implement pull model print system
133 virtual bool StartJob( const OUString* i_pFileName,
134 const OUString& rJobName,
135 const OUString& i_rAppName,
136 ImplJobSetup* i_pSetupData,
137 vcl::PrinterController& i_rListener ) override;
138
139 virtual bool EndJob() override;
140 virtual SalGraphics* StartPage( ImplJobSetup* i_pSetupData, bool i_bNewJobData ) override;
141 virtual void EndPage() override;
142
143 private:
144 AquaSalPrinter( const AquaSalPrinter& ) = delete;
146};
147
148const double fPtTo100thMM = 35.27777778;
149
150inline int PtTo10Mu( double nPoints ) { return static_cast<int>((nPoints*fPtTo100thMM)+0.5); }
151
152inline double TenMuToPt( double nUnits ) { return floor((nUnits/fPtTo100thMM)+0.5); }
153
154#endif // INCLUDED_VCL_INC_OSX_SALPRN_H
155
156/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void setPaperSize(tools::Long i_nWidth, tools::Long i_nHeight, Orientation i_eSetOrientation)
virtual sal_uInt32 GetCapabilities(const ImplJobSetup *i_pSetupData, PrinterCapType i_nType) override
virtual bool SetData(JobSetFlags i_nFlags, ImplJobSetup *i_pSetupData) override
virtual bool SetPrinterData(ImplJobSetup *pSetupData) override
AquaSalInfoPrinter(const AquaSalInfoPrinter &)=delete
virtual bool Setup(weld::Window *i_pFrame, ImplJobSetup *i_pSetupData) override
virtual sal_uInt16 GetPaperBinCount(const ImplJobSetup *i_pSetupData) override
NSPrintInfo * mpPrintInfo
cocoa print info object
Definition: osx/salprn.h:47
virtual void InitPaperFormats(const ImplJobSetup *i_pSetupData) override
sal_Int32 getCurPageRangeCount() const
Definition: osx/salprn.h:105
AquaSalInfoPrinter(const SalPrinterQueueInfo &pInfo)
NSPrintInfo * getPrintInfo() const
Definition: osx/salprn.h:102
AquaSalInfoPrinter & operator=(const AquaSalInfoPrinter &)=delete
sal_Int32 getCurPageRangeStart() const
Definition: osx/salprn.h:104
bool mbGraphics
is Graphics used
Definition: osx/salprn.h:40
virtual void ReleaseGraphics(SalGraphics *i_pGraphics) override
AquaSalGraphics * mpGraphics
Printer graphics.
Definition: osx/salprn.h:38
virtual OUString GetPaperBinName(const ImplJobSetup *i_pSetupData, sal_uInt16 i_nPaperBin) override
virtual SalGraphics * AcquireGraphics() override
virtual ~AquaSalInfoPrinter() override
virtual void GetPageInfo(const ImplJobSetup *i_pSetupData, tools::Long &o_rOutWidth, tools::Long &o_rOutHeight, Point &rPageOffset, Size &rPaperSize) override
void setStartPageOffset(int nOffsetX, int nOffsetY)
Definition: osx/salprn.h:103
NSPrinter * mpPrinter
cocoa printer object
Definition: osx/salprn.h:45
std::unique_ptr< sal_uInt8[]> mpContextMemory
memory for graphics bitmap context for querying metrics
Definition: osx/salprn.h:54
sal_Int32 mnCurPageRangeStart
Definition: osx/salprn.h:64
SalGraphics * StartPage(ImplJobSetup *i_pSetupData, bool i_bNewJobData)
virtual int GetLandscapeAngle(const ImplJobSetup *i_pSetupData) override
Orientation mePageOrientation
Definition: osx/salprn.h:60
void SetupPrinterGraphics(CGContextRef i_xContext) const
const PaperInfo * matchPaper(tools::Long i_nWidth, tools::Long i_nHeight, Orientation &o_rOrientation) const
sal_Int32 mnCurPageRangeCount
Definition: osx/salprn.h:65
bool StartJob(const OUString *i_pFileName, const OUString &rJobName, ImplJobSetup *i_pSetupData, vcl::PrinterController &i_rController)
CGContextRef mrContext
FIXME: get real printer context for infoprinter if possible fake context for info printer graphics co...
Definition: osx/salprn.h:52
bool mbJob
job active ?
Definition: osx/salprn.h:42
virtual ~AquaSalPrinter() override
virtual bool StartJob(const OUString *i_pFileName, const OUString &rJobName, const OUString &i_rAppName, ImplJobSetup *i_pSetupData, vcl::PrinterController &i_rListener) override
virtual void EndPage() override
AquaSalPrinter(const AquaSalPrinter &)=delete
AquaSalInfoPrinter * mpInfoPrinter
Definition: osx/salprn.h:120
virtual bool StartJob(const OUString *i_pFileName, const OUString &i_rJobName, const OUString &i_rAppName, sal_uInt32 i_nCopies, bool i_bCollate, bool i_bDirect, ImplJobSetup *i_pSetupData) override
AquaSalPrinter(AquaSalInfoPrinter *i_pInfoPrinter)
virtual SalGraphics * StartPage(ImplJobSetup *i_pSetupData, bool i_bNewJobData) override
virtual bool EndJob() override
AquaSalPrinter & operator=(const AquaSalPrinter &)=delete
long Long
double TenMuToPt(double nUnits)
Definition: osx/salprn.h:152
const double fPtTo100thMM
Definition: osx/salprn.h:148
int PtTo10Mu(double nPoints)
Definition: osx/salprn.h:150
Orientation
Definition: prntypes.hxx:31
PrinterCapType
Definition: prntypes.hxx:72
JobSetFlags
Definition: salptype.hxx:27