os/graphics/printingservices/printerdrivers/general/GENERAL.CPP
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include <banddev.h>
    17 #include "GNRLSTD.H"
    18 #include "GENERAL.H"
    19 #include "pdrtext.h"
    20 
    21 
    22 EXPORT_C CPrinterDevice* NewPrinterDeviceL()
    23 	{
    24 	CGeneralPrinterDevice* device = new(ELeave) CGeneralPrinterDevice;
    25 	return device;
    26 	}
    27 
    28 CGeneralPrinterDevice::CGeneralPrinterDevice():
    29 CPdrDevice()
    30 	{
    31 	__DECLARE_NAME(_S("CGeneralDevice"));
    32 	}
    33 
    34 CGeneralPrinterDevice::~CGeneralPrinterDevice()
    35 	{
    36 	}
    37 
    38 TInt CGeneralPrinterDevice::CreateContext(CGraphicsContext*& aGC)
    39 	{
    40 	__ASSERT_DEBUG(iControl, Panic(EGeneralPrinterControlDoesNotExist));
    41 	CPdrControl* control = (CPdrControl*)iControl;
    42 	return control->CreateContext(aGC);
    43 	}
    44 
    45 TSize CGeneralPrinterDevice::KPixelSizeInTwips() const
    46 	{
    47 	return TSize(iModelInfo->iKPixelWidthInTwips, iModelInfo->iKPixelHeightInTwips);
    48 	}
    49 
    50 void CGeneralPrinterDevice::CreateControlL(CPrinterPort* aPrinterPort)
    51 	{
    52 	__ASSERT_ALWAYS(aPrinterPort, Panic(EGeneralPrinterRequiresPrinterPort));
    53 	__ASSERT_ALWAYS(!iControl, Panic(EGeneralPrinterControlAlreadyExists));
    54 	__ASSERT_DEBUG(iCurrentPageSpecInTwips.iPortraitPageSize.iWidth && iCurrentPageSpecInTwips.iPortraitPageSize.iHeight, Panic(EGeneralPrinterPageSpecNotSet));
    55 	iControl = CGeneralPrinterControl::NewL(this, aPrinterPort, *iStore, iModelInfo->iResourcesStreamId);
    56 	}
    57 
    58 CGeneralPrinterControl* CGeneralPrinterControl::NewL(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort, CStreamStore& aStore, TStreamId aResourcesStreamId)
    59 	{
    60 	CGeneralPrinterControl* control = new(ELeave) CGeneralPrinterControl(aPdrDevice, aPrinterPort);
    61 	CleanupStack::PushL(control);
    62 	control->ConstructL(aStore, aResourcesStreamId);
    63 	CleanupStack::Pop();
    64 	return control;
    65 	}
    66 
    67 CGeneralPrinterControl::~CGeneralPrinterControl()
    68 	{
    69 	}
    70 
    71 CGeneralPrinterControl::CGeneralPrinterControl(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort):
    72 	CPdrControl(aPdrDevice, aPrinterPort)
    73 	{
    74 	__DECLARE_NAME(_S("CGeneralPrinterControl"));
    75 	}
    76 
    77 void CGeneralPrinterControl::ConstructL(CStreamStore& aStore, TStreamId aResourcesStreamId)
    78 	{
    79 	if((iPdrDevice->CurrentPageSpecInTwips().iOrientation == TPageSpec::ELandscape)
    80 		&& (iPdrDevice->Flags() & EGeneralLandscapeNotAvailable))
    81 		User::Leave(KErrNotSupported);
    82 	CPdrControl::ConstructL(aStore, aResourcesStreamId);
    83 
    84 	const TRect rect = iPdrDevice->PrintablePageInPixels();
    85 	const TSize size(0,0);
    86 	iBandedDevice = CBandedDevice::NewL(rect, size, iPdrDevice->DisplayMode(), EBandingTopToBottom, 0);
    87 
    88 	iPageText = CPageText::NewL();
    89 	}
    90 
    91 void CGeneralPrinterControl::OutputTextL(const TPoint& aPoint, TInt aWidthInPixels, const TTextFormat& /*aTextFormat*/, const TDesC8& aString)
    92 	{
    93 	MoveByL(aPoint - iPosition);
    94 	iPageBuffer->AddBytesL(aString);
    95 	iPosition.iX += aWidthInPixels;
    96 	}
    97 
    98 void CGeneralPrinterControl::OutputBandL() 	
    99 	{
   100 	TInt numentries = iPageText->NumEntries();
   101 	iPosition = iPdrDevice->OffsetInPixels();
   102 	for(TInt i = 0; i < numentries; i++)	 
   103 		{
   104 		CPageTextEntry* entry = (*iPageText)[i];																						 //!!
   105 		OutputTextL(entry->iDrawPos, entry->iTextWidthInPixels, *entry->iTextFormat, entry->iText->Des());
   106 		}																										 //!!
   107 	iPageText->Reset();
   108 	}
   109