1 /************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: aquaprintview.mm,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
34 #include "aquaprintview.h"
36 #include "vcl/impprn.hxx"
38 @implementation AquaPrintView
39 -(id)initWithQPrinter: (ImplQPrinter*)pPrinter withInfoPrinter: (AquaSalInfoPrinter*)pInfoPrinter
41 NSRect aRect = { { 0, 0 }, [pInfoPrinter->getPrintInfo() paperSize] };
42 if( (self = [super initWithFrame: aRect]) != nil )
44 mpQPrinter = pPrinter;
45 mpInfoPrinter = pInfoPrinter;
50 -(MacOSBOOL)knowsPageRange: (NSRangePointer)range
53 range->length = mpInfoPrinter->getCurPageRangeCount();
57 -(NSRect)rectForPage: (int)page
59 NSSize aPaperSize = [mpInfoPrinter->getPrintInfo() paperSize];
60 int nWidth = (int)aPaperSize.width;
61 // #i101108# sanity check
64 NSRect aRect = { { page % nWidth, page / nWidth }, aPaperSize };
68 -(NSPoint)locationOfPrintRect: (NSRect)aRect
70 NSPoint aPoint = { 0, 0 };
74 -(void)drawRect: (NSRect)rect
76 NSPoint aPoint = [self locationOfPrintRect: rect];
77 mpInfoPrinter->setStartPageOffset( static_cast<int>(rect.origin.x), static_cast<int>(rect.origin.y) );
78 NSSize aPaperSize = [mpInfoPrinter->getPrintInfo() paperSize];
79 int nPage = (int)(aPaperSize.width * rect.origin.y + rect.origin.x);
81 // page count is 1 based
82 mpQPrinter->PrintPage( nPage-1 + mpInfoPrinter->getCurPageRangeStart() );