1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVP_PSPGRAPHICS_HXX
25 #define _SVP_PSPGRAPHICS_HXX
26 
27 
28 #include "vcl/fontmanager.hxx"
29 
30 #include "sallayout.hxx"
31 #include "salgdi.hxx"
32 
33 namespace psp { struct JobData; class PrinterGfx; }
34 
35 class ServerFont;
36 class ImplDevFontAttributes;
37 class SalInfoPrinter;
38 
39 class PspGraphics : public SalGraphics
40 {
41     psp::JobData*				m_pJobData;
42     psp::PrinterGfx*			m_pPrinterGfx;
43     String*						m_pPhoneNr;
44     bool						m_bSwallowFaxNo;
45     String						m_aPhoneCollection;
46     bool						m_bPhoneCollectionActive;
47 
48     ServerFont*					m_pServerFont[ MAX_FALLBACK ];
49     bool						m_bFontVertical;
50     SalInfoPrinter*             m_pInfoPrinter;
51 
52 protected:
53     virtual bool drawAlphaBitmap( const SalTwoRect&, const SalBitmap& rSourceBitmap, const SalBitmap& rAlphaBitmap );
54     virtual bool drawAlphaRect( long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency );
55 
56 public:
57     PspGraphics( psp::JobData* pJob, psp::PrinterGfx* pGfx, String* pPhone, bool bSwallow, SalInfoPrinter* pInfoPrinter )
58             : m_pJobData( pJob ),
59               m_pPrinterGfx( pGfx ),
60               m_pPhoneNr( pPhone ),
61               m_bSwallowFaxNo( bSwallow ),
62               m_bPhoneCollectionActive( false ),
63               m_bFontVertical( false ),
64               m_pInfoPrinter( pInfoPrinter )
65     { for( int i = 0; i < MAX_FALLBACK; i++ ) m_pServerFont[i] = 0; }
66     virtual ~PspGraphics();
67 
68     // helper methods for sharing with X11SalGraphics
69     static const void* DoGetEmbedFontData( psp::fontID aFont, const sal_Ucs* pUnicodes, sal_Int32* pWidths, FontSubsetInfo& rInfo, long* pDataLen );
70     static void DoFreeEmbedFontData( const void* pData, long nLen );
71     static const Ucs2SIntMap* DoGetFontEncodingVector( psp::fontID aFont, const Ucs2OStrMap** pNonEncoded );
72     static void DoGetGlyphWidths( psp::fontID aFont,
73                                   bool bVertical,
74                                   Int32Vector& rWidths,
75                                   Ucs2UIntMap& rUnicodeEnc );
76     static ImplDevFontAttributes Info2DevFontAttributes( const psp::FastPrintFontInfo& );
77     static void AnnounceFonts( ImplDevFontList*, const psp::FastPrintFontInfo& );
78     static FontWidth	ToFontWidth (psp::width::type eWidth);
79     static FontWeight	ToFontWeight (psp::weight::type eWeight);
80     static FontPitch	ToFontPitch (psp::pitch::type ePitch);
81     static FontItalic	ToFontItalic (psp::italic::type eItalic);
82     static FontFamily	ToFontFamily (psp::family::type eFamily);
83 
84     // overload all pure virtual methods
85     virtual void			GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY );
86     virtual sal_uInt16			GetBitCount();
87     virtual long			GetGraphicsWidth() const;
88 
89     virtual void			ResetClipRegion();
90     virtual bool            setClipRegion( const Region& );
91 
92     virtual void			SetLineColor();
93     virtual void			SetLineColor( SalColor nSalColor );
94     virtual void			SetFillColor();
95     virtual void          	SetFillColor( SalColor nSalColor );
96     virtual void			SetXORMode( bool bSet, bool );
97     virtual void			SetROPLineColor( SalROPColor nROPColor );
98     virtual void			SetROPFillColor( SalROPColor nROPColor );
99 
100     virtual void			SetTextColor( SalColor nSalColor );
101     virtual sal_uInt16          SetFont( ImplFontSelectData*, int nFallbackLevel );
102     virtual void			GetFontMetric( ImplFontMetricData*, int nFallbackLevel );
103     virtual sal_uLong			GetKernPairs( sal_uLong nPairs, ImplKernPairData* pKernPairs );
104     virtual const ImplFontCharMap* GetImplFontCharMap() const;
105     virtual void			GetDevFontList( ImplDevFontList* );
106     virtual void			GetDevFontSubstList( OutputDevice* );
107     virtual bool			AddTempDevFont( ImplDevFontList*, const String& rFileURL, const String& rFontName );
108     virtual sal_Bool			CreateFontSubset( const rtl::OUString& rToFile,
109                                               const ImplFontData*,
110                                               sal_Int32* pGlyphIDs,
111                                               sal_uInt8* pEncoding,
112                                               sal_Int32* pWidths,
113                                               int nGlyphs,
114                                               FontSubsetInfo& rInfo
115                                               );
116     virtual const Ucs2SIntMap* GetFontEncodingVector( const ImplFontData*, const Ucs2OStrMap** ppNonEncoded );
117     virtual const void*	GetEmbedFontData( const ImplFontData*,
118                                           const sal_Ucs* pUnicodes,
119                                           sal_Int32* pWidths,
120                                           FontSubsetInfo& rInfo,
121                                           long* pDataLen );
122     virtual void			FreeEmbedFontData( const void* pData, long nDataLen );
123     virtual void            GetGlyphWidths( const ImplFontData*,
124                                             bool bVertical,
125                                             Int32Vector& rWidths,
126                                             Ucs2UIntMap& rUnicodeEnc );
127     virtual sal_Bool			GetGlyphBoundRect( long nIndex, Rectangle& );
128     virtual sal_Bool			GetGlyphOutline( long nIndex, ::basegfx::B2DPolyPolygon& );
129     virtual SalLayout*		GetTextLayout( ImplLayoutArgs&, int nFallbackLevel );
130     virtual void			DrawServerFontLayout( const ServerFontLayout& );
131     virtual bool            supportsOperation( OutDevSupportType ) const;
132     virtual void			drawPixel( long nX, long nY );
133     virtual void			drawPixel( long nX, long nY, SalColor nSalColor );
134     virtual void			drawLine( long nX1, long nY1, long nX2, long nY2 );
135     virtual void			drawRect( long nX, long nY, long nWidth, long nHeight );
136     virtual void			drawPolyLine( sal_uLong nPoints, const SalPoint* pPtAry );
137     virtual void			drawPolygon( sal_uLong nPoints, const SalPoint* pPtAry );
138     virtual bool            drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double fTransparency );
139     virtual bool            drawPolyLine( const ::basegfx::B2DPolygon&, double fTransparency, const ::basegfx::B2DVector& rLineWidths, basegfx::B2DLineJoin );
140     virtual void			drawPolyPolygon( sal_uInt32 nPoly,
141                                              const sal_uInt32* pPoints,
142                                              PCONSTSALPOINT* pPtAry );
143     virtual sal_Bool		drawPolyLineBezier( sal_uLong nPoints,
144                                                 const SalPoint* pPtAry,
145                                                 const sal_uInt8* pFlgAry );
146     virtual sal_Bool		drawPolygonBezier( sal_uLong nPoints,
147                                                const SalPoint* pPtAry,
148                                                const sal_uInt8* pFlgAry );
149     virtual sal_Bool		drawPolyPolygonBezier( sal_uInt32 nPoly,
150                                                    const sal_uInt32* pPoints,
151                                                    const SalPoint* const* pPtAry,
152                                                    const sal_uInt8* const* pFlgAry );
153 
154     virtual void			copyArea( long nDestX,
155                                       long nDestY,
156                                       long nSrcX,
157                                       long nSrcY,
158                                       long nSrcWidth,
159                                       long nSrcHeight,
160                                       sal_uInt16 nFlags );
161     virtual void			copyBits( const SalTwoRect* pPosAry,
162                                       SalGraphics* pSrcGraphics );
163     virtual void			drawBitmap( const SalTwoRect* pPosAry,
164                                         const SalBitmap& rSalBitmap );
165     virtual void			drawBitmap( const SalTwoRect* pPosAry,
166                                         const SalBitmap& rSalBitmap,
167                                         SalColor nTransparentColor );
168     virtual void			drawBitmap( const SalTwoRect* pPosAry,
169                                         const SalBitmap& rSalBitmap,
170                                         const SalBitmap& rTransparentBitmap );
171     virtual void			drawMask( const SalTwoRect* pPosAry,
172                                       const SalBitmap& rSalBitmap,
173                                       SalColor nMaskColor );
174     virtual SalBitmap*		getBitmap( long nX, long nY, long nWidth, long nHeight );
175     virtual SalColor		getPixel( long nX, long nY );
176     virtual void			invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags );
177     virtual void			invert( sal_uLong nPoints, const SalPoint* pPtAry, SalInvert nFlags );
178 
179     virtual sal_Bool			drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize );
180     virtual bool            filterText( const String& rOrigText, String& rNewText, xub_StrLen nIndex, xub_StrLen& rLen, xub_StrLen& rCutStart, xub_StrLen& rCutStop );
181 
182     virtual SystemGraphicsData 		GetGraphicsData() const;
183     virtual SystemFontData          GetSysFontData( int nFallbacklevel ) const;
184 };
185 
186 #endif // _SVP_PSPGRAPHICS_HXX
187 
188