1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
21 #include <vcl/print.hxx>
23 #include <osx/printview.h>
24 #include <osx/salprn.h>
26 @implementation AquaPrintView
28 -(id)initWithController: (vcl::PrinterController*)pController
29 withInfoPrinter: (AquaSalInfoPrinter*)pInfoPrinter
31 NSRect aRect = { NSZeroPoint, [pInfoPrinter->getPrintInfo() paperSize] };
32 if( (self = [super initWithFrame: aRect]) != nil )
34 mpController = pController;
35 mpInfoPrinter = pInfoPrinter;
40 -(BOOL)knowsPageRange: (NSRangePointer)range
43 range->length = mpInfoPrinter->getCurPageRangeCount();
47 -(NSRect)rectForPage: (int)page
49 NSSize aPaperSize = [mpInfoPrinter->getPrintInfo() paperSize];
50 int nWidth = static_cast<int>(aPaperSize.width);
51 // #i101108# sanity check
54 NSRect aRect = { { static_cast<CGFloat>(page % nWidth),
55 static_cast<CGFloat>(page / nWidth) },
60 -(NSPoint)locationOfPrintRect: (NSRect)aRect
66 -(void)drawRect: (NSRect)rect
68 mpInfoPrinter->setStartPageOffset( static_cast<int>(rect.origin.x),
69 static_cast<int>(rect.origin.y) );
70 NSSize aPaperSize = [mpInfoPrinter->getPrintInfo() paperSize];
71 int nPage = static_cast<int>(aPaperSize.width * rect.origin.y + rect.origin.x);
73 // page count is 1 based
74 if( nPage - 1 < (mpInfoPrinter->getCurPageRangeStart() + mpInfoPrinter->getCurPageRangeCount() ) )
75 mpController->printFilteredPage( nPage-1 );
80 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */