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