sl@0: // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include "PDRVSTD.H" sl@0: sl@0: #include sl@0: #include sl@0: #include "PRINTDRV.H" sl@0: #include "pdrtext.h" sl@0: sl@0: sl@0: EXPORT_C CPrinterDevice* NewPrinterDeviceL() sl@0: { sl@0: CPrintDrvDevice* device = new(ELeave) CPrintDrvDevice; sl@0: return device; sl@0: } sl@0: sl@0: CPrintDrvDevice::CPrintDrvDevice() sl@0: { sl@0: __DECLARE_NAME( _S( "CPrintDrvDevice" ) ); sl@0: } sl@0: sl@0: CPrintDrvDevice::~CPrintDrvDevice() sl@0: { sl@0: } sl@0: sl@0: TInt CPrintDrvDevice::CreateContext( CGraphicsContext*& aGc ) sl@0: { sl@0: __ASSERT_DEBUG( iControl, Panic( EPrintDrvControlDoesNotExist ) ); sl@0: CPdrControl* control = (CPdrControl*) iControl; sl@0: return control->CreateContext( aGc ); sl@0: } sl@0: sl@0: void CPrintDrvDevice::CreateControlL(CPrinterPort* aPrinterPort) sl@0: { sl@0: __ASSERT_ALWAYS( aPrinterPort, Panic( EPrintDrvRequiresPrinterPort ) ); sl@0: __ASSERT_ALWAYS( !iControl, Panic( EPrintDrvControlAlreadyExists ) ); sl@0: __ASSERT_DEBUG( iCurrentPageSpecInTwips.iPortraitPageSize.iWidth && iCurrentPageSpecInTwips.iPortraitPageSize.iHeight, Panic( EPrintDrvPageSpecNotSet ) ); sl@0: iControl = CPrintDrvControl::NewL( this, aPrinterPort, *iStore, iModelInfo->iResourcesStreamId ); sl@0: } sl@0: sl@0: CPrintDrvControl* CPrintDrvControl::NewL( CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort, CStreamStore& aStore, TStreamId aResourcesStreamId ) sl@0: { sl@0: CPrintDrvControl* control = new(ELeave) CPrintDrvControl( aPdrDevice, aPrinterPort ); sl@0: CleanupStack::PushL( control ); sl@0: control->ConstructL( aStore, aResourcesStreamId ); sl@0: CleanupStack::Pop(); sl@0: return control; sl@0: } sl@0: sl@0: CPrintDrvControl::~CPrintDrvControl() sl@0: { sl@0: delete iScanLine; sl@0: } sl@0: sl@0: CPrintDrvControl::CPrintDrvControl( CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort ): sl@0: CPdrControl( aPdrDevice, aPrinterPort ) sl@0: { sl@0: } sl@0: sl@0: void CPrintDrvControl::ConstructL( CStreamStore& aStore, TStreamId aResourcesStreamId ) sl@0: { sl@0: CPdrControl::ConstructL( aStore, aResourcesStreamId ); sl@0: TRect rect = iPdrDevice->PrintablePageInPixels(); sl@0: TSize size; sl@0: size.iWidth = iPdrDevice->HorizontalPixelsToTwips( 1000 ); sl@0: size.iHeight = iPdrDevice->VerticalPixelsToTwips( 1000 ); sl@0: iBandedDevice = CBandedDevice::NewL( rect, size, iPdrDevice->DisplayMode(), EBandingTopToBottom ); sl@0: iScanLine = HBufC8::NewL( CFbsBitmap::ScanLineLength( iBandedDevice->BandBitmap()->SizeInPixels().iWidth, iPdrDevice->DisplayMode() ) ); sl@0: } sl@0: sl@0: void CPrintDrvControl::OutputTextL( const TPoint& aPoint, TInt aWidthInPixels, const TTextFormat& aTextFormat, const TDesC8& aString ) sl@0: { sl@0: CPdrControl::OutputTextL( aPoint, aWidthInPixels, aTextFormat, aString ); sl@0: CommandL( EPdrResource1 ); sl@0: } sl@0: sl@0: void CPrintDrvControl::OutputBandL() sl@0: { sl@0: TRect bandrect = iBandedDevice->BandRect(); sl@0: TSize size = bandrect.Size(); sl@0: CommandL( EPdrBitmapStart ); sl@0: for ( TInt i = 0; iDes(); sl@0: // iBandedDevice->BandBitmap()->GetScanLine( ptr, TPoint( 0, i ), size.iWidth, iPdrDevice->DisplayMode() ); sl@0: // iPageBuffer->AddBytesL( ptr ); sl@0: CommandL( EPdrEndScanLine ); sl@0: } sl@0: CommandL( EPdrBitmapEnd ); sl@0: } sl@0: