sl@0: // Copyright (c) 1997-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 sl@0: #include "GNRLSTD.H" sl@0: #include "GENERAL.H" sl@0: #include "pdrtext.h" sl@0: sl@0: sl@0: EXPORT_C CPrinterDevice* NewPrinterDeviceL() sl@0: { sl@0: CGeneralPrinterDevice* device = new(ELeave) CGeneralPrinterDevice; sl@0: return device; sl@0: } sl@0: sl@0: CGeneralPrinterDevice::CGeneralPrinterDevice(): sl@0: CPdrDevice() sl@0: { sl@0: __DECLARE_NAME(_S("CGeneralDevice")); sl@0: } sl@0: sl@0: CGeneralPrinterDevice::~CGeneralPrinterDevice() sl@0: { sl@0: } sl@0: sl@0: TInt CGeneralPrinterDevice::CreateContext(CGraphicsContext*& aGC) sl@0: { sl@0: __ASSERT_DEBUG(iControl, Panic(EGeneralPrinterControlDoesNotExist)); sl@0: CPdrControl* control = (CPdrControl*)iControl; sl@0: return control->CreateContext(aGC); sl@0: } sl@0: sl@0: TSize CGeneralPrinterDevice::KPixelSizeInTwips() const sl@0: { sl@0: return TSize(iModelInfo->iKPixelWidthInTwips, iModelInfo->iKPixelHeightInTwips); sl@0: } sl@0: sl@0: void CGeneralPrinterDevice::CreateControlL(CPrinterPort* aPrinterPort) sl@0: { sl@0: __ASSERT_ALWAYS(aPrinterPort, Panic(EGeneralPrinterRequiresPrinterPort)); sl@0: __ASSERT_ALWAYS(!iControl, Panic(EGeneralPrinterControlAlreadyExists)); sl@0: __ASSERT_DEBUG(iCurrentPageSpecInTwips.iPortraitPageSize.iWidth && iCurrentPageSpecInTwips.iPortraitPageSize.iHeight, Panic(EGeneralPrinterPageSpecNotSet)); sl@0: iControl = CGeneralPrinterControl::NewL(this, aPrinterPort, *iStore, iModelInfo->iResourcesStreamId); sl@0: } sl@0: sl@0: CGeneralPrinterControl* CGeneralPrinterControl::NewL(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort, CStreamStore& aStore, TStreamId aResourcesStreamId) sl@0: { sl@0: CGeneralPrinterControl* control = new(ELeave) CGeneralPrinterControl(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: CGeneralPrinterControl::~CGeneralPrinterControl() sl@0: { sl@0: } sl@0: sl@0: CGeneralPrinterControl::CGeneralPrinterControl(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort): sl@0: CPdrControl(aPdrDevice, aPrinterPort) sl@0: { sl@0: __DECLARE_NAME(_S("CGeneralPrinterControl")); sl@0: } sl@0: sl@0: void CGeneralPrinterControl::ConstructL(CStreamStore& aStore, TStreamId aResourcesStreamId) sl@0: { sl@0: if((iPdrDevice->CurrentPageSpecInTwips().iOrientation == TPageSpec::ELandscape) sl@0: && (iPdrDevice->Flags() & EGeneralLandscapeNotAvailable)) sl@0: User::Leave(KErrNotSupported); sl@0: CPdrControl::ConstructL(aStore, aResourcesStreamId); sl@0: sl@0: const TRect rect = iPdrDevice->PrintablePageInPixels(); sl@0: const TSize size(0,0); sl@0: iBandedDevice = CBandedDevice::NewL(rect, size, iPdrDevice->DisplayMode(), EBandingTopToBottom, 0); sl@0: sl@0: iPageText = CPageText::NewL(); sl@0: } sl@0: sl@0: void CGeneralPrinterControl::OutputTextL(const TPoint& aPoint, TInt aWidthInPixels, const TTextFormat& /*aTextFormat*/, const TDesC8& aString) sl@0: { sl@0: MoveByL(aPoint - iPosition); sl@0: iPageBuffer->AddBytesL(aString); sl@0: iPosition.iX += aWidthInPixels; sl@0: } sl@0: sl@0: void CGeneralPrinterControl::OutputBandL() sl@0: { sl@0: TInt numentries = iPageText->NumEntries(); sl@0: iPosition = iPdrDevice->OffsetInPixels(); sl@0: for(TInt i = 0; i < numentries; i++) sl@0: { sl@0: CPageTextEntry* entry = (*iPageText)[i]; //!! sl@0: OutputTextL(entry->iDrawPos, entry->iTextWidthInPixels, *entry->iTextFormat, entry->iText->Des()); sl@0: } //!! sl@0: iPageText->Reset(); sl@0: } sl@0: