1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/printingservices/printerdriversupport/inc/PDRSTORE.H Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,443 @@
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 +#ifndef PDRSTORE_H
1.20 +#define PDRSTORE_H
1.21 +
1.22 +/**
1.23 +@file
1.24 +@publishedAll
1.25 +@released
1.26 +*/
1.27 +
1.28 +#include <s32mem.h>
1.29 +#include <gdi.h>
1.30 +#include <fbs.h>
1.31 +
1.32 +class CPdrControl;
1.33 +class CStreamStore;
1.34 +class CBandedDevice;
1.35 +
1.36 +/**
1.37 +Codes used by printer drivers.
1.38 +*/
1.39 +enum TFbsEncoding
1.40 + {
1.41 + /** No code. */
1.42 + EFbsNone = 0,
1.43 + /** Run length. */
1.44 + EFbsRunLength = 1,
1.45 + /** TIFF. */
1.46 + EFbsTIFF = 2,
1.47 + /** Delta row. */
1.48 + EFbsDeltaRow = 3,
1.49 + /** Reserved. */
1.50 + EFbsReserved = 4,
1.51 + /** Adaptive. */
1.52 + EFbsAdaptive = 5
1.53 + };
1.54 +
1.55 +/**
1.56 +Determines the raster mode used by printer drivers.
1.57 +*/
1.58 +enum TFbsRasterGraphicsMode
1.59 + {
1.60 + /** Logical page orientation. */
1.61 + EFbsLogicalPageOrientation = 0,
1.62 + /** Physcial page orientation. */
1.63 + EFbsPhysicalPageOrientation = 3
1.64 + };
1.65 +
1.66 +/**
1.67 +Enumerates resources used by printer drivers.
1.68 +*/
1.69 +enum TPdrResourceId // Corresponds to IdentResource in PDRREADR.H
1.70 + {
1.71 + /** Reset. */
1.72 + EPdrReset,
1.73 + /** Set page size. */
1.74 + EPdrSetPageSize,
1.75 + /** Preamble. */
1.76 + EPdrPreAmble,
1.77 + /** Postamble. */
1.78 + EPdrPostAmble,
1.79 + /** Set text colour. */
1.80 + EPdrSetTextColor,
1.81 + /** Bold text. */
1.82 + EPdrBoldOn,
1.83 + /** Normal text weighting. */
1.84 + EPdrBoldOff,
1.85 + /** Italic text. */
1.86 + EPdrItalicOn,
1.87 + /** Normal text slant. */
1.88 + EPdrItalicOff,
1.89 + /** Underline text. */
1.90 + EPdrUnderlineOn,
1.91 + /** No text underline. */
1.92 + EPdrUnderlineOff,
1.93 + /** Strike through text. */
1.94 + EPdrStrikethroughOn,
1.95 + /** No text strike through. */
1.96 + EPdrStrikethroughOff,
1.97 + /** New page. */
1.98 + EPdrNewPage,
1.99 + /** Portrait view. */
1.100 + EPdrPortrait,
1.101 + /** Landscape view. */
1.102 + EPdrLandscape,
1.103 + /** Set the x-position of the printer head. */
1.104 + EPdrSetXPos,
1.105 + /** Set the y-position of the printer head. */
1.106 + EPdrSetYPos,
1.107 + /** Increment the x-position. */
1.108 + EPdrIncrementXPos,
1.109 + /** Increment the y-position. */
1.110 + EPdrIncrementYPos,
1.111 + /** Carriage return. */
1.112 + EPdrCarriageReturn,
1.113 + /** Set the graphics colour. */
1.114 + EPdrSetGraphicsColor,
1.115 + /** Starting position of bitmap. */
1.116 + EPdrBitmapStart,
1.117 + /** End position of bitmap. */
1.118 + EPdrBitmapEnd,
1.119 + /** Scan line. */
1.120 + EPdrScanLine,
1.121 + /** End of scan line. */
1.122 + EPdrEndScanLine,
1.123 + /** Extra resource holder. */
1.124 + EPdrResource1,
1.125 + /** Extra resource holder. */
1.126 + EPdrResource2,
1.127 + /** Extra resource holder. */
1.128 + EPdrResource3,
1.129 + /** Extra resource holder. */
1.130 + EPdrResource4,
1.131 + /** Extra resource holder. */
1.132 + EPdrResource5,
1.133 + /** Extra resource holder. */
1.134 + EPdrResource6,
1.135 + /** Extra resource holder. */
1.136 + EPdrResource7,
1.137 + /** Extra resource holder. */
1.138 + EPdrResource8
1.139 + };
1.140 +
1.141 +/**
1.142 +Maximum length of a printer command string.
1.143 +*/
1.144 +const TInt KMaxCommandStringLength = 0x40;
1.145 +/**
1.146 +Defines a command string used by printer drivers.
1.147 +*/
1.148 +typedef TBuf8<KMaxCommandStringLength> TCommandString;
1.149 +
1.150 +// Forward declarations
1.151 +class CFontInfo;
1.152 +class CPdrTranslates;
1.153 +class CPdrDevice;
1.154 +
1.155 +/** WARNING: Class for internal use ONLY. Compatibility is not guaranteed in future releases.
1.156 + */
1.157 +class CInfoFont : public CFont
1.158 + {
1.159 + friend class CPdrTypefaceStore;
1.160 +public:
1.161 + // New functions
1.162 + IMPORT_C HBufC8* TranslateStringL(const TDesC& aString) const;
1.163 + IMPORT_C TPtrC8 CommandString() const;
1.164 + IMPORT_C TBool RepertoireContains(TChar aChar) const;
1.165 + IMPORT_C TBool AllCharsInFontRepertoire(const TDesC& aString, TInt& aFirstCharNotInRepertoire, TInt& aLength) const;
1.166 + inline CFontInfo* FontInfo() const {return iFontInfo;}
1.167 + CFont* RealFont() const;
1.168 +private:
1.169 + CInfoFont(TInt aBaselineOffsetInPixels, const TFontSpec& aFontSpecInTwips, TInt aFontInfoHeightInTwips, TInt aHeightInPixels, CPdrTranslates* aTranslates, const TDesC8& aCommandString, CPdrDevice* aPdrDevice);
1.170 + ~CInfoFont();
1.171 + TInt Width(TInt aNum) const;
1.172 + TInt Height(TInt aNum) const;
1.173 + void CreateBandedFontIfRequired();
1.174 + // From CFont
1.175 + IMPORT_C virtual TUid DoTypeUid() const;
1.176 + IMPORT_C virtual TInt DoHeightInPixels() const;
1.177 + IMPORT_C virtual TInt DoAscentInPixels() const;
1.178 + IMPORT_C virtual TInt DoCharWidthInPixels(TChar aChar) const;
1.179 + IMPORT_C virtual TInt DoTextWidthInPixels(const TDesC &aText) const;
1.180 + IMPORT_C virtual TInt DoBaselineOffsetInPixels() const;
1.181 + IMPORT_C virtual TInt DoTextCount(const TDesC &aText, TInt aWidthInPixels) const;
1.182 + IMPORT_C virtual TInt DoTextCount(const TDesC &aText, TInt aWidthInPixels, TInt &aExcessWidthInPixels) const;
1.183 + IMPORT_C virtual TInt DoMaxCharWidthInPixels() const;
1.184 + IMPORT_C virtual TInt DoMaxNormalCharWidthInPixels() const;
1.185 + IMPORT_C virtual TFontSpec DoFontSpecInTwips() const;
1.186 +private:
1.187 + TCommandString iCommandString;
1.188 + TInt iBaselineOffsetInPixels;
1.189 + TFontSpec iFontSpecInTwips;
1.190 + TInt iFontInfoHeightInTwips;
1.191 + TInt iHeightInPixels;
1.192 + CFontInfo* iFontInfo;
1.193 + CPdrTranslates* iTranslates;
1.194 + CPdrDevice* iPdrDevice;
1.195 + CFont* iRealFont;
1.196 + };
1.197 +
1.198 +
1.199 +class CPageBuffer : public CActive
1.200 + {
1.201 +public:
1.202 + IMPORT_C static CPageBuffer* NewL(CPrinterPort* aPrinterPort);
1.203 + IMPORT_C static CPageBuffer* NewL(CPrinterPort* aPrinterPort, TInt aGranularity);
1.204 + IMPORT_C void StartFlush(TRequestStatus& aRequestStatus);
1.205 + IMPORT_C void AddBytesL(const TDesC8& aDes);
1.206 + IMPORT_C RWriteStream& CreateWriteStreamL();
1.207 + IMPORT_C void CloseWriteStream();
1.208 + IMPORT_C ~CPageBuffer();
1.209 + void DoCancel();
1.210 + void RunL();
1.211 +private:
1.212 + void ConstructL();
1.213 + CPageBuffer(CPrinterPort* aPrinterPort, TInt aGranularity);
1.214 + void Queue();
1.215 +private:
1.216 +
1.217 + TRequestStatus* iRequestStatus;
1.218 +
1.219 + TInt iWritePos;
1.220 +
1.221 + TInt iGranularity;
1.222 +
1.223 + CBufSeg* iBuffer;
1.224 +
1.225 + TPtr8 iPtr;
1.226 +
1.227 + CPrinterPort* iPrinterPort;
1.228 +
1.229 + RBufWriteStream iWriteStream;
1.230 +
1.231 + CBufSeg* iWriteStreamBuffer;
1.232 + };
1.233 +
1.234 +
1.235 +/** WARNING: Class for internal use ONLY. Compatibility is not guaranteed in future releases.
1.236 + */
1.237 +class TTextFormat
1.238 + {
1.239 +public:
1.240 + IMPORT_C TTextFormat();
1.241 + IMPORT_C TTextFormat(const TFontUnderline anUnderlineStyle, const TFontStrikethrough aStrikethroughStyle, const TRgb& aColor, const TDesC8& aFontString, const TFontStyle& aFontStyle);
1.242 + IMPORT_C TBool operator == (const TTextFormat& aFormat) const;
1.243 +public:
1.244 +
1.245 + TFontUnderline iUnderlineStyle;
1.246 +
1.247 + TFontStrikethrough iStrikethroughStyle;
1.248 +
1.249 + TRgb iColor;
1.250 +
1.251 + TCommandString iFontString;
1.252 +
1.253 + TFontStyle iFontStyle;
1.254 + };
1.255 +
1.256 +
1.257 +// Forward declarations
1.258 +class CPdrModelInfo;
1.259 +class CPdrTypefaceStore;
1.260 +
1.261 +/**
1.262 +@see CFbsDrvDevice
1.263 +*/
1.264 +class CPdrDevice : public CPrinterDevice
1.265 + {
1.266 +protected:
1.267 + IMPORT_C CPdrDevice();
1.268 +public:
1.269 + IMPORT_C virtual ~CPdrDevice();
1.270 + IMPORT_C void SelectPageSpecInTwips(const TPageSpec& aPageSpec);
1.271 + IMPORT_C TDisplayMode DisplayMode() const;
1.272 + IMPORT_C TSize SizeInPixels() const;
1.273 + IMPORT_C TSize SizeInTwips() const;
1.274 + IMPORT_C TRect PrintablePageInPixels() const;
1.275 + IMPORT_C TInt HorizontalTwipsToPixels(TInt aTwips) const;
1.276 + IMPORT_C TInt VerticalTwipsToPixels(TInt aTwips) const;
1.277 + IMPORT_C TInt HorizontalPixelsToTwips(TInt aPixels) const;
1.278 + IMPORT_C TInt VerticalPixelsToTwips(TInt aPixels) const;
1.279 + IMPORT_C TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec);
1.280 + IMPORT_C TInt GetNearestFontToDesignHeightInTwips(CFont *&aFont, const TFontSpec &aFontSpec);
1.281 + IMPORT_C TInt GetNearestFontToMaxHeightInTwips(CFont *&aFont, const TFontSpec &aFontSpec, TInt aMaxHeight);
1.282 + IMPORT_C TInt NumTypefaces() const;
1.283 + IMPORT_C void TypefaceSupport(TTypefaceSupport& aTypefaceSupport, TInt aTypefaceIndex) const;
1.284 + IMPORT_C TInt FontHeightInTwips(TInt aTypefaceIndex, TInt aHeightIndex) const;
1.285 + IMPORT_C void PaletteAttributes(TBool& aModifiable, TInt& aNumEntries) const;
1.286 + IMPORT_C void SetPalette(CPalette* aPalette);
1.287 + IMPORT_C TInt GetPalette(CPalette*& aPalette) const;
1.288 + IMPORT_C TPrinterModelEntry Model() const;
1.289 + IMPORT_C TInt Flags() const;
1.290 + IMPORT_C TInt SetModel(const TPrinterModelHeader& aModel, CStreamStore& aStore);
1.291 + IMPORT_C void ReleaseFont(CFont* aFont);
1.292 + IMPORT_C TPoint OffsetInPixels();
1.293 +
1.294 +protected:
1.295 + IMPORT_C virtual TSize KPixelSizeInTwips() const;
1.296 +private:
1.297 + void DoSetModelL();
1.298 +protected:
1.299 +
1.300 + CStreamStore* iStore;
1.301 +
1.302 + TPrinterModelHeader iModel;
1.303 +
1.304 + CPdrModelInfo* iModelInfo;
1.305 +
1.306 + CPdrTypefaceStore* iTypefaceStore;
1.307 + };
1.308 +
1.309 +
1.310 +//Forward declarations
1.311 +class CPdrResources;
1.312 +class CPageText;
1.313 +
1.314 +class CPdrControl : public CPrinterControl
1.315 + {
1.316 +public:
1.317 + IMPORT_C ~CPdrControl();
1.318 + IMPORT_C TInt CreateContext(CGraphicsContext*& aGC);
1.319 + IMPORT_C TInt BandsPerPage();
1.320 + IMPORT_C TMoreOnPage QueueGetBand(TRequestStatus& aStatus, TBandAttributes& aBand); // returns affirmative if more to print on current page
1.321 + IMPORT_C void QueueEndPrint(TRequestStatus& aStatus); // Called at finish to flush buffer, tidy up printer etc.
1.322 + IMPORT_C void AbortPrint(); // tidy up synchronously in a short time
1.323 + IMPORT_C virtual void DrawTextL(const TPoint& aPoint, const TFontUnderline aUnderlineStyle, const TFontStrikethrough aStrikethroughStyle, const TRgb& aColor, const CInfoFont* aFont, const TDesC& aString);
1.324 + IMPORT_C TBool IsGraphicsBand() const;
1.325 + inline CBandedDevice* BandedDevice() const {return iBandedDevice;}
1.326 +protected:
1.327 + IMPORT_C CPdrControl(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort);
1.328 + IMPORT_C virtual void DoQueueGetBandL();
1.329 + IMPORT_C virtual void DoQueueEndPrintL();
1.330 + IMPORT_C void ConstructL(CStreamStore& aStore, TStreamId aStreamId);
1.331 +
1.332 + virtual void OutputBandL() = 0;
1.333 +
1.334 + IMPORT_C virtual void MoveToL(const TPoint& aPoint);
1.335 + IMPORT_C virtual void MoveByL(const TPoint& aVector);
1.336 + IMPORT_C virtual void OutputTextL(const TPoint& aPoint, TInt aWidthInPixels, const TTextFormat& aTextFormat, const TDesC8& aString);
1.337 +
1.338 + IMPORT_C virtual void SetPageSizeL();
1.339 + IMPORT_C virtual void SetPageOrientationL();
1.340 + IMPORT_C virtual void SetFontPostureL(const TFontPosture aPosture);
1.341 + IMPORT_C virtual void SetFontStrokeWeightL(const TFontStrokeWeight aStrokeWeight);
1.342 + IMPORT_C virtual void SetTextColorL(const TRgb& aColor);
1.343 + IMPORT_C virtual void CommandL(const TInt anId);
1.344 +
1.345 + IMPORT_C TBool TransformBuffer(); // These two functions are not implemented anywhere
1.346 + IMPORT_C TBool CompressBuffer(); // for this class. Nor do I believe they are defined
1.347 + // for a reason. But since they are part of the
1.348 + // existing interface of a DLL in a ROM I need to
1.349 + // patch. They get to stay there for the moment. CJC
1.350 +
1.351 +protected:
1.352 +
1.353 + CPdrDevice* iPdrDevice;
1.354 +
1.355 + CPageBuffer* iPageBuffer;
1.356 +
1.357 + CPdrResources* iResources;
1.358 +
1.359 + CBandedDevice* iBandedDevice;
1.360 +
1.361 + CPageText* iPageText;
1.362 +
1.363 + TInt iBandIndex;
1.364 +
1.365 + TInt iEntryIndex;
1.366 +
1.367 + TPoint iPosition;
1.368 +
1.369 + TTextFormat iTextFormat;
1.370 + };
1.371 +
1.372 +
1.373 +class CFbsDrvDevice : public CPdrDevice
1.374 + {
1.375 +public:
1.376 + IMPORT_C CFbsDrvDevice();
1.377 + IMPORT_C ~CFbsDrvDevice();
1.378 +
1.379 + IMPORT_C TInt GetNearestFontInTwips(CFont*& aFont, const TFontSpec& aFontSpec);
1.380 + IMPORT_C TInt GetNearestFontToDesignHeightInTwips(CFont *&aFont, const TFontSpec &aFontSpec);
1.381 + IMPORT_C void ReleaseFont(CFont* aFont);
1.382 + IMPORT_C TInt NumTypefaces() const;
1.383 + IMPORT_C void TypefaceSupport(TTypefaceSupport& aTypefaceSupport, TInt aTypefaceIndex) const;
1.384 + IMPORT_C TInt FontHeightInTwips(TInt aTypefaceIndex, TInt aHeightIndex) const;
1.385 +
1.386 + IMPORT_C TInt CreateContext(CGraphicsContext*& aGc);
1.387 + IMPORT_C void CreateControlL(CPrinterPort* aPrinterPort);
1.388 + IMPORT_C TInt SetModel(const TPrinterModelHeader& aModel, CStreamStore& aStore);
1.389 + IMPORT_C void LoadTypeFaceList();
1.390 + IMPORT_C TSize KPixelSizeInTwips() const;
1.391 + IMPORT_C void LoadTypeFaceListL();
1.392 + IMPORT_C TInt SetModelL(const TPrinterModelHeader& aModel, CStreamStore& aStore);
1.393 +private:
1.394 +// reserved virtual function space
1.395 + IMPORT_C virtual void Reserved_1();
1.396 +
1.397 +protected:
1.398 +
1.399 + CFbsTypefaceStore* iFbsTypefaceStore;
1.400 +
1.401 + CArrayFixFlat<TInt>* iGenTypefaceFontsList;
1.402 +
1.403 + CArrayFixFlat<TInt>* iGenTypefaceFontsType;
1.404 +
1.405 + TInt iFbsTypefaceCount;
1.406 +
1.407 + TInt iPdrTypefaceCount;
1.408 +
1.409 +private:
1.410 +
1.411 + TAny* iReserved;
1.412 + };
1.413 +
1.414 +
1.415 +class CFbsDrvControl : public CPdrControl
1.416 + {
1.417 +public:
1.418 + IMPORT_C static CFbsDrvControl* NewL(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort, CStreamStore& aStore, TStreamId aResourcesStreamId);
1.419 + IMPORT_C ~CFbsDrvControl();
1.420 +
1.421 +protected:
1.422 + IMPORT_C virtual void OutputBandL();
1.423 +
1.424 + IMPORT_C CFbsDrvControl(CPdrDevice* aPdrDevice, CPrinterPort* aPrinterPort);
1.425 + IMPORT_C void ConstructL(CStreamStore& aStore, TStreamId aResourcesStreamId);
1.426 + IMPORT_C void SetPageSizeL();
1.427 +
1.428 + IMPORT_C TBool TransformBuffer();
1.429 + IMPORT_C TBool CompressBuffer();
1.430 +
1.431 +private:
1.432 +// reserved virtual function space
1.433 + IMPORT_C virtual void Reserved_1();
1.434 +
1.435 +protected:
1.436 +
1.437 + HBufC8* iScanLine;
1.438 +
1.439 + HBufC8* iCompressedScanLine;
1.440 +
1.441 +private:
1.442 +
1.443 + TAny* iReserved;
1.444 + };
1.445 +
1.446 +#endif