1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/printingservices/printerdriversupport/src/METAFILE.CPP Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1054 @@
1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <metafile.h>
1.20 +#include <bitdev.h>
1.21 +#include <fbs.h>
1.22 +
1.23 +NONSHARABLE_CLASS(CFontStack) : public CBase
1.24 + {
1.25 +protected:
1.26 + CFontStack(CGraphicsDevice* aDevice);
1.27 +public:
1.28 + static CFontStack* NewL(CGraphicsDevice* aDevice);
1.29 + ~CFontStack();
1.30 + void AddFontL(CFont* aFont);
1.31 +private:
1.32 + CGraphicsDevice* iDevice;
1.33 + CArrayPtrFlat<CFont>* iFontList;
1.34 + };
1.35 +
1.36 +CFontStack::CFontStack(CGraphicsDevice* aDevice):
1.37 + iDevice(aDevice),
1.38 + iFontList(NULL)
1.39 + {
1.40 + __DECLARE_NAME(_S("CFontStack"));
1.41 + }
1.42 +
1.43 +CFontStack* CFontStack::NewL(CGraphicsDevice* aDevice)
1.44 + {
1.45 + CFontStack* fontstack=new(ELeave) CFontStack(aDevice);
1.46 + CleanupStack::PushL(fontstack);
1.47 + fontstack->iFontList=new(ELeave) CArrayPtrFlat<CFont>(8);
1.48 + CleanupStack::Pop();
1.49 + return fontstack;
1.50 + }
1.51 +
1.52 +CFontStack::~CFontStack()
1.53 + {
1.54 + if (iFontList)
1.55 + {
1.56 + TInt count=iFontList->Count();
1.57 + for (TInt i=0; i<count; i++)
1.58 + iDevice->ReleaseFont((*iFontList)[i]);
1.59 + delete iFontList;
1.60 + }
1.61 + }
1.62 +
1.63 +void CFontStack::AddFontL(CFont* aFont)
1.64 + {
1.65 + TRAPD(ret,iFontList->AppendL(aFont));
1.66 + if (ret!=KErrNone)
1.67 + {
1.68 + iDevice->ReleaseFont(aFont);
1.69 + User::Leave(ret);
1.70 + }
1.71 + }
1.72 +
1.73 +enum TGraphicsContextCommandCode
1.74 + {
1.75 + EUseGc, // Not gc command
1.76 + EEndOfStream,
1.77 +
1.78 + ESetOrigin,
1.79 + ESetDrawMode,
1.80 + ESetClippingRect,
1.81 + ECancelClippingRect,
1.82 + EReset,
1.83 + EUseFont,
1.84 + EDiscardFont,
1.85 + ESetUnderlineStyle,
1.86 + ESetStrikethroughStyle,
1.87 + ESetWordJustification,
1.88 + ESetCharJustification,
1.89 + ESetPenColor,
1.90 + ESetPenStyle,
1.91 + ESetPenSize,
1.92 + ESetBrushColor,
1.93 + ESetBrushStyle,
1.94 + ESetBrushOrigin,
1.95 + EUseBrushPattern,
1.96 + EDiscardBrushPattern,
1.97 + EMoveTo,
1.98 + EMoveBy,
1.99 + EPlot,
1.100 + EDrawArc,
1.101 + EDrawLine,
1.102 + EDrawLineTo,
1.103 + EDrawLineBy,
1.104 + EDrawPolyLine1,
1.105 + EDrawPolyLine2,
1.106 + EDrawPie,
1.107 + EDrawEllipse,
1.108 + EDrawRect,
1.109 + EDrawRoundRect,
1.110 + EDrawPolygon1,
1.111 + EDrawPolygon2,
1.112 + EDrawBitmap1,
1.113 + EDrawBitmap2,
1.114 + EDrawBitmap3,
1.115 + EDrawText1,
1.116 + EDrawText2
1.117 + };
1.118 +
1.119 +inline RWriteStream& operator<<(RWriteStream& aStream,TGraphicsContextCommandCode aCommandCode)
1.120 + {
1.121 + aStream.WriteUint8L(TUint8(aCommandCode));
1.122 + return aStream;
1.123 + }
1.124 +
1.125 +EXPORT_C CMetafileDevice::CMetafileDevice(CGraphicsDevice* aDevice):
1.126 + CGraphicsDevice(),
1.127 + iGcCount(0),
1.128 + iGcIndex(-1),
1.129 + iRealDevice(aDevice),
1.130 + iWriteStream(NULL)
1.131 + {
1.132 + __DECLARE_NAME(_S("CMetafileDevice"));
1.133 + }
1.134 +
1.135 +EXPORT_C CMetafileDevice* CMetafileDevice::NewL(CGraphicsDevice* aDevice)
1.136 + {
1.137 + CMetafileDevice* device=new(ELeave) CMetafileDevice(aDevice);
1.138 + return device;
1.139 + }
1.140 +
1.141 +EXPORT_C CMetafileDevice::~CMetafileDevice()
1.142 + {
1.143 + }
1.144 +
1.145 +EXPORT_C TInt CMetafileDevice::HorizontalTwipsToPixels(TInt aTwips) const
1.146 + {
1.147 + return iRealDevice->HorizontalTwipsToPixels(aTwips);
1.148 + }
1.149 +
1.150 +EXPORT_C TInt CMetafileDevice::VerticalTwipsToPixels(TInt aTwips) const
1.151 + {
1.152 + return iRealDevice->VerticalTwipsToPixels(aTwips);
1.153 + }
1.154 +
1.155 +EXPORT_C TInt CMetafileDevice::HorizontalPixelsToTwips(TInt aPixels) const
1.156 + {
1.157 + return iRealDevice->HorizontalPixelsToTwips(aPixels);
1.158 + }
1.159 +
1.160 +EXPORT_C TInt CMetafileDevice::VerticalPixelsToTwips(TInt aPixels) const
1.161 + {
1.162 + return iRealDevice->VerticalPixelsToTwips(aPixels);
1.163 + }
1.164 +
1.165 +EXPORT_C TInt CMetafileDevice::GetNearestFontInTwips(CFont*& aFont,const TFontSpec& aFontSpec)
1.166 + {
1.167 + return GetNearestFontToDesignHeightInTwips(aFont, aFontSpec);
1.168 + }
1.169 +
1.170 +EXPORT_C TInt CMetafileDevice::GetNearestFontToDesignHeightInTwips(CFont*& aFont,const TFontSpec& aFontSpec)
1.171 + {
1.172 + return iRealDevice->GetNearestFontToDesignHeightInTwips(aFont,aFontSpec);
1.173 + }
1.174 +
1.175 +EXPORT_C TInt CMetafileDevice::GetNearestFontToMaxHeightInTwips(CFont*& aFont,const TFontSpec& aFontSpec, TInt aMaxHeight)
1.176 + {
1.177 + return iRealDevice->GetNearestFontToMaxHeightInTwips(aFont, aFontSpec, aMaxHeight);
1.178 + }
1.179 +
1.180 +EXPORT_C void CMetafileDevice::ReleaseFont(CFont* aFont)
1.181 + {
1.182 + iRealDevice->ReleaseFont(aFont);
1.183 + }
1.184 +
1.185 +EXPORT_C TDisplayMode CMetafileDevice::DisplayMode() const
1.186 + {
1.187 + return iRealDevice->DisplayMode();
1.188 + }
1.189 +
1.190 +EXPORT_C TSize CMetafileDevice::SizeInPixels() const
1.191 + {
1.192 + return iRealDevice->SizeInPixels();
1.193 + }
1.194 +
1.195 +EXPORT_C TSize CMetafileDevice::SizeInTwips() const
1.196 + {
1.197 + return iRealDevice->SizeInTwips();
1.198 + }
1.199 +
1.200 +EXPORT_C TInt CMetafileDevice::CreateContext(CGraphicsContext*& aGC)
1.201 + {
1.202 + CMetafileGc* gc=new CMetafileGc(this,iGcCount);
1.203 + if (!gc)
1.204 + return KErrNoMemory;
1.205 + iGcCount++;
1.206 + aGC=gc;
1.207 + return KErrNone;
1.208 + }
1.209 +
1.210 +EXPORT_C TInt CMetafileDevice::NumTypefaces() const
1.211 + {
1.212 + return iRealDevice->NumTypefaces();
1.213 + }
1.214 +
1.215 +EXPORT_C void CMetafileDevice::TypefaceSupport(TTypefaceSupport& aTypefaceSupport,TInt aTypefaceIndex) const
1.216 + {
1.217 + iRealDevice->TypefaceSupport(aTypefaceSupport,aTypefaceIndex);
1.218 + }
1.219 +
1.220 +EXPORT_C TInt CMetafileDevice::FontHeightInTwips(TInt aTypefaceIndex,TInt aHeightIndex) const
1.221 + {
1.222 + return iRealDevice->FontHeightInTwips(aTypefaceIndex,aHeightIndex);
1.223 + }
1.224 +
1.225 +EXPORT_C void CMetafileDevice::PaletteAttributes(TBool& aModifiable,TInt& aNumEntries) const
1.226 + {
1.227 + iRealDevice->PaletteAttributes(aModifiable,aNumEntries);
1.228 + }
1.229 +
1.230 +EXPORT_C void CMetafileDevice::SetPalette(CPalette* aPalette)
1.231 + {
1.232 + iRealDevice->SetPalette(aPalette);
1.233 + }
1.234 +
1.235 +EXPORT_C TInt CMetafileDevice::GetPalette(CPalette*& aPalette) const
1.236 + {
1.237 + return iRealDevice->GetPalette(aPalette);
1.238 + }
1.239 +
1.240 +EXPORT_C void CMetafileDevice::UseGcL(TInt aGcIndex)
1.241 + {
1.242 + if (iGcIndex!=aGcIndex)
1.243 + {
1.244 + iGcIndex=aGcIndex;
1.245 + *iWriteStream << EUseGc;
1.246 + iWriteStream->WriteInt32L(iGcIndex);
1.247 + }
1.248 + }
1.249 +
1.250 +EXPORT_C void CMetafileDevice::StartOutputStreamL(RWriteStream& aStream) // Returns error code
1.251 + {
1.252 + iWriteStream=&aStream;
1.253 + TSize size(HorizontalPixelsToTwips(1000),VerticalPixelsToTwips(1000));
1.254 + *iWriteStream << size;
1.255 + }
1.256 +
1.257 +EXPORT_C void CMetafileDevice::EndOfStreamL() // Returns error code
1.258 + {
1.259 + *iWriteStream << EEndOfStream;
1.260 + }
1.261 +
1.262 +EXPORT_C RWriteStream& CMetafileDevice::WriteStream()
1.263 + {
1.264 + return *iWriteStream;
1.265 + }
1.266 +
1.267 +EXPORT_C CMetafileGc::CMetafileGc(CMetafileDevice* aDevice,TInt anIndex):
1.268 + CGraphicsContext(),
1.269 + iDevice(aDevice),
1.270 + iIndex(anIndex)
1.271 + {
1.272 + }
1.273 +
1.274 +EXPORT_C CMetafileGc::~CMetafileGc()
1.275 + {
1.276 + }
1.277 +
1.278 +EXPORT_C CGraphicsDevice* CMetafileGc::Device() const
1.279 + {
1.280 + return iDevice;
1.281 + }
1.282 +
1.283 +EXPORT_C void CMetafileGc::SetOrigin(const TPoint& aPos)
1.284 + {
1.285 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.286 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.287 + iDevice->WriteStream() << ESetOrigin;
1.288 + iDevice->WriteStream() << aPos;
1.289 + }
1.290 +
1.291 +EXPORT_C void CMetafileGc::SetDrawMode(TDrawMode aDrawingMode)
1.292 + {
1.293 + TInt errCode = 0;
1.294 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.295 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.296 + iDevice->WriteStream() << ESetDrawMode;
1.297 + TRAP(errCode, iDevice->WriteStream().WriteUint8L((TUint8) aDrawingMode));
1.298 + }
1.299 +
1.300 +EXPORT_C void CMetafileGc::SetClippingRect(const TRect& aRect)
1.301 + {
1.302 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.303 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.304 + iDevice->WriteStream() << ESetClippingRect;
1.305 + iDevice->WriteStream() << aRect;
1.306 + }
1.307 +
1.308 +EXPORT_C void CMetafileGc::CancelClippingRect()
1.309 + {
1.310 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.311 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.312 + iDevice->WriteStream() << ECancelClippingRect;
1.313 + }
1.314 +
1.315 +EXPORT_C void CMetafileGc::Reset()
1.316 + {
1.317 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.318 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.319 + iDevice->WriteStream() << EReset;
1.320 + }
1.321 +
1.322 +EXPORT_C void CMetafileGc::UseFont(const CFont* aFont)
1.323 + {
1.324 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.325 + TInt errCode = 0;
1.326 + TRAP(errCode, iDevice->UseGcL(iIndex));
1.327 + iDevice->WriteStream() << EUseFont;
1.328 + iDevice->WriteStream() << aFont->FontSpecInTwips();
1.329 + TRAP(errCode, iDevice->WriteStream().WriteInt32L(aFont->HeightInPixels()));
1.330 + TRAP(errCode, iDevice->WriteStream().WriteInt32L(aFont->BaselineOffsetInPixels()));
1.331 + }
1.332 +
1.333 +EXPORT_C void CMetafileGc::DiscardFont()
1.334 + {
1.335 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.336 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.337 + iDevice->WriteStream() << EDiscardFont;
1.338 + }
1.339 +
1.340 +EXPORT_C void CMetafileGc::SetUnderlineStyle(TFontUnderline aUnderlineStyle)
1.341 + {
1.342 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.343 + TInt errCode = 0;
1.344 + TRAP(errCode, iDevice->UseGcL(iIndex));
1.345 + iDevice->WriteStream() << ESetUnderlineStyle;
1.346 + TRAP(errCode, iDevice->WriteStream().WriteUint8L((TUint8) aUnderlineStyle));
1.347 + }
1.348 +
1.349 +EXPORT_C void CMetafileGc::SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle)
1.350 + {
1.351 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.352 + TInt errCode = 0;
1.353 + TRAP(errCode, iDevice->UseGcL(iIndex));
1.354 + iDevice->WriteStream() << ESetStrikethroughStyle;
1.355 + TRAP(errCode, iDevice->WriteStream().WriteUint8L((TUint8) aStrikethroughStyle));
1.356 + }
1.357 +
1.358 +EXPORT_C void CMetafileGc::SetWordJustification(TInt aExcessWidth,TInt aNumGaps)
1.359 + {
1.360 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.361 + TInt errCode = 0;
1.362 + TRAP(errCode, iDevice->UseGcL(iIndex));
1.363 + iDevice->WriteStream() << ESetWordJustification;
1.364 + TRAP(errCode, iDevice->WriteStream().WriteInt32L(aExcessWidth));
1.365 + TRAP(errCode, iDevice->WriteStream().WriteInt32L(aNumGaps));
1.366 + }
1.367 +
1.368 +EXPORT_C void CMetafileGc::SetCharJustification(TInt aExcessWidth,TInt aNumChars)
1.369 + {
1.370 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.371 + TInt errCode = 0;
1.372 + TRAP(errCode, iDevice->UseGcL(iIndex));
1.373 + iDevice->WriteStream() << ESetCharJustification;
1.374 + TRAP(errCode, iDevice->WriteStream().WriteInt32L(aExcessWidth));
1.375 + TRAP(errCode, iDevice->WriteStream().WriteInt32L(aNumChars));
1.376 + }
1.377 +
1.378 +EXPORT_C void CMetafileGc::SetPenColor(const TRgb& aColor)
1.379 + {
1.380 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.381 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.382 + iDevice->WriteStream() << ESetPenColor;
1.383 + iDevice->WriteStream() << aColor;
1.384 + }
1.385 +
1.386 +EXPORT_C void CMetafileGc::SetPenStyle(TPenStyle aPenStyle)
1.387 + {
1.388 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.389 + TInt errCode = 0;
1.390 + TRAP(errCode, iDevice->UseGcL(iIndex));
1.391 + iDevice->WriteStream() << ESetPenStyle;
1.392 + TRAP(errCode, iDevice->WriteStream().WriteUint8L((TUint8) aPenStyle));
1.393 + }
1.394 +
1.395 +EXPORT_C void CMetafileGc::SetPenSize(const TSize& aSize)
1.396 + {
1.397 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.398 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.399 + iDevice->WriteStream() << ESetPenSize;
1.400 + iDevice->WriteStream() << aSize;
1.401 + }
1.402 +
1.403 +EXPORT_C void CMetafileGc::SetBrushColor(const TRgb& aColor)
1.404 + {
1.405 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.406 + TRAP_IGNORE( iDevice->UseGcL(iIndex));
1.407 + iDevice->WriteStream() << ESetBrushColor;
1.408 + iDevice->WriteStream() << aColor;
1.409 + }
1.410 +
1.411 +EXPORT_C void CMetafileGc::SetBrushStyle(TBrushStyle aBrushStyle)
1.412 + {
1.413 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.414 + TInt errCode = 0;
1.415 + TRAP(errCode, iDevice->UseGcL(iIndex));
1.416 + iDevice->WriteStream() << ESetBrushStyle;
1.417 + TRAP(errCode, iDevice->WriteStream().WriteUint8L((TUint8) aBrushStyle));
1.418 + }
1.419 +
1.420 +EXPORT_C void CMetafileGc::SetBrushOrigin(const TPoint& aOrigin)
1.421 + {
1.422 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.423 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.424 + iDevice->WriteStream() << ESetBrushOrigin;
1.425 + iDevice->WriteStream() << aOrigin;
1.426 + }
1.427 +
1.428 +EXPORT_C void CMetafileGc::UseBrushPattern(const CFbsBitmap* aBitmap)
1.429 + {
1.430 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.431 + TInt errCode = 0;
1.432 + TRAP(errCode, iDevice->UseGcL(iIndex));
1.433 + iDevice->WriteStream() << EUseBrushPattern;
1.434 + TRAP(errCode, aBitmap->ExternalizeL(iDevice->WriteStream()));
1.435 + }
1.436 +
1.437 +EXPORT_C void CMetafileGc::DiscardBrushPattern()
1.438 + {
1.439 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.440 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.441 + iDevice->WriteStream() << EDiscardBrushPattern;
1.442 + }
1.443 +
1.444 +EXPORT_C void CMetafileGc::MoveTo(const TPoint& aPoint)
1.445 + {
1.446 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.447 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.448 + iDevice->WriteStream() << EMoveTo;
1.449 + iDevice->WriteStream() << aPoint;
1.450 + }
1.451 +
1.452 +EXPORT_C void CMetafileGc::MoveBy(const TPoint& aVector)
1.453 + {
1.454 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.455 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.456 + iDevice->WriteStream() << EMoveBy;
1.457 + iDevice->WriteStream() << aVector;
1.458 + }
1.459 +
1.460 +EXPORT_C void CMetafileGc::Plot(const TPoint& aPoint)
1.461 + {
1.462 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.463 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.464 + iDevice->WriteStream() << EPlot;
1.465 + iDevice->WriteStream() << aPoint;
1.466 + }
1.467 +
1.468 +EXPORT_C void CMetafileGc::DrawArc(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd)
1.469 + {
1.470 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.471 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.472 + iDevice->WriteStream() << EDrawArc;
1.473 + iDevice->WriteStream() << aRect;
1.474 + iDevice->WriteStream() << aStart;
1.475 + iDevice->WriteStream() << aEnd;
1.476 + }
1.477 +
1.478 +EXPORT_C void CMetafileGc::DrawLine(const TPoint& aPoint1,const TPoint& aPoint2)
1.479 + {
1.480 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.481 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.482 + iDevice->WriteStream() << EDrawLine;
1.483 + iDevice->WriteStream() << aPoint1;
1.484 + iDevice->WriteStream() << aPoint2;
1.485 + }
1.486 +
1.487 +EXPORT_C void CMetafileGc::DrawLineTo(const TPoint& aPoint)
1.488 + {
1.489 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.490 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.491 + iDevice->WriteStream() << EDrawLineTo;
1.492 + iDevice->WriteStream() << aPoint;
1.493 + }
1.494 +
1.495 +EXPORT_C void CMetafileGc::DrawLineBy(const TPoint& aVector)
1.496 + {
1.497 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.498 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.499 + iDevice->WriteStream() << EDrawLineBy;
1.500 + iDevice->WriteStream() << aVector;
1.501 + }
1.502 +
1.503 +EXPORT_C void CMetafileGc::DrawPolyLine(const CArrayFix<TPoint>* aPointList)
1.504 + {
1.505 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.506 + TInt errCode = 0;
1.507 + TRAP(errCode, iDevice->UseGcL(iIndex));
1.508 + iDevice->WriteStream() << EDrawPolyLine1;
1.509 +
1.510 + TInt numpoints=aPointList->Count();
1.511 + TRAP(errCode, iDevice->WriteStream().WriteInt32L(numpoints));
1.512 + for (TInt i=0; i<numpoints; i++)
1.513 + iDevice->WriteStream() << (*aPointList)[i];
1.514 + }
1.515 +
1.516 +EXPORT_C void CMetafileGc::DrawPolyLine(const TPoint* aPointList,TInt aNumPoints)
1.517 + {
1.518 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.519 + TInt errCode = 0;
1.520 + TRAP(errCode, iDevice->UseGcL(iIndex));
1.521 + iDevice->WriteStream() << EDrawPolyLine2;
1.522 + TRAP(errCode, iDevice->WriteStream().WriteInt32L(aNumPoints));
1.523 + TPoint *p=(TPoint*) aPointList,*pEnd=p+aNumPoints;
1.524 + for (; p<pEnd; p++)
1.525 + iDevice->WriteStream() << *p;
1.526 + }
1.527 +
1.528 +EXPORT_C void CMetafileGc::DrawPie(const TRect& aRect,const TPoint& aStart,const TPoint& aEnd)
1.529 + {
1.530 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.531 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.532 + iDevice->WriteStream() << EDrawPie;
1.533 + iDevice->WriteStream() << aRect;
1.534 + iDevice->WriteStream() << aStart;
1.535 + iDevice->WriteStream() << aEnd;
1.536 + }
1.537 +
1.538 +EXPORT_C void CMetafileGc::DrawEllipse(const TRect& aRect)
1.539 + {
1.540 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.541 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.542 + iDevice->WriteStream() << EDrawEllipse;
1.543 + iDevice->WriteStream() << aRect;
1.544 + }
1.545 +
1.546 +EXPORT_C void CMetafileGc::DrawRect(const TRect& aRect)
1.547 + {
1.548 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.549 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.550 + iDevice->WriteStream() << EDrawRect;
1.551 + iDevice->WriteStream() << aRect;
1.552 + }
1.553 +
1.554 +EXPORT_C void CMetafileGc::DrawRoundRect(const TRect& aRect,const TSize& aCornerSize)
1.555 + {
1.556 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.557 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.558 + iDevice->WriteStream() << EDrawRoundRect;
1.559 + iDevice->WriteStream() << aRect;
1.560 + iDevice->WriteStream() << aCornerSize;
1.561 + }
1.562 +
1.563 +EXPORT_C TInt CMetafileGc::DrawPolygon(const CArrayFix<TPoint>* aPointList,TFillRule aFillRule)
1.564 + {
1.565 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.566 + TInt errCode = 0;
1.567 + TRAP(errCode, iDevice->UseGcL(iIndex));
1.568 + iDevice->WriteStream() << EDrawPolygon1;
1.569 + TInt numpoints=aPointList->Count();
1.570 + TRAP(errCode, iDevice->WriteStream().WriteInt32L(numpoints));
1.571 + for (TInt i=0; i<numpoints; i++)
1.572 + iDevice->WriteStream() << (*aPointList)[i];
1.573 + TRAP(errCode, iDevice->WriteStream().WriteUint8L((TUint8) aFillRule));
1.574 + return KErrNone;
1.575 + }
1.576 +
1.577 +EXPORT_C TInt CMetafileGc::DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule aFillRule)
1.578 + {
1.579 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.580 + TInt errCode = 0;
1.581 + TRAP(errCode, iDevice->UseGcL(iIndex));
1.582 + iDevice->WriteStream() << EDrawPolygon2;
1.583 + TRAP(errCode, iDevice->WriteStream().WriteInt32L(aNumPoints));
1.584 + TPoint *p=(TPoint*) aPointList,*pEnd=p+aNumPoints;
1.585 + for (; p<pEnd; p++)
1.586 + iDevice->WriteStream() << *p;
1.587 + TRAP(errCode, iDevice->WriteStream().WriteUint8L((TUint8) aFillRule));
1.588 + return KErrNone;
1.589 + }
1.590 +
1.591 +EXPORT_C void CMetafileGc::DrawBitmap(const TPoint& aTopLeft,const CFbsBitmap* aSource)
1.592 + {
1.593 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.594 + TInt errCode = 0;
1.595 + TRAP(errCode, iDevice->UseGcL(iIndex));
1.596 + iDevice->WriteStream() << EDrawBitmap1;
1.597 + iDevice->WriteStream() << aTopLeft;
1.598 + TRAP(errCode, ExternalizeBitmapL(aSource));
1.599 + }
1.600 +
1.601 +EXPORT_C void CMetafileGc::DrawBitmap(const TRect& aDestRect,const CFbsBitmap* aSource)
1.602 + {
1.603 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.604 + TInt errCode = 0;
1.605 + TRAP(errCode, iDevice->UseGcL(iIndex));
1.606 + iDevice->WriteStream() << EDrawBitmap2;
1.607 + iDevice->WriteStream() << aDestRect;
1.608 + TRAP(errCode, ExternalizeBitmapL(aSource));
1.609 + }
1.610 +
1.611 +EXPORT_C void CMetafileGc::DrawBitmap(const TRect& aDestRect,const CFbsBitmap* aSource,const TRect& aSourceRect)
1.612 + {
1.613 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.614 + TInt errCode = 0;
1.615 + TRAP(errCode, iDevice->UseGcL(iIndex));
1.616 + iDevice->WriteStream() << EDrawBitmap3;
1.617 + iDevice->WriteStream() << aDestRect;
1.618 + TRAP(errCode, ExternalizeBitmapL(aSource));
1.619 + iDevice->WriteStream() << aSourceRect;
1.620 + }
1.621 +
1.622 +EXPORT_C void CMetafileGc::DrawBitmapMasked(const TRect& /*aDestRect*/,const CFbsBitmap* /*aBitmap*/,const TRect& /*aSourceRect*/,const CFbsBitmap* /*aMaskBitmap*/,TBool /*aInvertMask*/)
1.623 + {}
1.624 +
1.625 +EXPORT_C void CMetafileGc::DrawBitmapMasked(const TRect& /*aDestRect*/,const CWsBitmap* /*aBitmap*/,const TRect& /*aSourceRect*/,const CWsBitmap* /*aMaskBitmap*/,TBool /*aInvertMask*/)
1.626 + {}
1.627 +
1.628 +EXPORT_C void CMetafileGc::MapColors(const TRect& /*aRect*/,const TRgb* /*aColors*/,TInt /*aNumPairs*/,TBool /*aMapForwards*/)
1.629 + {}
1.630 +
1.631 +EXPORT_C TInt CMetafileGc::SetClippingRegion(const TRegion &/*aRegion*/)
1.632 + {
1.633 + return KErrNone;
1.634 + }
1.635 +
1.636 +EXPORT_C void CMetafileGc::CancelClippingRegion()
1.637 + {}
1.638 +
1.639 +EXPORT_C void CMetafileGc::DrawTextVertical(const TDesC& /*aText*/,const TPoint& /*aPos*/,TBool /*aUp*/)
1.640 + {}
1.641 +
1.642 +EXPORT_C void CMetafileGc::DrawTextVertical(const TDesC& /*aText*/,const TRect& /*aBox*/,TInt /*aBaselineOffset*/,TBool /*aUp*/,TTextAlign /*aVert*/,TInt /*aMargin*/)
1.643 + {}
1.644 +
1.645 +EXPORT_C TInt CMetafileGc::AlphaBlendBitmaps(const TPoint& /*aDestPt*/, const CFbsBitmap* /*aSrcBmp*/, const TRect& /*aSrcRect*/, const CFbsBitmap* /*aAlphaBmp*/, const TPoint& /*aAlphaPt*/)
1.646 + {
1.647 + return KErrNone;
1.648 + }
1.649 +
1.650 +EXPORT_C TInt CMetafileGc::AlphaBlendBitmaps(const TPoint& /*aDestPt*/, const CWsBitmap* /*aSrcBmp*/, const TRect& /*aSrcRect*/, const CWsBitmap* /*aAlphaBmp*/, const TPoint& /*aAlphaPt*/)
1.651 + {
1.652 + return KErrNone;
1.653 + }
1.654 +
1.655 +
1.656 +EXPORT_C void CMetafileGc::DrawText(const TDesC& aString,const TPoint& aPosition)
1.657 + {
1.658 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.659 + TRAP_IGNORE(iDevice->UseGcL(iIndex));
1.660 + iDevice->WriteStream() << EDrawText1;
1.661 + iDevice->WriteStream() << aString;
1.662 + iDevice->WriteStream() << aPosition;
1.663 + }
1.664 +
1.665 +EXPORT_C void CMetafileGc::DrawText(const TDesC& aString,const TRect& aBox,TInt aBaselineOffset,TTextAlign aHoriz,TInt aLeftMrg)
1.666 + {
1.667 + // TRAP and ignore the ERROR code due to this beeing a non-leaving method
1.668 + TInt errCode = 0;
1.669 + TRAP(errCode, iDevice->UseGcL(iIndex));
1.670 + iDevice->WriteStream() << EDrawText2;
1.671 + iDevice->WriteStream() << aString;
1.672 + iDevice->WriteStream() << aBox;
1.673 + TRAP(errCode, iDevice->WriteStream().WriteInt32L(aBaselineOffset));
1.674 + TRAP(errCode, iDevice->WriteStream().WriteUint8L((TUint8) aHoriz));
1.675 + TRAP(errCode, iDevice->WriteStream().WriteInt32L(aLeftMrg));
1.676 + }
1.677 +
1.678 +void CMetafileGc::ExternalizeBitmapL(const CFbsBitmap* aSource)
1.679 + {
1.680 + CFbsBitmap* bitmap=new(ELeave) CFbsBitmap;
1.681 + CleanupStack::PushL(bitmap);
1.682 + User::LeaveIfError(bitmap->Create(aSource->SizeInPixels(),iDevice->DisplayMode()));
1.683 + CFbsBitmapDevice* bitmapdevice=CFbsBitmapDevice::NewL(bitmap);
1.684 + CleanupStack::PushL(bitmapdevice);
1.685 + CFbsBitGc* gc;
1.686 + User::LeaveIfError(bitmapdevice->CreateContext((CGraphicsContext*&) gc));
1.687 + CleanupStack::PushL(gc);
1.688 + gc->BitBlt(TPoint(0,0),aSource);
1.689 + bitmap->ExternalizeL(iDevice->WriteStream());
1.690 + CleanupStack::PopAndDestroy(3);
1.691 + }
1.692 +
1.693 +EXPORT_C CMetafilePlayback::CMetafilePlayback(CGraphicsDevice* aDevice):
1.694 + iDevice(aDevice)
1.695 + {
1.696 + __DECLARE_NAME(_S("CMetafilePlayback"));
1.697 + }
1.698 +
1.699 +EXPORT_C CMetafilePlayback* CMetafilePlayback::NewL(CGraphicsDevice* aDevice)
1.700 + {
1.701 + CMetafilePlayback* playback=new(ELeave) CMetafilePlayback(aDevice);
1.702 + return playback;
1.703 + }
1.704 +
1.705 +EXPORT_C CMetafilePlayback::~CMetafilePlayback()
1.706 + {
1.707 + }
1.708 +
1.709 +
1.710 +EXPORT_C void CMetafilePlayback::DrawL(RReadStream& aReadStream)
1.711 + {
1.712 + CArrayPtrFlat<CGraphicsContext>* gclist=new(ELeave) CArrayPtrFlat<CGraphicsContext>(8);
1.713 + CleanupStack::PushL(gclist);
1.714 + CFontStack* fontstack = CFontStack::NewL(iDevice);
1.715 + CleanupStack::PushL(fontstack);
1.716 + CArrayFixFlat<TPoint>* pointlist=new(ELeave) CArrayFixFlat<TPoint>(8);
1.717 + CleanupStack::PushL(pointlist);
1.718 + CFbsBitmap* bitmap=new(ELeave) CFbsBitmap;
1.719 + CleanupStack::PushL(bitmap);
1.720 + TSize kpixelsizeintwips;
1.721 + aReadStream >> kpixelsizeintwips;
1.722 + TGraphicsContextCommandCode code;
1.723 + TInt gcindex=0;
1.724 + do
1.725 + {
1.726 + code = (TGraphicsContextCommandCode) aReadStream.ReadUint8L();
1.727 + switch (code)
1.728 + {
1.729 + case EUseGc:
1.730 + {
1.731 + TInt gcindex=aReadStream.ReadInt32L();
1.732 + if (gcindex>=gclist->Count())
1.733 + {
1.734 + for (TInt i=gclist->Count(); i<=gcindex; i++)
1.735 + {
1.736 + CGraphicsContext* gc;
1.737 + User::LeaveIfError(iDevice->CreateContext(gc));
1.738 + CleanupStack::PushL(gc);
1.739 + gclist->AppendL(gc);
1.740 + }
1.741 + }
1.742 +
1.743 + break;
1.744 + }
1.745 + case EEndOfStream:
1.746 + {
1.747 + break;
1.748 + }
1.749 + case ESetOrigin:
1.750 + {
1.751 + TPoint pos;
1.752 + aReadStream >> pos;
1.753 + (*gclist)[gcindex]->SetOrigin(pos);
1.754 + break;
1.755 + }
1.756 + case ESetDrawMode:
1.757 + {
1.758 + CGraphicsContext::TDrawMode drawingmode;
1.759 + drawingmode = (CGraphicsContext::TDrawMode) aReadStream.ReadUint8L();
1.760 + (*gclist)[gcindex]->SetDrawMode(drawingmode);
1.761 + break;
1.762 + }
1.763 + case ESetClippingRect:
1.764 + {
1.765 + TRect rect;
1.766 + aReadStream >> rect;
1.767 + (*gclist)[gcindex]->SetClippingRect(rect);
1.768 + break;
1.769 + }
1.770 + case ECancelClippingRect:
1.771 + {
1.772 + (*gclist)[gcindex]->CancelClippingRect();
1.773 + break;
1.774 + }
1.775 + case EReset:
1.776 + {
1.777 + (*gclist)[gcindex]->CancelClippingRect();
1.778 + break;
1.779 + }
1.780 + case EUseFont:
1.781 + {
1.782 + TFontSpec spec;
1.783 + aReadStream >> spec;
1.784 + aReadStream.ReadInt32L(); // height in pixels
1.785 + aReadStream.ReadInt32L(); // baseline offset in pixels
1.786 + spec.iHeight=((spec.iHeight*iDevice->VerticalPixelsToTwips(1000))+(kpixelsizeintwips.iHeight/2))/kpixelsizeintwips.iHeight;
1.787 + CFont* font;
1.788 + User::LeaveIfError(iDevice->GetNearestFontToDesignHeightInTwips(font,spec));
1.789 + fontstack->AddFontL(font);
1.790 + (*gclist)[gcindex]->UseFont(font);
1.791 + break;
1.792 + }
1.793 + case EDiscardFont:
1.794 + {
1.795 + (*gclist)[gcindex]->DiscardFont();
1.796 + break;
1.797 + }
1.798 + case ESetUnderlineStyle:
1.799 + {
1.800 + TFontUnderline underlinestyle;
1.801 + underlinestyle = (TFontUnderline) aReadStream.ReadUint8L();
1.802 + (*gclist)[gcindex]->SetUnderlineStyle(underlinestyle);
1.803 + break;
1.804 + }
1.805 + case ESetStrikethroughStyle:
1.806 + {
1.807 + TFontStrikethrough strikethroughstyle;
1.808 + strikethroughstyle = (TFontStrikethrough) aReadStream.ReadUint8L();
1.809 + (*gclist)[gcindex]->SetStrikethroughStyle(strikethroughstyle);
1.810 + break;
1.811 + }
1.812 + case ESetWordJustification:
1.813 + {
1.814 + TInt excesswidth,numgaps;
1.815 + excesswidth=aReadStream.ReadInt32L();
1.816 + numgaps=aReadStream.ReadInt32L();
1.817 + (*gclist)[gcindex]->SetWordJustification(excesswidth,numgaps);
1.818 + break;
1.819 + }
1.820 + case ESetCharJustification:
1.821 + {
1.822 + TInt excesswidth,numgaps;
1.823 + excesswidth=aReadStream.ReadInt32L();
1.824 + numgaps=aReadStream.ReadInt32L();
1.825 + (*gclist)[gcindex]->SetCharJustification(excesswidth,numgaps);
1.826 + break;
1.827 + }
1.828 + case ESetPenColor:
1.829 + {
1.830 + TRgb color;
1.831 + aReadStream >> color;
1.832 + (*gclist)[gcindex]->SetPenColor(color);
1.833 + break;
1.834 + }
1.835 + case ESetPenStyle:
1.836 + {
1.837 + CGraphicsContext::TPenStyle penstyle;
1.838 + penstyle=(CGraphicsContext::TPenStyle) aReadStream.ReadUint8L();
1.839 + (*gclist)[gcindex]->SetPenStyle(penstyle);
1.840 + break;
1.841 + }
1.842 + case ESetPenSize:
1.843 + {
1.844 + TSize size;
1.845 + aReadStream >> size;
1.846 + (*gclist)[gcindex]->SetPenSize(size);
1.847 + break;
1.848 + }
1.849 + case ESetBrushColor:
1.850 + {
1.851 + TRgb color;
1.852 + aReadStream >> color;
1.853 + (*gclist)[gcindex]->SetBrushColor(color);
1.854 + break;
1.855 + }
1.856 + case ESetBrushStyle:
1.857 + {
1.858 + CGraphicsContext::TBrushStyle brushstyle;
1.859 + brushstyle = (CGraphicsContext::TBrushStyle) aReadStream.ReadUint8L();
1.860 + (*gclist)[gcindex]->SetBrushStyle(brushstyle);
1.861 + break;
1.862 + }
1.863 + case ESetBrushOrigin:
1.864 + {
1.865 + TPoint origin;
1.866 + aReadStream >> origin;
1.867 + (*gclist)[gcindex]->SetBrushOrigin(origin);
1.868 + break;
1.869 + }
1.870 + case EUseBrushPattern:
1.871 + {
1.872 + bitmap->InternalizeL(aReadStream);
1.873 + (*gclist)[gcindex]->UseBrushPattern(bitmap);
1.874 + bitmap->Reset();
1.875 + break;
1.876 + }
1.877 + case EDiscardBrushPattern:
1.878 + {
1.879 + (*gclist)[gcindex]->DiscardBrushPattern();
1.880 + break;
1.881 + }
1.882 + case EMoveTo:
1.883 + {
1.884 + TPoint point;
1.885 + aReadStream >> point;
1.886 + (*gclist)[gcindex]->MoveTo(point);
1.887 + break;
1.888 + }
1.889 + case EMoveBy:
1.890 + {
1.891 + TPoint vector;
1.892 + aReadStream >> vector;
1.893 + (*gclist)[gcindex]->MoveBy(vector);
1.894 + break;
1.895 + }
1.896 + case EPlot:
1.897 + {
1.898 + TPoint point;
1.899 + aReadStream >> point;
1.900 + (*gclist)[gcindex]->Plot(point);
1.901 + break;
1.902 + }
1.903 + case EDrawArc:
1.904 + {
1.905 + TRect rect;
1.906 + aReadStream >> rect;
1.907 + TPoint start,end;
1.908 + aReadStream >> start;
1.909 + aReadStream >> end;
1.910 + (*gclist)[gcindex]->DrawArc(rect,start,end);
1.911 + break;
1.912 + }
1.913 + case EDrawLine:
1.914 + {
1.915 + TPoint point1,point2;
1.916 + aReadStream >> point1;
1.917 + aReadStream >> point2;
1.918 + (*gclist)[gcindex]->DrawLine(point1,point2);
1.919 + break;
1.920 + }
1.921 + case EDrawLineTo:
1.922 + {
1.923 + TPoint point;
1.924 + aReadStream >> point;
1.925 + (*gclist)[gcindex]->DrawLineTo(point);
1.926 + break;
1.927 + }
1.928 + case EDrawLineBy:
1.929 + {
1.930 + TPoint vector;
1.931 + aReadStream >> vector;
1.932 + (*gclist)[gcindex]->DrawLineBy(vector);
1.933 + break;
1.934 + }
1.935 + case EDrawPolyLine1:
1.936 + {
1.937 + }
1.938 + case EDrawPolyLine2:
1.939 + {
1.940 + TInt numpoints;
1.941 + numpoints=aReadStream.ReadInt32L();
1.942 + for (TInt i=0; i<numpoints; i++)
1.943 + {
1.944 + TPoint point;
1.945 + aReadStream >> point;
1.946 + pointlist->AppendL(point);
1.947 + }
1.948 + (*gclist)[gcindex]->DrawPolyLine(pointlist);
1.949 + pointlist->Reset();
1.950 + break;
1.951 + }
1.952 + case EDrawPie:
1.953 + {
1.954 + TRect rect;
1.955 + aReadStream >> rect;
1.956 + TPoint start,end;
1.957 + aReadStream >> start;
1.958 + aReadStream >> end;
1.959 + (*gclist)[gcindex]->DrawPie(rect,start,end);
1.960 + break;
1.961 + }
1.962 + case EDrawEllipse:
1.963 + {
1.964 + TRect rect;
1.965 + aReadStream >> rect;
1.966 + (*gclist)[gcindex]->DrawEllipse(rect);
1.967 + break;
1.968 + }
1.969 + case EDrawRect:
1.970 + {
1.971 + TRect rect;
1.972 + aReadStream >> rect;
1.973 + (*gclist)[gcindex]->DrawRect(rect);
1.974 + break;
1.975 + }
1.976 + case EDrawRoundRect:
1.977 + {
1.978 + TRect rect;
1.979 + aReadStream >> rect;
1.980 + TSize cornersize;
1.981 + aReadStream >> cornersize;
1.982 + (*gclist)[gcindex]->DrawRoundRect(rect,cornersize);
1.983 + break;
1.984 + }
1.985 + case EDrawPolygon1:
1.986 + {
1.987 + }
1.988 + case EDrawPolygon2:
1.989 + {
1.990 + TInt numpoints;
1.991 + numpoints=aReadStream.ReadInt32L();
1.992 + for (TInt i=0; i<numpoints; i++)
1.993 + {
1.994 + TPoint point;
1.995 + aReadStream >> point;
1.996 + pointlist->AppendL(point);
1.997 + }
1.998 + CGraphicsContext::TFillRule fillrule=(CGraphicsContext::TFillRule) aReadStream.ReadUint8L();
1.999 + (*gclist)[gcindex]->DrawPolygon(pointlist,fillrule);
1.1000 + pointlist->Reset();
1.1001 + break;
1.1002 + }
1.1003 + case EDrawBitmap1:
1.1004 + {
1.1005 + TPoint topleft;
1.1006 + aReadStream >> topleft;
1.1007 + bitmap->InternalizeL(aReadStream);
1.1008 + (*gclist)[gcindex]->DrawBitmap(topleft,bitmap);
1.1009 + bitmap->Reset();
1.1010 + break;
1.1011 + }
1.1012 + case EDrawBitmap2:
1.1013 + {
1.1014 + TRect destrect;
1.1015 + aReadStream >> destrect;
1.1016 + bitmap->InternalizeL(aReadStream);
1.1017 + (*gclist)[gcindex]->DrawBitmap(destrect,bitmap);
1.1018 + bitmap->Reset();
1.1019 + break;
1.1020 + }
1.1021 + case EDrawBitmap3:
1.1022 + {
1.1023 + TRect destrect;
1.1024 + aReadStream >> destrect;
1.1025 + bitmap->InternalizeL(aReadStream);
1.1026 + TRect sourcerect;
1.1027 + aReadStream >> sourcerect;
1.1028 + (*gclist)[gcindex]->DrawBitmap(destrect,bitmap,sourcerect);
1.1029 + bitmap->Reset();
1.1030 + break;
1.1031 + }
1.1032 + case EDrawText1:
1.1033 + {
1.1034 + HBufC* string=HBufC::NewLC(aReadStream,KMaxTInt);
1.1035 + TPoint position;
1.1036 + aReadStream >> position;
1.1037 + (*gclist)[gcindex]->DrawText(*string,position);
1.1038 + CleanupStack::PopAndDestroy();
1.1039 + break;
1.1040 + }
1.1041 + case EDrawText2:
1.1042 + {
1.1043 + HBufC* string=HBufC::NewLC(aReadStream,KMaxTInt);
1.1044 + TRect box;
1.1045 + aReadStream >> box;
1.1046 + TInt baselineoffset=aReadStream.ReadInt32L();
1.1047 + CGraphicsContext::TTextAlign horiz=(CGraphicsContext::TTextAlign) aReadStream.ReadUint8L();
1.1048 + TInt leftmrg=aReadStream.ReadInt32L();
1.1049 + (*gclist)[gcindex]->DrawText(*string,box,baselineoffset,horiz,leftmrg);
1.1050 + CleanupStack::PopAndDestroy();
1.1051 + break;
1.1052 + }
1.1053 + }
1.1054 + }
1.1055 + while (code!=EEndOfStream);
1.1056 + CleanupStack::PopAndDestroy(gclist->Count()+4);
1.1057 + }