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
27 -(id)initWithController: (vcl::PrinterController*)pController withInfoPrinter: (AquaSalInfoPrinter*)pInfoPrinter
29 NSRect aRect = { NSZeroPoint, [pInfoPrinter->getPrintInfo() paperSize] };
30 if( (self = [super initWithFrame: aRect]) != nil )
32 mpController = pController;
33 mpInfoPrinter = pInfoPrinter;
38 -(BOOL)knowsPageRange: (NSRangePointer)range
41 range->length = mpInfoPrinter->getCurPageRangeCount();
45 -(NSRect)rectForPage: (int)page
47 NSSize aPaperSize = [mpInfoPrinter->getPrintInfo() paperSize];
48 int nWidth = (int)aPaperSize.width;
49 // #i101108# sanity check
52 NSRect aRect = { { static_cast<CGFloat>(page % nWidth), static_cast<CGFloat>(page / nWidth) }, aPaperSize };
56 -(NSPoint)locationOfPrintRect: (NSRect)aRect
62 -(void)drawRect: (NSRect)rect
64 mpInfoPrinter->setStartPageOffset( static_cast<int>(rect.origin.x), static_cast<int>(rect.origin.y) );
65 NSSize aPaperSize = [mpInfoPrinter->getPrintInfo() paperSize];
66 int nPage = (int)(aPaperSize.width * rect.origin.y + rect.origin.x);
68 // page count is 1 based
69 if( nPage - 1 < (mpInfoPrinter->getCurPageRangeStart() + mpInfoPrinter->getCurPageRangeCount() ) )
70 mpController->printFilteredPage( nPage-1 );
74 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */