19f62ea84SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 39f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 49f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file 59f62ea84SAndrew Rist * distributed with this work for additional information 69f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file 79f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the 89f62ea84SAndrew Rist * "License"); you may not use this file except in compliance 99f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at 109f62ea84SAndrew Rist * 119f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 129f62ea84SAndrew Rist * 139f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing, 149f62ea84SAndrew Rist * software distributed under the License is distributed on an 159f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 169f62ea84SAndrew Rist * KIND, either express or implied. See the License for the 179f62ea84SAndrew Rist * specific language governing permissions and limitations 189f62ea84SAndrew Rist * under the License. 199f62ea84SAndrew Rist * 209f62ea84SAndrew Rist *************************************************************/ 219f62ea84SAndrew Rist 229f62ea84SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_vcl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <stdlib.h> 28cdf0e10cSrcweir #include <unistd.h> 29cdf0e10cSrcweir #include <fcntl.h> 30cdf0e10cSrcweir #include <sys/mman.h> 31cdf0e10cSrcweir #include <sys/stat.h> 32cdf0e10cSrcweir #include <sys/types.h> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include "basegfx/vector/b2ivector.hxx" 35cdf0e10cSrcweir #include "basegfx/point/b2ipoint.hxx" 36cdf0e10cSrcweir 37cdf0e10cSrcweir #include "basebmp/color.hxx" 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include "vcl/jobdata.hxx" 40cdf0e10cSrcweir #include "vcl/printerinfomanager.hxx" 41cdf0e10cSrcweir #include "vcl/bmpacc.hxx" 42cdf0e10cSrcweir #include "vcl/svapp.hxx" 43cdf0e10cSrcweir #include "vcl/sysdata.hxx" 44cdf0e10cSrcweir 45cdf0e10cSrcweir #include "salprn.hxx" 46cdf0e10cSrcweir #include "salbmp.hxx" 47cdf0e10cSrcweir #include "glyphcache.hxx" 48cdf0e10cSrcweir #include "impfont.hxx" 49cdf0e10cSrcweir #include "outfont.hxx" 50cdf0e10cSrcweir #include "fontsubset.hxx" 51cdf0e10cSrcweir #include "printergfx.hxx" 52cdf0e10cSrcweir #include "svppspgraphics.hxx" 53cdf0e10cSrcweir #include "svpbmp.hxx" 54cdf0e10cSrcweir 55cdf0e10cSrcweir using namespace psp; 56cdf0e10cSrcweir using namespace rtl; 57cdf0e10cSrcweir using namespace basebmp; 58cdf0e10cSrcweir using namespace basegfx; 59cdf0e10cSrcweir 60cdf0e10cSrcweir // ----- Implementation of PrinterBmp by means of SalBitmap/BitmapBuffer --------------- 61cdf0e10cSrcweir 62cdf0e10cSrcweir class SalPrinterBmp : public psp::PrinterBmp 63cdf0e10cSrcweir { 64cdf0e10cSrcweir private: 65cdf0e10cSrcweir SalPrinterBmp (); 66cdf0e10cSrcweir 67cdf0e10cSrcweir BitmapDeviceSharedPtr m_aBitmap; 68cdf0e10cSrcweir public: 69cdf0e10cSrcweir 70cdf0e10cSrcweir SalPrinterBmp (const BitmapDeviceSharedPtr& rDevice); 71cdf0e10cSrcweir virtual ~SalPrinterBmp (); 72cdf0e10cSrcweir virtual sal_uInt32 GetPaletteColor (sal_uInt32 nIdx) const; 73cdf0e10cSrcweir virtual sal_uInt32 GetPaletteEntryCount () const; 74cdf0e10cSrcweir virtual sal_uInt32 GetPixelRGB (sal_uInt32 nRow, sal_uInt32 nColumn) const; 75cdf0e10cSrcweir virtual sal_uInt8 GetPixelGray (sal_uInt32 nRow, sal_uInt32 nColumn) const; 76cdf0e10cSrcweir virtual sal_uInt8 GetPixelIdx (sal_uInt32 nRow, sal_uInt32 nColumn) const; 77cdf0e10cSrcweir virtual sal_uInt32 GetWidth () const; 78cdf0e10cSrcweir virtual sal_uInt32 GetHeight() const; 79cdf0e10cSrcweir virtual sal_uInt32 GetDepth () const; 80cdf0e10cSrcweir 81cdf0e10cSrcweir static sal_uInt32 getRGBFromColor( const basebmp::Color& rCol ) 82cdf0e10cSrcweir { 83cdf0e10cSrcweir return ((rCol.getBlue()) & 0x000000ff) 84cdf0e10cSrcweir | ((rCol.getGreen() << 8) & 0x0000ff00) 85cdf0e10cSrcweir | ((rCol.getRed() << 16) & 0x00ff0000); 86cdf0e10cSrcweir } 87cdf0e10cSrcweir }; 88cdf0e10cSrcweir 89cdf0e10cSrcweir SalPrinterBmp::SalPrinterBmp(const BitmapDeviceSharedPtr& rDevice) : 90cdf0e10cSrcweir m_aBitmap( rDevice ) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir } 93cdf0e10cSrcweir 94cdf0e10cSrcweir SalPrinterBmp::~SalPrinterBmp () 95cdf0e10cSrcweir { 96cdf0e10cSrcweir } 97cdf0e10cSrcweir 98cdf0e10cSrcweir sal_uInt32 99cdf0e10cSrcweir SalPrinterBmp::GetWidth () const 100cdf0e10cSrcweir { 101cdf0e10cSrcweir return m_aBitmap.get() ? m_aBitmap->getSize().getX() : 0; 102cdf0e10cSrcweir } 103cdf0e10cSrcweir 104cdf0e10cSrcweir sal_uInt32 105cdf0e10cSrcweir SalPrinterBmp::GetHeight () const 106cdf0e10cSrcweir { 107cdf0e10cSrcweir return m_aBitmap.get() ? m_aBitmap->getSize().getY() : 0; 108cdf0e10cSrcweir } 109cdf0e10cSrcweir 110cdf0e10cSrcweir sal_uInt32 111cdf0e10cSrcweir SalPrinterBmp::GetDepth () const 112cdf0e10cSrcweir { 113cdf0e10cSrcweir return m_aBitmap.get() ? 114cdf0e10cSrcweir SvpElement::getBitCountFromScanlineFormat( m_aBitmap->getScanlineFormat() ) 115cdf0e10cSrcweir : 0; 116cdf0e10cSrcweir } 117cdf0e10cSrcweir 118cdf0e10cSrcweir 119cdf0e10cSrcweir sal_uInt32 120cdf0e10cSrcweir SalPrinterBmp::GetPaletteEntryCount () const 121cdf0e10cSrcweir { 122cdf0e10cSrcweir return m_aBitmap.get() ? m_aBitmap->getPaletteEntryCount() : 0; 123cdf0e10cSrcweir } 124cdf0e10cSrcweir 125cdf0e10cSrcweir sal_uInt32 126cdf0e10cSrcweir SalPrinterBmp::GetPaletteColor (sal_uInt32 nIdx) const 127cdf0e10cSrcweir { 128cdf0e10cSrcweir sal_uInt32 nCol = 0; 129cdf0e10cSrcweir if( m_aBitmap.get() && nIdx < static_cast<sal_uInt32>(m_aBitmap->getPaletteEntryCount()) ) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir const basebmp::Color& rColor = (*m_aBitmap->getPalette().get())[ nIdx ]; 132cdf0e10cSrcweir nCol = getRGBFromColor( rColor ); 133cdf0e10cSrcweir } 134cdf0e10cSrcweir return nCol; 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir sal_uInt32 138cdf0e10cSrcweir SalPrinterBmp::GetPixelRGB (sal_uInt32 nRow, sal_uInt32 nColumn) const 139cdf0e10cSrcweir { 140cdf0e10cSrcweir sal_uInt32 nCol = 0; 141cdf0e10cSrcweir if( m_aBitmap.get() ) 142cdf0e10cSrcweir nCol = getRGBFromColor( m_aBitmap->getPixel( B2IPoint( nColumn, nRow ) ) ); 143cdf0e10cSrcweir return nCol; 144cdf0e10cSrcweir } 145cdf0e10cSrcweir 146cdf0e10cSrcweir sal_uInt8 147cdf0e10cSrcweir SalPrinterBmp::GetPixelGray (sal_uInt32 nRow, sal_uInt32 nColumn) const 148cdf0e10cSrcweir { 149cdf0e10cSrcweir sal_uInt8 nGray = 0; 150cdf0e10cSrcweir if( m_aBitmap.get() ) 151cdf0e10cSrcweir { 152cdf0e10cSrcweir // TODO: don't use tools color 153cdf0e10cSrcweir basebmp::Color aCol = m_aBitmap->getPixel( B2IPoint( nColumn, nRow ) ); 154cdf0e10cSrcweir ::Color aColor( aCol.getRed(), aCol.getGreen(), aCol.getBlue() ); 155cdf0e10cSrcweir nGray = aColor.GetLuminance(); 156cdf0e10cSrcweir } 157cdf0e10cSrcweir return nGray; 158cdf0e10cSrcweir } 159cdf0e10cSrcweir 160cdf0e10cSrcweir sal_uInt8 161cdf0e10cSrcweir SalPrinterBmp::GetPixelIdx (sal_uInt32 nRow, sal_uInt32 nColumn) const 162cdf0e10cSrcweir { 163cdf0e10cSrcweir sal_uInt8 nIdx = 0; 164cdf0e10cSrcweir if( m_aBitmap.get() ) 165cdf0e10cSrcweir nIdx = static_cast<sal_uInt8>(m_aBitmap->getPixelData( B2IPoint( nColumn, nRow ) )); 166cdf0e10cSrcweir return nIdx; 167cdf0e10cSrcweir } 168cdf0e10cSrcweir 169cdf0e10cSrcweir /******************************************************* 170cdf0e10cSrcweir * PspGraphics * 171cdf0e10cSrcweir *******************************************************/ 172cdf0e10cSrcweir 173cdf0e10cSrcweir bool PspGraphics::drawAlphaBitmap( const SalTwoRect&, const SalBitmap& /*rSourceBitmap*/, const SalBitmap& /*rAlphaBitmap*/ ) 174cdf0e10cSrcweir { 175cdf0e10cSrcweir return false; 176cdf0e10cSrcweir } 177cdf0e10cSrcweir 1785f27b83cSArmin Le Grand bool PspGraphics::drawTransformedBitmap( 1795f27b83cSArmin Le Grand const basegfx::B2DPoint& rNull, 1805f27b83cSArmin Le Grand const basegfx::B2DPoint& rX, 1815f27b83cSArmin Le Grand const basegfx::B2DPoint& rY, 1825f27b83cSArmin Le Grand const SalBitmap& rSourceBitmap, 1835f27b83cSArmin Le Grand const SalBitmap* pAlphaBitmap) 1845f27b83cSArmin Le Grand { 1855f27b83cSArmin Le Grand // here direct support for transformed bitmaps can be impemented 1865f27b83cSArmin Le Grand (void)rNull; (void)rX; (void)rY; (void)rSourceBitmap; (void)pAlphaBitmap; 1875f27b83cSArmin Le Grand return false; 1885f27b83cSArmin Le Grand } 1895f27b83cSArmin Le Grand 190cdf0e10cSrcweir bool PspGraphics::drawAlphaRect( long /*nX*/, long /*nY*/, long /*nWidth*/, long /*nHeight*/, sal_uInt8 /*nTransparency*/ ) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir return false; 193cdf0e10cSrcweir } 194cdf0e10cSrcweir 195cdf0e10cSrcweir bool PspGraphics::supportsOperation( OutDevSupportType ) const 196cdf0e10cSrcweir { 197cdf0e10cSrcweir return false; 198cdf0e10cSrcweir } 199cdf0e10cSrcweir 200cdf0e10cSrcweir PspGraphics::~PspGraphics() 201cdf0e10cSrcweir { 202cdf0e10cSrcweir ReleaseFonts(); 203cdf0e10cSrcweir } 204cdf0e10cSrcweir 205cdf0e10cSrcweir void PspGraphics::GetResolution( sal_Int32 &rDPIX, sal_Int32 &rDPIY ) 206cdf0e10cSrcweir { 207cdf0e10cSrcweir if (m_pJobData != NULL) 208cdf0e10cSrcweir { 209cdf0e10cSrcweir int x = m_pJobData->m_aContext.getRenderResolution(); 210cdf0e10cSrcweir 211cdf0e10cSrcweir rDPIX = x; 212cdf0e10cSrcweir rDPIY = x; 213cdf0e10cSrcweir } 214cdf0e10cSrcweir } 215cdf0e10cSrcweir 216cdf0e10cSrcweir sal_uInt16 PspGraphics::GetBitCount() 217cdf0e10cSrcweir { 218cdf0e10cSrcweir return m_pPrinterGfx->GetBitCount(); 219cdf0e10cSrcweir } 220cdf0e10cSrcweir 221cdf0e10cSrcweir long PspGraphics::GetGraphicsWidth() const 222cdf0e10cSrcweir { 223cdf0e10cSrcweir return 0; 224cdf0e10cSrcweir } 225cdf0e10cSrcweir 226cdf0e10cSrcweir void PspGraphics::ResetClipRegion() 227cdf0e10cSrcweir { 228cdf0e10cSrcweir m_pPrinterGfx->ResetClipRegion(); 229cdf0e10cSrcweir } 230cdf0e10cSrcweir 231cdf0e10cSrcweir bool PspGraphics::setClipRegion( const Region& i_rClip ) 232cdf0e10cSrcweir { 233cdf0e10cSrcweir // TODO: support polygonal clipregions here 234e6f63103SArmin Le Grand RectangleVector aRectangles; 235e6f63103SArmin Le Grand i_rClip.GetRegionRectangles(aRectangles); 236e6f63103SArmin Le Grand m_pPrinterGfx->BeginSetClipRegion(aRectangles.size()); 237cdf0e10cSrcweir 238e6f63103SArmin Le Grand for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++) 239cdf0e10cSrcweir { 240e6f63103SArmin Le Grand const long nW(aRectIter->GetWidth()); 241e6f63103SArmin Le Grand 242e6f63103SArmin Le Grand if(nW) 243cdf0e10cSrcweir { 244e6f63103SArmin Le Grand const long nH(aRectIter->GetHeight()); 245e6f63103SArmin Le Grand 246e6f63103SArmin Le Grand if(nH) 247e6f63103SArmin Le Grand { 248e6f63103SArmin Le Grand m_pPrinterGfx->UnionClipRegion( 249e6f63103SArmin Le Grand aRectIter->Left(), 250e6f63103SArmin Le Grand aRectIter->Top(), 251e6f63103SArmin Le Grand nW, 252e6f63103SArmin Le Grand nH); 253e6f63103SArmin Le Grand } 254cdf0e10cSrcweir } 255cdf0e10cSrcweir } 256e6f63103SArmin Le Grand 257e6f63103SArmin Le Grand //ImplRegionInfo aInfo; 258e6f63103SArmin Le Grand //long nX, nY, nW, nH; 259e6f63103SArmin Le Grand //bool bRegionRect = i_rClip.ImplGetFirstRect(aInfo, nX, nY, nW, nH ); 260e6f63103SArmin Le Grand //while( bRegionRect ) 261e6f63103SArmin Le Grand //{ 262e6f63103SArmin Le Grand // if ( nW && nH ) 263e6f63103SArmin Le Grand // { 264e6f63103SArmin Le Grand // m_pPrinterGfx->UnionClipRegion( nX, nY, nW, nH ); 265e6f63103SArmin Le Grand // } 266e6f63103SArmin Le Grand // bRegionRect = i_rClip.ImplGetNextRect( aInfo, nX, nY, nW, nH ); 267e6f63103SArmin Le Grand //} 268e6f63103SArmin Le Grand 269cdf0e10cSrcweir m_pPrinterGfx->EndSetClipRegion(); 270cdf0e10cSrcweir return true; 271cdf0e10cSrcweir } 272cdf0e10cSrcweir 273cdf0e10cSrcweir void PspGraphics::SetLineColor() 274cdf0e10cSrcweir { 275cdf0e10cSrcweir m_pPrinterGfx->SetLineColor (); 276cdf0e10cSrcweir } 277cdf0e10cSrcweir 278cdf0e10cSrcweir void PspGraphics::SetLineColor( SalColor nSalColor ) 279cdf0e10cSrcweir { 280cdf0e10cSrcweir psp::PrinterColor aColor (SALCOLOR_RED (nSalColor), 281cdf0e10cSrcweir SALCOLOR_GREEN (nSalColor), 282cdf0e10cSrcweir SALCOLOR_BLUE (nSalColor)); 283cdf0e10cSrcweir m_pPrinterGfx->SetLineColor (aColor); 284cdf0e10cSrcweir } 285cdf0e10cSrcweir 286cdf0e10cSrcweir void PspGraphics::SetFillColor() 287cdf0e10cSrcweir { 288cdf0e10cSrcweir m_pPrinterGfx->SetFillColor (); 289cdf0e10cSrcweir } 290cdf0e10cSrcweir 291cdf0e10cSrcweir void PspGraphics::SetFillColor( SalColor nSalColor ) 292cdf0e10cSrcweir { 293cdf0e10cSrcweir psp::PrinterColor aColor (SALCOLOR_RED (nSalColor), 294cdf0e10cSrcweir SALCOLOR_GREEN (nSalColor), 295cdf0e10cSrcweir SALCOLOR_BLUE (nSalColor)); 296cdf0e10cSrcweir m_pPrinterGfx->SetFillColor (aColor); 297cdf0e10cSrcweir } 298cdf0e10cSrcweir 299cdf0e10cSrcweir void PspGraphics::SetROPLineColor( SalROPColor ) 300cdf0e10cSrcweir { 301cdf0e10cSrcweir DBG_ASSERT( 0, "Error: PrinterGfx::SetROPLineColor() not implemented" ); 302cdf0e10cSrcweir } 303cdf0e10cSrcweir 304cdf0e10cSrcweir void PspGraphics::SetROPFillColor( SalROPColor ) 305cdf0e10cSrcweir { 306cdf0e10cSrcweir DBG_ASSERT( 0, "Error: PrinterGfx::SetROPFillColor() not implemented" ); 307cdf0e10cSrcweir } 308cdf0e10cSrcweir 309cdf0e10cSrcweir void PspGraphics::SetXORMode( bool bSet, bool ) 310cdf0e10cSrcweir { 311cdf0e10cSrcweir (void)bSet; 312cdf0e10cSrcweir DBG_ASSERT( !bSet, "Error: PrinterGfx::SetXORMode() not implemented" ); 313cdf0e10cSrcweir } 314cdf0e10cSrcweir 315cdf0e10cSrcweir void PspGraphics::drawPixel( long nX, long nY ) 316cdf0e10cSrcweir { 317cdf0e10cSrcweir m_pPrinterGfx->DrawPixel (Point(nX, nY)); 318cdf0e10cSrcweir } 319cdf0e10cSrcweir 320cdf0e10cSrcweir void PspGraphics::drawPixel( long nX, long nY, SalColor nSalColor ) 321cdf0e10cSrcweir { 322cdf0e10cSrcweir psp::PrinterColor aColor (SALCOLOR_RED (nSalColor), 323cdf0e10cSrcweir SALCOLOR_GREEN (nSalColor), 324cdf0e10cSrcweir SALCOLOR_BLUE (nSalColor)); 325cdf0e10cSrcweir m_pPrinterGfx->DrawPixel (Point(nX, nY), aColor); 326cdf0e10cSrcweir } 327cdf0e10cSrcweir 328cdf0e10cSrcweir void PspGraphics::drawLine( long nX1, long nY1, long nX2, long nY2 ) 329cdf0e10cSrcweir { 330cdf0e10cSrcweir m_pPrinterGfx->DrawLine (Point(nX1, nY1), Point(nX2, nY2)); 331cdf0e10cSrcweir } 332cdf0e10cSrcweir 333cdf0e10cSrcweir void PspGraphics::drawRect( long nX, long nY, long nDX, long nDY ) 334cdf0e10cSrcweir { 335cdf0e10cSrcweir m_pPrinterGfx->DrawRect (Rectangle(Point(nX, nY), Size(nDX, nDY))); 336cdf0e10cSrcweir } 337cdf0e10cSrcweir 338cdf0e10cSrcweir void PspGraphics::drawPolyLine( sal_uLong nPoints, const SalPoint *pPtAry ) 339cdf0e10cSrcweir { 340cdf0e10cSrcweir m_pPrinterGfx->DrawPolyLine (nPoints, (Point*)pPtAry); 341cdf0e10cSrcweir } 342cdf0e10cSrcweir 343cdf0e10cSrcweir void PspGraphics::drawPolygon( sal_uLong nPoints, const SalPoint* pPtAry ) 344cdf0e10cSrcweir { 345cdf0e10cSrcweir // Point must be equal to SalPoint! see vcl/inc/salgtype.hxx 346cdf0e10cSrcweir m_pPrinterGfx->DrawPolygon (nPoints, (Point*)pPtAry); 347cdf0e10cSrcweir } 348cdf0e10cSrcweir 349cdf0e10cSrcweir void PspGraphics::drawPolyPolygon( sal_uInt32 nPoly, 350cdf0e10cSrcweir const sal_uInt32 *pPoints, 351cdf0e10cSrcweir PCONSTSALPOINT *pPtAry ) 352cdf0e10cSrcweir { 353cdf0e10cSrcweir m_pPrinterGfx->DrawPolyPolygon (nPoly, pPoints, (const Point**)pPtAry); 354cdf0e10cSrcweir } 355cdf0e10cSrcweir 3565aaf853bSArmin Le Grand bool PspGraphics::drawPolyLine( 3575aaf853bSArmin Le Grand const ::basegfx::B2DPolygon&, 3585aaf853bSArmin Le Grand double /*fTransparency*/, 3595aaf853bSArmin Le Grand const ::basegfx::B2DVector& /*rLineWidths*/, 3605aaf853bSArmin Le Grand basegfx::B2DLineJoin /*eJoin*/, 3615aaf853bSArmin Le Grand com::sun::star::drawing::LineCap /*eLineCap*/) 362cdf0e10cSrcweir { 363cdf0e10cSrcweir // TODO: implement and advertise OutDevSupport_B2DDraw support 364cdf0e10cSrcweir return false; 365cdf0e10cSrcweir } 366cdf0e10cSrcweir 367cdf0e10cSrcweir sal_Bool PspGraphics::drawPolyLineBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry ) 368cdf0e10cSrcweir { 369cdf0e10cSrcweir m_pPrinterGfx->DrawPolyLineBezier (nPoints, (Point*)pPtAry, pFlgAry); 370cdf0e10cSrcweir return sal_True; 371cdf0e10cSrcweir } 372cdf0e10cSrcweir 373cdf0e10cSrcweir sal_Bool PspGraphics::drawPolygonBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry ) 374cdf0e10cSrcweir { 375cdf0e10cSrcweir m_pPrinterGfx->DrawPolygonBezier (nPoints, (Point*)pPtAry, pFlgAry); 376cdf0e10cSrcweir return sal_True; 377cdf0e10cSrcweir } 378cdf0e10cSrcweir 379cdf0e10cSrcweir sal_Bool PspGraphics::drawPolyPolygonBezier( sal_uInt32 nPoly, 380cdf0e10cSrcweir const sal_uInt32* pPoints, 381cdf0e10cSrcweir const SalPoint* const* pPtAry, 382cdf0e10cSrcweir const sal_uInt8* const* pFlgAry ) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir // Point must be equal to SalPoint! see vcl/inc/salgtype.hxx 385cdf0e10cSrcweir m_pPrinterGfx->DrawPolyPolygonBezier (nPoly, pPoints, (Point**)pPtAry, (sal_uInt8**)pFlgAry); 386cdf0e10cSrcweir return sal_True; 387cdf0e10cSrcweir } 388cdf0e10cSrcweir 389cdf0e10cSrcweir bool PspGraphics::drawPolyPolygon( const basegfx::B2DPolyPolygon&, double /*fTransparency*/ ) 390cdf0e10cSrcweir { 391cdf0e10cSrcweir // TODO: implement and advertise OutDevSupport_B2DDraw support 392cdf0e10cSrcweir return false; 393cdf0e10cSrcweir } 394cdf0e10cSrcweir 395cdf0e10cSrcweir void PspGraphics::invert( sal_uLong /*nPoints*/, 396cdf0e10cSrcweir const SalPoint* /*pPtAry*/, 397cdf0e10cSrcweir SalInvert /*nFlags*/ ) 398cdf0e10cSrcweir { 399cdf0e10cSrcweir DBG_ASSERT( 0, "Error: PrinterGfx::Invert() not implemented" ); 400cdf0e10cSrcweir } 401cdf0e10cSrcweir sal_Bool PspGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize ) 402cdf0e10cSrcweir { 403cdf0e10cSrcweir return m_pPrinterGfx->DrawEPS( Rectangle( Point( nX, nY ), Size( nWidth, nHeight ) ), pPtr, nSize ); 404cdf0e10cSrcweir } 405cdf0e10cSrcweir 4065f27b83cSArmin Le Grand void PspGraphics::copyBits( const SalTwoRect& /*rPosAry*/, 407cdf0e10cSrcweir SalGraphics* /*pSSrcGraphics*/ ) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir DBG_ERROR( "Error: PrinterGfx::CopyBits() not implemented" ); 410cdf0e10cSrcweir } 411cdf0e10cSrcweir 412cdf0e10cSrcweir void PspGraphics::copyArea ( long /*nDestX*/, long /*nDestY*/, 413cdf0e10cSrcweir long /*nSrcX*/, long /*nSrcY*/, 414cdf0e10cSrcweir long /*nSrcWidth*/, long /*nSrcHeight*/, 415cdf0e10cSrcweir sal_uInt16 /*nFlags*/ ) 416cdf0e10cSrcweir { 417cdf0e10cSrcweir DBG_ERROR( "Error: PrinterGfx::CopyArea() not implemented" ); 418cdf0e10cSrcweir } 419cdf0e10cSrcweir 4205f27b83cSArmin Le Grand void PspGraphics::drawBitmap( const SalTwoRect& rPosAry, const SalBitmap& rSalBitmap ) 421cdf0e10cSrcweir { 4225f27b83cSArmin Le Grand Rectangle aSrc (Point(rPosAry.mnSrcX, rPosAry.mnSrcY), 4235f27b83cSArmin Le Grand Size(rPosAry.mnSrcWidth, rPosAry.mnSrcHeight)); 4245f27b83cSArmin Le Grand Rectangle aDst (Point(rPosAry.mnDestX, rPosAry.mnDestY), 4255f27b83cSArmin Le Grand Size(rPosAry.mnDestWidth, rPosAry.mnDestHeight)); 426cdf0e10cSrcweir 427cdf0e10cSrcweir const SvpSalBitmap* pBmp = dynamic_cast<const SvpSalBitmap*>(&rSalBitmap); 428cdf0e10cSrcweir if( pBmp ) 429cdf0e10cSrcweir { 430cdf0e10cSrcweir SalPrinterBmp aBmp(pBmp->getBitmap()); 431cdf0e10cSrcweir m_pPrinterGfx->DrawBitmap(aDst, aSrc, aBmp); 432cdf0e10cSrcweir } 433cdf0e10cSrcweir } 434cdf0e10cSrcweir 4355f27b83cSArmin Le Grand void PspGraphics::drawBitmap( const SalTwoRect& /*pPosAry*/, 436cdf0e10cSrcweir const SalBitmap& /*rSalBitmap*/, 437cdf0e10cSrcweir const SalBitmap& /*rTransBitmap*/ ) 438cdf0e10cSrcweir { 439cdf0e10cSrcweir DBG_ERROR("Error: no PrinterGfx::DrawBitmap() for transparent bitmap"); 440cdf0e10cSrcweir } 441cdf0e10cSrcweir 4425f27b83cSArmin Le Grand void PspGraphics::drawBitmap( const SalTwoRect& /*pPosAry*/, 443cdf0e10cSrcweir const SalBitmap& /*rSalBitmap*/, 444cdf0e10cSrcweir SalColor /*nTransparentColor*/ ) 445cdf0e10cSrcweir { 446cdf0e10cSrcweir DBG_ERROR("Error: no PrinterGfx::DrawBitmap() for transparent color"); 447cdf0e10cSrcweir } 448cdf0e10cSrcweir 4495f27b83cSArmin Le Grand void PspGraphics::drawMask( const SalTwoRect& /*rPosAry*/, 450cdf0e10cSrcweir const SalBitmap& /*rSalBitmap*/, 451cdf0e10cSrcweir SalColor /*nMaskColor*/ ) 452cdf0e10cSrcweir { 453cdf0e10cSrcweir DBG_ERROR("Error: PrinterGfx::DrawMask() not implemented"); 454cdf0e10cSrcweir } 455cdf0e10cSrcweir 456cdf0e10cSrcweir SalBitmap* PspGraphics::getBitmap( long /*nX*/, long /*nY*/, long /*nDX*/, long /*nDY*/ ) 457cdf0e10cSrcweir { 458cdf0e10cSrcweir DBG_WARNING ("Warning: PrinterGfx::GetBitmap() not implemented"); 459cdf0e10cSrcweir return NULL; 460cdf0e10cSrcweir } 461cdf0e10cSrcweir 462cdf0e10cSrcweir SalColor PspGraphics::getPixel( long /*nX*/, long /*nY*/ ) 463cdf0e10cSrcweir { 464cdf0e10cSrcweir DBG_ERROR ("Warning: PrinterGfx::GetPixel() not implemented"); 465cdf0e10cSrcweir return 0; 466cdf0e10cSrcweir } 467cdf0e10cSrcweir 468cdf0e10cSrcweir void PspGraphics::invert( 469cdf0e10cSrcweir long /*nX*/, 470cdf0e10cSrcweir long /*nY*/, 471cdf0e10cSrcweir long /*nDX*/, 472cdf0e10cSrcweir long /*nDY*/, 473cdf0e10cSrcweir SalInvert /*nFlags*/ ) 474cdf0e10cSrcweir { 475cdf0e10cSrcweir DBG_ERROR ("Warning: PrinterGfx::Invert() not implemented"); 476cdf0e10cSrcweir } 477cdf0e10cSrcweir 478cdf0e10cSrcweir //========================================================================== 479cdf0e10cSrcweir 480cdf0e10cSrcweir class ImplPspFontData : public ImplFontData 481cdf0e10cSrcweir { 482cdf0e10cSrcweir private: 483cdf0e10cSrcweir enum { PSPFD_MAGIC = 0xb5bf01f0 }; 484cdf0e10cSrcweir sal_IntPtr mnFontId; 485cdf0e10cSrcweir 486cdf0e10cSrcweir public: 487cdf0e10cSrcweir ImplPspFontData( const psp::FastPrintFontInfo& ); 488cdf0e10cSrcweir virtual sal_IntPtr GetFontId() const { return mnFontId; } 489cdf0e10cSrcweir virtual ImplFontData* Clone() const { return new ImplPspFontData( *this ); } 490cdf0e10cSrcweir virtual ImplFontEntry* CreateFontInstance( ImplFontSelectData& ) const; 491cdf0e10cSrcweir static bool CheckFontData( const ImplFontData& r ) { return r.CheckMagic( PSPFD_MAGIC ); } 492cdf0e10cSrcweir }; 493cdf0e10cSrcweir 494cdf0e10cSrcweir //-------------------------------------------------------------------------- 495cdf0e10cSrcweir 496cdf0e10cSrcweir ImplPspFontData::ImplPspFontData( const psp::FastPrintFontInfo& rInfo ) 497cdf0e10cSrcweir : ImplFontData( PspGraphics::Info2DevFontAttributes(rInfo), PSPFD_MAGIC ), 498cdf0e10cSrcweir mnFontId( rInfo.m_nID ) 499cdf0e10cSrcweir {} 500cdf0e10cSrcweir 501cdf0e10cSrcweir //-------------------------------------------------------------------------- 502cdf0e10cSrcweir 503cdf0e10cSrcweir ImplFontEntry* ImplPspFontData::CreateFontInstance( ImplFontSelectData& rFSD ) const 504cdf0e10cSrcweir { 505cdf0e10cSrcweir ImplServerFontEntry* pEntry = new ImplServerFontEntry( rFSD ); 506cdf0e10cSrcweir return pEntry; 507cdf0e10cSrcweir } 508cdf0e10cSrcweir 509cdf0e10cSrcweir //========================================================================== 510cdf0e10cSrcweir 511cdf0e10cSrcweir class PspFontLayout : public GenericSalLayout 512cdf0e10cSrcweir { 513cdf0e10cSrcweir public: 514cdf0e10cSrcweir PspFontLayout( ::psp::PrinterGfx& ); 515cdf0e10cSrcweir virtual bool LayoutText( ImplLayoutArgs& ); 516cdf0e10cSrcweir virtual void InitFont() const; 517cdf0e10cSrcweir virtual void DrawText( SalGraphics& ) const; 518cdf0e10cSrcweir private: 519cdf0e10cSrcweir ::psp::PrinterGfx& mrPrinterGfx; 520cdf0e10cSrcweir sal_IntPtr mnFontID; 521cdf0e10cSrcweir int mnFontHeight; 522cdf0e10cSrcweir int mnFontWidth; 523cdf0e10cSrcweir bool mbVertical; 524cdf0e10cSrcweir bool mbArtItalic; 525cdf0e10cSrcweir bool mbArtBold; 526cdf0e10cSrcweir }; 527cdf0e10cSrcweir 528cdf0e10cSrcweir //-------------------------------------------------------------------------- 529cdf0e10cSrcweir 530cdf0e10cSrcweir PspFontLayout::PspFontLayout( ::psp::PrinterGfx& rGfx ) 531cdf0e10cSrcweir : mrPrinterGfx( rGfx ) 532cdf0e10cSrcweir { 533cdf0e10cSrcweir mnFontID = mrPrinterGfx.GetFontID(); 534cdf0e10cSrcweir mnFontHeight = mrPrinterGfx.GetFontHeight(); 535cdf0e10cSrcweir mnFontWidth = mrPrinterGfx.GetFontWidth(); 536cdf0e10cSrcweir mbVertical = mrPrinterGfx.GetFontVertical(); 537cdf0e10cSrcweir mbArtItalic = mrPrinterGfx.GetArtificialItalic(); 538cdf0e10cSrcweir mbArtBold = mrPrinterGfx.GetArtificialBold(); 539cdf0e10cSrcweir } 540cdf0e10cSrcweir 541cdf0e10cSrcweir //-------------------------------------------------------------------------- 542cdf0e10cSrcweir 543cdf0e10cSrcweir bool PspFontLayout::LayoutText( ImplLayoutArgs& rArgs ) 544cdf0e10cSrcweir { 545cdf0e10cSrcweir mbVertical = ((rArgs.mnFlags & SAL_LAYOUT_VERTICAL) != 0); 546cdf0e10cSrcweir 547cdf0e10cSrcweir long nUnitsPerPixel = 1; 548cdf0e10cSrcweir int nOldGlyphId = -1; 549cdf0e10cSrcweir long nGlyphWidth = 0; 550cdf0e10cSrcweir int nCharPos = -1; 551cdf0e10cSrcweir Point aNewPos( 0, 0 ); 552cdf0e10cSrcweir GlyphItem aPrevItem; 553cdf0e10cSrcweir rtl_TextEncoding aFontEnc = mrPrinterGfx.GetFontMgr().getFontEncoding( mnFontID ); 554cdf0e10cSrcweir for(;;) 555cdf0e10cSrcweir { 556cdf0e10cSrcweir bool bRightToLeft; 557cdf0e10cSrcweir if( !rArgs.GetNextPos( &nCharPos, &bRightToLeft ) ) 558cdf0e10cSrcweir break; 559cdf0e10cSrcweir 560cdf0e10cSrcweir sal_UCS4 cChar = rArgs.mpStr[ nCharPos ]; 561cdf0e10cSrcweir if( bRightToLeft ) 562cdf0e10cSrcweir cChar = GetMirroredChar( cChar ); 563cdf0e10cSrcweir // symbol font aliasing: 0x0020-0x00ff -> 0xf020 -> 0xf0ff 564cdf0e10cSrcweir if( aFontEnc == RTL_TEXTENCODING_SYMBOL ) 565cdf0e10cSrcweir if( cChar < 256 ) 566cdf0e10cSrcweir cChar += 0xf000; 567*248a599fSHerbert Dürr sal_GlyphId aGlyphId( cChar); // printer glyphs = unicode 568cdf0e10cSrcweir 569cdf0e10cSrcweir // update fallback_runs if needed 570cdf0e10cSrcweir psp::CharacterMetric aMetric; 571cdf0e10cSrcweir mrPrinterGfx.GetFontMgr().getMetrics( mnFontID, cChar, cChar, &aMetric, mbVertical ); 572cdf0e10cSrcweir if( aMetric.width == -1 && aMetric.height == -1 ) 573cdf0e10cSrcweir rArgs.NeedFallback( nCharPos, bRightToLeft ); 574cdf0e10cSrcweir 575cdf0e10cSrcweir // apply pair kerning to prev glyph if requested 576cdf0e10cSrcweir if( SAL_LAYOUT_KERNING_PAIRS & rArgs.mnFlags ) 577cdf0e10cSrcweir { 578cdf0e10cSrcweir if( nOldGlyphId > 0 ) 579cdf0e10cSrcweir { 580cdf0e10cSrcweir const std::list< KernPair >& rKernPairs = mrPrinterGfx.getKernPairs(mbVertical); 581cdf0e10cSrcweir for( std::list< KernPair >::const_iterator it = rKernPairs.begin(); 582cdf0e10cSrcweir it != rKernPairs.end(); ++it ) 583cdf0e10cSrcweir { 584*248a599fSHerbert Dürr if( it->first == nOldGlyphId && it->second == aGlyphId ) 585cdf0e10cSrcweir { 586cdf0e10cSrcweir int nTextScale = mrPrinterGfx.GetFontWidth(); 587cdf0e10cSrcweir if( ! nTextScale ) 588cdf0e10cSrcweir nTextScale = mrPrinterGfx.GetFontHeight(); 589cdf0e10cSrcweir int nKern = (mbVertical ? it->kern_y : it->kern_x) * nTextScale; 590cdf0e10cSrcweir nGlyphWidth += nKern; 591cdf0e10cSrcweir aPrevItem.mnNewWidth = nGlyphWidth; 592cdf0e10cSrcweir break; 593cdf0e10cSrcweir } 594cdf0e10cSrcweir } 595cdf0e10cSrcweir } 596cdf0e10cSrcweir } 597cdf0e10cSrcweir 598cdf0e10cSrcweir // finish previous glyph 599cdf0e10cSrcweir if( nOldGlyphId >= 0 ) 600cdf0e10cSrcweir AppendGlyph( aPrevItem ); 601*248a599fSHerbert Dürr nOldGlyphId = aGlyphId; 602cdf0e10cSrcweir aNewPos.X() += nGlyphWidth; 603cdf0e10cSrcweir 604cdf0e10cSrcweir // prepare GlyphItem for appending it in next round 605cdf0e10cSrcweir nUnitsPerPixel = mrPrinterGfx.GetCharWidth( cChar, cChar, &nGlyphWidth ); 606cdf0e10cSrcweir int nGlyphFlags = bRightToLeft ? GlyphItem::IS_RTL_GLYPH : 0; 607*248a599fSHerbert Dürr aGlyphId |= GF_ISCHAR; 608*248a599fSHerbert Dürr aPrevItem = GlyphItem( nCharPos, aGlyphId, aNewPos, nGlyphFlags, nGlyphWidth ); 609cdf0e10cSrcweir } 610cdf0e10cSrcweir 611cdf0e10cSrcweir // append last glyph item if any 612cdf0e10cSrcweir if( nOldGlyphId >= 0 ) 613cdf0e10cSrcweir AppendGlyph( aPrevItem ); 614cdf0e10cSrcweir 615cdf0e10cSrcweir SetOrientation( mrPrinterGfx.GetFontAngle() ); 616cdf0e10cSrcweir SetUnitsPerPixel( nUnitsPerPixel ); 617cdf0e10cSrcweir return (nOldGlyphId >= 0); 618cdf0e10cSrcweir } 619cdf0e10cSrcweir 620cdf0e10cSrcweir class PspServerFontLayout : public ServerFontLayout 621cdf0e10cSrcweir { 622cdf0e10cSrcweir public: 623cdf0e10cSrcweir PspServerFontLayout( psp::PrinterGfx&, ServerFont& rFont, const ImplLayoutArgs& rArgs ); 624cdf0e10cSrcweir 625cdf0e10cSrcweir virtual void InitFont() const; 626cdf0e10cSrcweir const sal_Unicode* getTextPtr() const { return maText.getStr() - mnMinCharPos; } 627cdf0e10cSrcweir int getMinCharPos() const { return mnMinCharPos; } 628cdf0e10cSrcweir int getMaxCharPos() const { return mnMinCharPos+maText.getLength()-1; } 629cdf0e10cSrcweir private: 630cdf0e10cSrcweir ::psp::PrinterGfx& mrPrinterGfx; 631cdf0e10cSrcweir sal_IntPtr mnFontID; 632cdf0e10cSrcweir int mnFontHeight; 633cdf0e10cSrcweir int mnFontWidth; 634cdf0e10cSrcweir bool mbVertical; 635cdf0e10cSrcweir bool mbArtItalic; 636cdf0e10cSrcweir bool mbArtBold; 637cdf0e10cSrcweir rtl::OUString maText; 638cdf0e10cSrcweir int mnMinCharPos; 639cdf0e10cSrcweir }; 640cdf0e10cSrcweir 641cdf0e10cSrcweir PspServerFontLayout::PspServerFontLayout( ::psp::PrinterGfx& rGfx, ServerFont& rFont, const ImplLayoutArgs& rArgs ) 642cdf0e10cSrcweir : ServerFontLayout( rFont ), 643cdf0e10cSrcweir mrPrinterGfx( rGfx ) 644cdf0e10cSrcweir { 645cdf0e10cSrcweir mnFontID = mrPrinterGfx.GetFontID(); 646cdf0e10cSrcweir mnFontHeight = mrPrinterGfx.GetFontHeight(); 647cdf0e10cSrcweir mnFontWidth = mrPrinterGfx.GetFontWidth(); 648cdf0e10cSrcweir mbVertical = mrPrinterGfx.GetFontVertical(); 649cdf0e10cSrcweir mbArtItalic = mrPrinterGfx.GetArtificialItalic(); 650cdf0e10cSrcweir mbArtBold = mrPrinterGfx.GetArtificialBold(); 651cdf0e10cSrcweir maText = OUString( rArgs.mpStr + rArgs.mnMinCharPos, rArgs.mnEndCharPos - rArgs.mnMinCharPos+1 ); 652cdf0e10cSrcweir mnMinCharPos = rArgs.mnMinCharPos; 653cdf0e10cSrcweir } 654cdf0e10cSrcweir 655cdf0e10cSrcweir void PspServerFontLayout::InitFont() const 656cdf0e10cSrcweir { 657cdf0e10cSrcweir mrPrinterGfx.SetFont( mnFontID, mnFontHeight, mnFontWidth, 658cdf0e10cSrcweir mnOrientation, mbVertical, mbArtItalic, mbArtBold ); 659cdf0e10cSrcweir } 660cdf0e10cSrcweir 661cdf0e10cSrcweir //-------------------------------------------------------------------------- 662cdf0e10cSrcweir 663cdf0e10cSrcweir static void DrawPrinterLayout( const SalLayout& rLayout, ::psp::PrinterGfx& rGfx, bool bIsPspServerFontLayout ) 664cdf0e10cSrcweir { 665cdf0e10cSrcweir const int nMaxGlyphs = 200; 666cdf0e10cSrcweir sal_GlyphId aGlyphAry[ nMaxGlyphs ]; 667cdf0e10cSrcweir sal_Int32 aWidthAry[ nMaxGlyphs ]; 668cdf0e10cSrcweir sal_Int32 aIdxAry [ nMaxGlyphs ]; 669cdf0e10cSrcweir sal_Ucs aUnicodes[ nMaxGlyphs ]; 670cdf0e10cSrcweir int aCharPosAry [ nMaxGlyphs ]; 671cdf0e10cSrcweir 672cdf0e10cSrcweir Point aPos; 673cdf0e10cSrcweir long nUnitsPerPixel = rLayout.GetUnitsPerPixel(); 674cdf0e10cSrcweir const sal_Unicode* pText = bIsPspServerFontLayout ? static_cast<const PspServerFontLayout&>(rLayout).getTextPtr() : NULL; 675cdf0e10cSrcweir int nMinCharPos = bIsPspServerFontLayout ? static_cast<const PspServerFontLayout&>(rLayout).getMinCharPos() : 0; 676cdf0e10cSrcweir int nMaxCharPos = bIsPspServerFontLayout ? static_cast<const PspServerFontLayout&>(rLayout).getMaxCharPos() : 0; 677cdf0e10cSrcweir for( int nStart = 0;; ) 678cdf0e10cSrcweir { 679cdf0e10cSrcweir int nGlyphCount = rLayout.GetNextGlyphs( nMaxGlyphs, aGlyphAry, aPos, nStart, aWidthAry, bIsPspServerFontLayout ? aCharPosAry : NULL ); 680cdf0e10cSrcweir if( !nGlyphCount ) 681cdf0e10cSrcweir break; 682cdf0e10cSrcweir 683cdf0e10cSrcweir sal_Int32 nXOffset = 0; 684cdf0e10cSrcweir for( int i = 0; i < nGlyphCount; ++i ) 685cdf0e10cSrcweir { 686cdf0e10cSrcweir nXOffset += aWidthAry[ i ]; 687cdf0e10cSrcweir aIdxAry[ i ] = nXOffset / nUnitsPerPixel; 688*248a599fSHerbert Dürr sal_GlyphId aGlyphId = aGlyphAry[i] & (GF_IDXMASK | GF_ROTMASK); 689cdf0e10cSrcweir if( bIsPspServerFontLayout ) 690cdf0e10cSrcweir aUnicodes[i] = (aCharPosAry[i] >= nMinCharPos && aCharPosAry[i] <= nMaxCharPos) ? pText[ aCharPosAry[i] ] : 0; 691cdf0e10cSrcweir else 692*248a599fSHerbert Dürr aUnicodes[i] = (aGlyphAry[i] & GF_ISCHAR) ? aGlyphId : 0; 693*248a599fSHerbert Dürr aGlyphAry[i] = aGlyphId; 694cdf0e10cSrcweir } 695cdf0e10cSrcweir 696*248a599fSHerbert Dürr rGfx.DrawGlyphs( aPos, aGlyphAry, aUnicodes, nGlyphCount, aIdxAry ); 697cdf0e10cSrcweir } 698cdf0e10cSrcweir } 699cdf0e10cSrcweir 700cdf0e10cSrcweir //-------------------------------------------------------------------------- 701cdf0e10cSrcweir 702cdf0e10cSrcweir void PspFontLayout::InitFont() const 703cdf0e10cSrcweir { 704cdf0e10cSrcweir mrPrinterGfx.SetFont( mnFontID, mnFontHeight, mnFontWidth, 705cdf0e10cSrcweir mnOrientation, mbVertical, mbArtItalic, mbArtBold ); 706cdf0e10cSrcweir } 707cdf0e10cSrcweir 708cdf0e10cSrcweir //-------------------------------------------------------------------------- 709cdf0e10cSrcweir 710cdf0e10cSrcweir void PspFontLayout::DrawText( SalGraphics& ) const 711cdf0e10cSrcweir { 712cdf0e10cSrcweir DrawPrinterLayout( *this, mrPrinterGfx, false ); 713cdf0e10cSrcweir } 714cdf0e10cSrcweir 715cdf0e10cSrcweir void PspGraphics::DrawServerFontLayout( const ServerFontLayout& rLayout ) 716cdf0e10cSrcweir { 717cdf0e10cSrcweir // print complex text 718cdf0e10cSrcweir DrawPrinterLayout( rLayout, *m_pPrinterGfx, true ); 719cdf0e10cSrcweir } 720cdf0e10cSrcweir 721cdf0e10cSrcweir const ImplFontCharMap* PspGraphics::GetImplFontCharMap() const 722cdf0e10cSrcweir { 723cdf0e10cSrcweir if( !m_pServerFont[0] ) 724cdf0e10cSrcweir return NULL; 725cdf0e10cSrcweir 726cdf0e10cSrcweir const ImplFontCharMap* pIFCMap = m_pServerFont[0]->GetImplFontCharMap(); 727cdf0e10cSrcweir return pIFCMap; 728cdf0e10cSrcweir } 729cdf0e10cSrcweir 730cdf0e10cSrcweir sal_uInt16 PspGraphics::SetFont( ImplFontSelectData *pEntry, int nFallbackLevel ) 731cdf0e10cSrcweir { 732cdf0e10cSrcweir // release all fonts that are to be overridden 733cdf0e10cSrcweir for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i ) 734cdf0e10cSrcweir { 735cdf0e10cSrcweir if( m_pServerFont[i] != NULL ) 736cdf0e10cSrcweir { 737cdf0e10cSrcweir // old server side font is no longer referenced 738cdf0e10cSrcweir GlyphCache::GetInstance().UncacheFont( *m_pServerFont[i] ); 739cdf0e10cSrcweir m_pServerFont[i] = NULL; 740cdf0e10cSrcweir } 741cdf0e10cSrcweir } 742cdf0e10cSrcweir 743cdf0e10cSrcweir // return early if there is no new font 744cdf0e10cSrcweir if( !pEntry ) 745cdf0e10cSrcweir return 0; 746cdf0e10cSrcweir 747cdf0e10cSrcweir sal_IntPtr nID = pEntry->mpFontData ? pEntry->mpFontData->GetFontId() : 0; 748cdf0e10cSrcweir 749cdf0e10cSrcweir // determine which font attributes need to be emulated 750cdf0e10cSrcweir bool bArtItalic = false; 751cdf0e10cSrcweir bool bArtBold = false; 752cdf0e10cSrcweir if( pEntry->meItalic == ITALIC_OBLIQUE || pEntry->meItalic == ITALIC_NORMAL ) 753cdf0e10cSrcweir { 754cdf0e10cSrcweir psp::italic::type eItalic = m_pPrinterGfx->GetFontMgr().getFontItalic( nID ); 755cdf0e10cSrcweir if( eItalic != psp::italic::Italic && eItalic != psp::italic::Oblique ) 756cdf0e10cSrcweir bArtItalic = true; 757cdf0e10cSrcweir } 758cdf0e10cSrcweir int nWeight = (int)pEntry->meWeight; 759cdf0e10cSrcweir int nRealWeight = (int)m_pPrinterGfx->GetFontMgr().getFontWeight( nID ); 760cdf0e10cSrcweir if( nRealWeight <= (int)psp::weight::Medium && nWeight > (int)WEIGHT_MEDIUM ) 761cdf0e10cSrcweir { 762cdf0e10cSrcweir bArtBold = true; 763cdf0e10cSrcweir } 764cdf0e10cSrcweir 765cdf0e10cSrcweir // also set the serverside font for layouting 766cdf0e10cSrcweir m_bFontVertical = pEntry->mbVertical; 767cdf0e10cSrcweir if( pEntry->mpFontData ) 768cdf0e10cSrcweir { 769cdf0e10cSrcweir // requesting a font provided by builtin rasterizer 770cdf0e10cSrcweir ServerFont* pServerFont = GlyphCache::GetInstance().CacheFont( *pEntry ); 771cdf0e10cSrcweir if( pServerFont != NULL ) 772cdf0e10cSrcweir { 773cdf0e10cSrcweir if( pServerFont->TestFont() ) 774cdf0e10cSrcweir m_pServerFont[ nFallbackLevel ] = pServerFont; 775cdf0e10cSrcweir else 776cdf0e10cSrcweir GlyphCache::GetInstance().UncacheFont( *pServerFont ); 777cdf0e10cSrcweir } 778cdf0e10cSrcweir } 779cdf0e10cSrcweir 780cdf0e10cSrcweir // set the printer font 781cdf0e10cSrcweir return m_pPrinterGfx->SetFont( nID, 782cdf0e10cSrcweir pEntry->mnHeight, 783cdf0e10cSrcweir pEntry->mnWidth, 784cdf0e10cSrcweir pEntry->mnOrientation, 785cdf0e10cSrcweir pEntry->mbVertical, 786cdf0e10cSrcweir bArtItalic, 787cdf0e10cSrcweir bArtBold 788cdf0e10cSrcweir ); 789cdf0e10cSrcweir } 790cdf0e10cSrcweir 791cdf0e10cSrcweir void PspGraphics::SetTextColor( SalColor nSalColor ) 792cdf0e10cSrcweir { 793cdf0e10cSrcweir psp::PrinterColor aColor (SALCOLOR_RED (nSalColor), 794cdf0e10cSrcweir SALCOLOR_GREEN (nSalColor), 795cdf0e10cSrcweir SALCOLOR_BLUE (nSalColor)); 796cdf0e10cSrcweir m_pPrinterGfx->SetTextColor (aColor); 797cdf0e10cSrcweir } 798cdf0e10cSrcweir 799cdf0e10cSrcweir bool PspGraphics::AddTempDevFont( ImplDevFontList*, const String&, const String& ) 800cdf0e10cSrcweir { 801cdf0e10cSrcweir return false; 802cdf0e10cSrcweir } 803cdf0e10cSrcweir 804cdf0e10cSrcweir void PspGraphics::GetDevFontList( ImplDevFontList *pList ) 805cdf0e10cSrcweir { 806cdf0e10cSrcweir ::std::list< psp::fontID > aList; 807cdf0e10cSrcweir psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); 808cdf0e10cSrcweir rMgr.getFontList( aList, m_pJobData->m_pParser, m_pInfoPrinter->m_bCompatMetrics ); 809cdf0e10cSrcweir 810cdf0e10cSrcweir ::std::list< psp::fontID >::iterator it; 811cdf0e10cSrcweir psp::FastPrintFontInfo aInfo; 812cdf0e10cSrcweir for (it = aList.begin(); it != aList.end(); ++it) 813cdf0e10cSrcweir if (rMgr.getFontFastInfo (*it, aInfo)) 814cdf0e10cSrcweir AnnounceFonts( pList, aInfo ); 815cdf0e10cSrcweir } 816cdf0e10cSrcweir 817cdf0e10cSrcweir void PspGraphics::GetDevFontSubstList( OutputDevice* pOutDev ) 818cdf0e10cSrcweir { 819cdf0e10cSrcweir const psp::PrinterInfo& rInfo = psp::PrinterInfoManager::get().getPrinterInfo( m_pJobData->m_aPrinterName ); 820cdf0e10cSrcweir if( rInfo.m_bPerformFontSubstitution ) 821cdf0e10cSrcweir { 822cdf0e10cSrcweir for( std::hash_map< rtl::OUString, rtl::OUString, rtl::OUStringHash >::const_iterator it = rInfo.m_aFontSubstitutes.begin(); it != rInfo.m_aFontSubstitutes.end(); ++it ) 823cdf0e10cSrcweir AddDevFontSubstitute( pOutDev, it->first, it->second, FONT_SUBSTITUTE_ALWAYS ); 824cdf0e10cSrcweir } 825cdf0e10cSrcweir } 826cdf0e10cSrcweir 827cdf0e10cSrcweir void PspGraphics::GetFontMetric( ImplFontMetricData *pMetric, int ) 828cdf0e10cSrcweir { 829cdf0e10cSrcweir const psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); 830cdf0e10cSrcweir psp::PrintFontInfo aInfo; 831cdf0e10cSrcweir 832cdf0e10cSrcweir if (rMgr.getFontInfo (m_pPrinterGfx->GetFontID(), aInfo)) 833cdf0e10cSrcweir { 834cdf0e10cSrcweir ImplDevFontAttributes aDFA = Info2DevFontAttributes( aInfo ); 835cdf0e10cSrcweir static_cast<ImplFontAttributes&>(*pMetric) = aDFA; 836cdf0e10cSrcweir pMetric->mbDevice = aDFA.mbDevice; 837cdf0e10cSrcweir pMetric->mbScalableFont = true; 838cdf0e10cSrcweir 839cdf0e10cSrcweir pMetric->mnOrientation = m_pPrinterGfx->GetFontAngle(); 840cdf0e10cSrcweir pMetric->mnSlant = 0; 841cdf0e10cSrcweir 842cdf0e10cSrcweir sal_Int32 nTextHeight = m_pPrinterGfx->GetFontHeight(); 843cdf0e10cSrcweir sal_Int32 nTextWidth = m_pPrinterGfx->GetFontWidth(); 844cdf0e10cSrcweir if( ! nTextWidth ) 845cdf0e10cSrcweir nTextWidth = nTextHeight; 846cdf0e10cSrcweir 847cdf0e10cSrcweir pMetric->mnWidth = nTextWidth; 848cdf0e10cSrcweir pMetric->mnAscent = ( aInfo.m_nAscend * nTextHeight + 500 ) / 1000; 849cdf0e10cSrcweir pMetric->mnDescent = ( aInfo.m_nDescend * nTextHeight + 500 ) / 1000; 850cdf0e10cSrcweir pMetric->mnIntLeading = ( aInfo.m_nLeading * nTextHeight + 500 ) / 1000; 851cdf0e10cSrcweir pMetric->mnExtLeading = 0; 852cdf0e10cSrcweir } 853cdf0e10cSrcweir } 854cdf0e10cSrcweir 855cdf0e10cSrcweir sal_uLong PspGraphics::GetKernPairs( sal_uLong nPairs, ImplKernPairData *pKernPairs ) 856cdf0e10cSrcweir { 857cdf0e10cSrcweir const ::std::list< ::psp::KernPair >& rPairs( m_pPrinterGfx->getKernPairs() ); 858cdf0e10cSrcweir sal_uLong nHavePairs = rPairs.size(); 859cdf0e10cSrcweir if( pKernPairs && nPairs ) 860cdf0e10cSrcweir { 861cdf0e10cSrcweir ::std::list< ::psp::KernPair >::const_iterator it; 862cdf0e10cSrcweir unsigned int i; 863cdf0e10cSrcweir int nTextScale = m_pPrinterGfx->GetFontWidth(); 864cdf0e10cSrcweir if( ! nTextScale ) 865cdf0e10cSrcweir nTextScale = m_pPrinterGfx->GetFontHeight(); 866cdf0e10cSrcweir for( i = 0, it = rPairs.begin(); i < nPairs && i < nHavePairs; i++, ++it ) 867cdf0e10cSrcweir { 868cdf0e10cSrcweir pKernPairs[i].mnChar1 = it->first; 869cdf0e10cSrcweir pKernPairs[i].mnChar2 = it->second; 870cdf0e10cSrcweir pKernPairs[i].mnKern = it->kern_x * nTextScale / 1000; 871cdf0e10cSrcweir } 872cdf0e10cSrcweir 873cdf0e10cSrcweir } 874cdf0e10cSrcweir return nHavePairs; 875cdf0e10cSrcweir } 876cdf0e10cSrcweir 877*248a599fSHerbert Dürr bool PspGraphics::GetGlyphBoundRect( sal_GlyphId aGlyphId, Rectangle& rRect ) 878cdf0e10cSrcweir { 879*248a599fSHerbert Dürr const int nLevel = aGlyphId >> GF_FONTSHIFT; 880cdf0e10cSrcweir if( nLevel >= MAX_FALLBACK ) 881*248a599fSHerbert Dürr return false; 882cdf0e10cSrcweir 883cdf0e10cSrcweir ServerFont* pSF = m_pServerFont[ nLevel ]; 884cdf0e10cSrcweir if( !pSF ) 885*248a599fSHerbert Dürr return false; 886cdf0e10cSrcweir 887*248a599fSHerbert Dürr aGlyphId &= ~GF_FONTMASK; 888*248a599fSHerbert Dürr const GlyphMetric& rGM = pSF->GetGlyphMetric( aGlyphId ); 889cdf0e10cSrcweir rRect = Rectangle( rGM.GetOffset(), rGM.GetSize() ); 890*248a599fSHerbert Dürr return true; 891cdf0e10cSrcweir } 892cdf0e10cSrcweir 893*248a599fSHerbert Dürr bool PspGraphics::GetGlyphOutline( sal_GlyphId aGlyphId, 894cdf0e10cSrcweir ::basegfx::B2DPolyPolygon& rB2DPolyPoly ) 895cdf0e10cSrcweir { 896*248a599fSHerbert Dürr const int nLevel = aGlyphId >> GF_FONTSHIFT; 897cdf0e10cSrcweir if( nLevel >= MAX_FALLBACK ) 898cdf0e10cSrcweir return sal_False; 899cdf0e10cSrcweir 900cdf0e10cSrcweir ServerFont* pSF = m_pServerFont[ nLevel ]; 901cdf0e10cSrcweir if( !pSF ) 902cdf0e10cSrcweir return sal_False; 903cdf0e10cSrcweir 904*248a599fSHerbert Dürr aGlyphId &= ~GF_FONTMASK; 905*248a599fSHerbert Dürr bool bOK = pSF->GetGlyphOutline( aGlyphId, rB2DPolyPoly ); 906*248a599fSHerbert Dürr return bOK; 907cdf0e10cSrcweir } 908cdf0e10cSrcweir 909cdf0e10cSrcweir SalLayout* PspGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel ) 910cdf0e10cSrcweir { 911cdf0e10cSrcweir // workaround for printers not handling glyph indexing for non-TT fonts 912cdf0e10cSrcweir int nFontId = m_pPrinterGfx->GetFontID(); 913cdf0e10cSrcweir if( psp::fonttype::TrueType != psp::PrintFontManager::get().getFontType( nFontId ) ) 914cdf0e10cSrcweir rArgs.mnFlags |= SAL_LAYOUT_DISABLE_GLYPH_PROCESSING; 915cdf0e10cSrcweir else if( nFallbackLevel > 0 ) 916cdf0e10cSrcweir rArgs.mnFlags &= ~SAL_LAYOUT_DISABLE_GLYPH_PROCESSING; 917cdf0e10cSrcweir 918cdf0e10cSrcweir GenericSalLayout* pLayout = NULL; 919cdf0e10cSrcweir 920cdf0e10cSrcweir if( m_pServerFont[ nFallbackLevel ] 921cdf0e10cSrcweir && !(rArgs.mnFlags & SAL_LAYOUT_DISABLE_GLYPH_PROCESSING) ) 922cdf0e10cSrcweir pLayout = new PspServerFontLayout( *m_pPrinterGfx, *m_pServerFont[nFallbackLevel], rArgs ); 923cdf0e10cSrcweir else 924cdf0e10cSrcweir pLayout = new PspFontLayout( *m_pPrinterGfx ); 925cdf0e10cSrcweir 926cdf0e10cSrcweir return pLayout; 927cdf0e10cSrcweir } 928cdf0e10cSrcweir 929cdf0e10cSrcweir //-------------------------------------------------------------------------- 930cdf0e10cSrcweir 931cdf0e10cSrcweir sal_Bool PspGraphics::CreateFontSubset( 932cdf0e10cSrcweir const rtl::OUString& rToFile, 933cdf0e10cSrcweir const ImplFontData* pFont, 934*248a599fSHerbert Dürr sal_GlyphId* pGlyphIds, 935cdf0e10cSrcweir sal_uInt8* pEncoding, 936cdf0e10cSrcweir sal_Int32* pWidths, 937cdf0e10cSrcweir int nGlyphCount, 938cdf0e10cSrcweir FontSubsetInfo& rInfo 939cdf0e10cSrcweir ) 940cdf0e10cSrcweir { 941cdf0e10cSrcweir // in this context the pFont->GetFontId() is a valid PSP 942cdf0e10cSrcweir // font since they are the only ones left after the PDF 943cdf0e10cSrcweir // export has filtered its list of subsettable fonts (for 944cdf0e10cSrcweir // which this method was created). The correct way would 945cdf0e10cSrcweir // be to have the GlyphCache search for the ImplFontData pFont 946cdf0e10cSrcweir psp::fontID aFont = pFont->GetFontId(); 947cdf0e10cSrcweir 948cdf0e10cSrcweir psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); 949cdf0e10cSrcweir bool bSuccess = rMgr.createFontSubset( rInfo, 950cdf0e10cSrcweir aFont, 951cdf0e10cSrcweir rToFile, 952*248a599fSHerbert Dürr pGlyphIds, 953cdf0e10cSrcweir pEncoding, 954cdf0e10cSrcweir pWidths, 955cdf0e10cSrcweir nGlyphCount ); 956cdf0e10cSrcweir return bSuccess; 957cdf0e10cSrcweir } 958cdf0e10cSrcweir 959cdf0e10cSrcweir //-------------------------------------------------------------------------- 960cdf0e10cSrcweir 961cdf0e10cSrcweir const void* PspGraphics::GetEmbedFontData( const ImplFontData* pFont, const sal_Ucs* pUnicodes, sal_Int32* pWidths, FontSubsetInfo& rInfo, long* pDataLen ) 962cdf0e10cSrcweir { 963cdf0e10cSrcweir // in this context the pFont->GetFontId() is a valid PSP 964cdf0e10cSrcweir // font since they are the only ones left after the PDF 965cdf0e10cSrcweir // export has filtered its list of subsettable fonts (for 966cdf0e10cSrcweir // which this method was created). The correct way would 967cdf0e10cSrcweir // be to have the GlyphCache search for the ImplFontData pFont 968cdf0e10cSrcweir psp::fontID aFont = pFont->GetFontId(); 969cdf0e10cSrcweir return PspGraphics::DoGetEmbedFontData( aFont, pUnicodes, pWidths, rInfo, pDataLen ); 970cdf0e10cSrcweir } 971cdf0e10cSrcweir 972cdf0e10cSrcweir //-------------------------------------------------------------------------- 973cdf0e10cSrcweir 974cdf0e10cSrcweir void PspGraphics::FreeEmbedFontData( const void* pData, long nLen ) 975cdf0e10cSrcweir { 976cdf0e10cSrcweir PspGraphics::DoFreeEmbedFontData( pData, nLen ); 977cdf0e10cSrcweir } 978cdf0e10cSrcweir 979cdf0e10cSrcweir //-------------------------------------------------------------------------- 980cdf0e10cSrcweir 981cdf0e10cSrcweir const Ucs2SIntMap* PspGraphics::GetFontEncodingVector( const ImplFontData* pFont, const Ucs2OStrMap** pNonEncoded ) 982cdf0e10cSrcweir { 983cdf0e10cSrcweir // in this context the pFont->GetFontId() is a valid PSP 984cdf0e10cSrcweir // font since they are the only ones left after the PDF 985cdf0e10cSrcweir // export has filtered its list of subsettable fonts (for 986cdf0e10cSrcweir // which this method was created). The correct way would 987cdf0e10cSrcweir // be to have the GlyphCache search for the ImplFontData pFont 988cdf0e10cSrcweir psp::fontID aFont = pFont->GetFontId(); 989cdf0e10cSrcweir return PspGraphics::DoGetFontEncodingVector( aFont, pNonEncoded ); 990cdf0e10cSrcweir } 991cdf0e10cSrcweir 992cdf0e10cSrcweir //-------------------------------------------------------------------------- 993cdf0e10cSrcweir 994cdf0e10cSrcweir void PspGraphics::GetGlyphWidths( const ImplFontData* pFont, 995cdf0e10cSrcweir bool bVertical, 996cdf0e10cSrcweir Int32Vector& rWidths, 997cdf0e10cSrcweir Ucs2UIntMap& rUnicodeEnc ) 998cdf0e10cSrcweir { 999cdf0e10cSrcweir // in this context the pFont->GetFontId() is a valid PSP 1000cdf0e10cSrcweir // font since they are the only ones left after the PDF 1001cdf0e10cSrcweir // export has filtered its list of subsettable fonts (for 1002cdf0e10cSrcweir // which this method was created). The correct way would 1003cdf0e10cSrcweir // be to have the GlyphCache search for the ImplFontData pFont 1004cdf0e10cSrcweir psp::fontID aFont = pFont->GetFontId(); 1005cdf0e10cSrcweir PspGraphics::DoGetGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc ); 1006cdf0e10cSrcweir } 1007cdf0e10cSrcweir 1008cdf0e10cSrcweir // static helpers of PspGraphics 1009cdf0e10cSrcweir 1010cdf0e10cSrcweir const void* PspGraphics::DoGetEmbedFontData( fontID aFont, const sal_Ucs* pUnicodes, sal_Int32* pWidths, FontSubsetInfo& rInfo, long* pDataLen ) 1011cdf0e10cSrcweir { 1012cdf0e10cSrcweir psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); 1013cdf0e10cSrcweir 1014cdf0e10cSrcweir psp::PrintFontInfo aFontInfo; 1015cdf0e10cSrcweir if( ! rMgr.getFontInfo( aFont, aFontInfo ) ) 1016cdf0e10cSrcweir return NULL; 1017cdf0e10cSrcweir 1018cdf0e10cSrcweir // fill in font info 1019cdf0e10cSrcweir rInfo.m_nAscent = aFontInfo.m_nAscend; 1020cdf0e10cSrcweir rInfo.m_nDescent = aFontInfo.m_nDescend; 1021cdf0e10cSrcweir rInfo.m_aPSName = rMgr.getPSName( aFont ); 1022cdf0e10cSrcweir 1023cdf0e10cSrcweir int xMin, yMin, xMax, yMax; 1024cdf0e10cSrcweir rMgr.getFontBoundingBox( aFont, xMin, yMin, xMax, yMax ); 1025cdf0e10cSrcweir 1026cdf0e10cSrcweir psp::CharacterMetric aMetrics[256]; 1027cdf0e10cSrcweir sal_Ucs aUnicodes[256]; 1028cdf0e10cSrcweir if( aFontInfo.m_aEncoding == RTL_TEXTENCODING_SYMBOL && aFontInfo.m_eType == psp::fonttype::Type1 ) 1029cdf0e10cSrcweir { 1030cdf0e10cSrcweir for( int i = 0; i < 256; i++ ) 1031cdf0e10cSrcweir aUnicodes[i] = pUnicodes[i] < 0x0100 ? pUnicodes[i] + 0xf000 : pUnicodes[i]; 1032cdf0e10cSrcweir pUnicodes = aUnicodes; 1033cdf0e10cSrcweir } 1034cdf0e10cSrcweir if( ! rMgr.getMetrics( aFont, pUnicodes, 256, aMetrics ) ) 1035cdf0e10cSrcweir return NULL; 1036cdf0e10cSrcweir 1037cdf0e10cSrcweir OString aSysPath = rMgr.getFontFileSysPath( aFont ); 1038cdf0e10cSrcweir struct stat aStat; 1039cdf0e10cSrcweir if( stat( aSysPath.getStr(), &aStat ) ) 1040cdf0e10cSrcweir return NULL; 1041cdf0e10cSrcweir int fd = open( aSysPath.getStr(), O_RDONLY ); 1042cdf0e10cSrcweir if( fd < 0 ) 1043cdf0e10cSrcweir return NULL; 1044cdf0e10cSrcweir void* pFile = mmap( NULL, aStat.st_size, PROT_READ, MAP_SHARED, fd, 0 ); 1045cdf0e10cSrcweir close( fd ); 1046cdf0e10cSrcweir if( pFile == MAP_FAILED ) 1047cdf0e10cSrcweir return NULL; 1048cdf0e10cSrcweir 1049cdf0e10cSrcweir *pDataLen = aStat.st_size; 1050cdf0e10cSrcweir 1051cdf0e10cSrcweir rInfo.m_aFontBBox = Rectangle( Point( xMin, yMin ), Size( xMax-xMin, yMax-yMin ) ); 1052cdf0e10cSrcweir rInfo.m_nCapHeight = yMax; // Well ... 1053cdf0e10cSrcweir 1054cdf0e10cSrcweir for( int i = 0; i < 256; i++ ) 1055cdf0e10cSrcweir pWidths[i] = (aMetrics[i].width > 0 ? aMetrics[i].width : 0); 1056cdf0e10cSrcweir 1057cdf0e10cSrcweir switch( aFontInfo.m_eType ) 1058cdf0e10cSrcweir { 1059cdf0e10cSrcweir case psp::fonttype::TrueType: 1060cdf0e10cSrcweir rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF; 1061cdf0e10cSrcweir break; 1062cdf0e10cSrcweir case psp::fonttype::Type1: { 1063cdf0e10cSrcweir const bool bPFA = ((*(unsigned char*)pFile) < 0x80); 1064cdf0e10cSrcweir rInfo.m_nFontType = bPFA ? FontSubsetInfo::TYPE1_PFA : FontSubsetInfo::TYPE1_PFB; 1065cdf0e10cSrcweir } 1066cdf0e10cSrcweir break; 1067cdf0e10cSrcweir default: 1068cdf0e10cSrcweir return NULL; 1069cdf0e10cSrcweir } 1070cdf0e10cSrcweir 1071cdf0e10cSrcweir return pFile; 1072cdf0e10cSrcweir } 1073cdf0e10cSrcweir 1074cdf0e10cSrcweir void PspGraphics::DoFreeEmbedFontData( const void* pData, long nLen ) 1075cdf0e10cSrcweir { 1076cdf0e10cSrcweir if( pData ) 1077cdf0e10cSrcweir munmap( (char*)pData, nLen ); 1078cdf0e10cSrcweir } 1079cdf0e10cSrcweir 1080cdf0e10cSrcweir const Ucs2SIntMap* PspGraphics::DoGetFontEncodingVector( fontID aFont, const Ucs2OStrMap** pNonEncoded ) 1081cdf0e10cSrcweir { 1082cdf0e10cSrcweir psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); 1083cdf0e10cSrcweir 1084cdf0e10cSrcweir psp::PrintFontInfo aFontInfo; 1085cdf0e10cSrcweir if( ! rMgr.getFontInfo( aFont, aFontInfo ) ) 1086cdf0e10cSrcweir { 1087cdf0e10cSrcweir if( pNonEncoded ) 1088cdf0e10cSrcweir *pNonEncoded = NULL; 1089cdf0e10cSrcweir return NULL; 1090cdf0e10cSrcweir } 1091cdf0e10cSrcweir 1092cdf0e10cSrcweir return rMgr.getEncodingMap( aFont, pNonEncoded ); 1093cdf0e10cSrcweir } 1094cdf0e10cSrcweir 1095cdf0e10cSrcweir void PspGraphics::DoGetGlyphWidths( psp::fontID aFont, 1096cdf0e10cSrcweir bool bVertical, 1097cdf0e10cSrcweir Int32Vector& rWidths, 1098cdf0e10cSrcweir Ucs2UIntMap& rUnicodeEnc ) 1099cdf0e10cSrcweir { 1100cdf0e10cSrcweir psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); 1101cdf0e10cSrcweir rMgr.getGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc ); 1102cdf0e10cSrcweir } 1103cdf0e10cSrcweir 1104cdf0e10cSrcweir // ---------------------------------------------------------------------------- 1105cdf0e10cSrcweir 1106cdf0e10cSrcweir FontWidth PspGraphics::ToFontWidth (psp::width::type eWidth) 1107cdf0e10cSrcweir { 1108cdf0e10cSrcweir switch (eWidth) 1109cdf0e10cSrcweir { 1110cdf0e10cSrcweir case psp::width::UltraCondensed: return WIDTH_ULTRA_CONDENSED; 1111cdf0e10cSrcweir case psp::width::ExtraCondensed: return WIDTH_EXTRA_CONDENSED; 1112cdf0e10cSrcweir case psp::width::Condensed: return WIDTH_CONDENSED; 1113cdf0e10cSrcweir case psp::width::SemiCondensed: return WIDTH_SEMI_CONDENSED; 1114cdf0e10cSrcweir case psp::width::Normal: return WIDTH_NORMAL; 1115cdf0e10cSrcweir case psp::width::SemiExpanded: return WIDTH_SEMI_EXPANDED; 1116cdf0e10cSrcweir case psp::width::Expanded: return WIDTH_EXPANDED; 1117cdf0e10cSrcweir case psp::width::ExtraExpanded: return WIDTH_EXTRA_EXPANDED; 1118cdf0e10cSrcweir case psp::width::UltraExpanded: return WIDTH_ULTRA_EXPANDED; 1119cdf0e10cSrcweir default: break; 1120cdf0e10cSrcweir } 1121cdf0e10cSrcweir return WIDTH_DONTKNOW; 1122cdf0e10cSrcweir } 1123cdf0e10cSrcweir 1124cdf0e10cSrcweir FontWeight PspGraphics::ToFontWeight (psp::weight::type eWeight) 1125cdf0e10cSrcweir { 1126cdf0e10cSrcweir switch (eWeight) 1127cdf0e10cSrcweir { 1128cdf0e10cSrcweir case psp::weight::Thin: return WEIGHT_THIN; 1129cdf0e10cSrcweir case psp::weight::UltraLight: return WEIGHT_ULTRALIGHT; 1130cdf0e10cSrcweir case psp::weight::Light: return WEIGHT_LIGHT; 1131cdf0e10cSrcweir case psp::weight::SemiLight: return WEIGHT_SEMILIGHT; 1132cdf0e10cSrcweir case psp::weight::Normal: return WEIGHT_NORMAL; 1133cdf0e10cSrcweir case psp::weight::Medium: return WEIGHT_MEDIUM; 1134cdf0e10cSrcweir case psp::weight::SemiBold: return WEIGHT_SEMIBOLD; 1135cdf0e10cSrcweir case psp::weight::Bold: return WEIGHT_BOLD; 1136cdf0e10cSrcweir case psp::weight::UltraBold: return WEIGHT_ULTRABOLD; 1137cdf0e10cSrcweir case psp::weight::Black: return WEIGHT_BLACK; 1138cdf0e10cSrcweir default: break; 1139cdf0e10cSrcweir } 1140cdf0e10cSrcweir return WEIGHT_DONTKNOW; 1141cdf0e10cSrcweir } 1142cdf0e10cSrcweir 1143cdf0e10cSrcweir FontPitch PspGraphics::ToFontPitch (psp::pitch::type ePitch) 1144cdf0e10cSrcweir { 1145cdf0e10cSrcweir switch (ePitch) 1146cdf0e10cSrcweir { 1147cdf0e10cSrcweir case psp::pitch::Fixed: return PITCH_FIXED; 1148cdf0e10cSrcweir case psp::pitch::Variable: return PITCH_VARIABLE; 1149cdf0e10cSrcweir default: break; 1150cdf0e10cSrcweir } 1151cdf0e10cSrcweir return PITCH_DONTKNOW; 1152cdf0e10cSrcweir } 1153cdf0e10cSrcweir 1154cdf0e10cSrcweir FontItalic PspGraphics::ToFontItalic (psp::italic::type eItalic) 1155cdf0e10cSrcweir { 1156cdf0e10cSrcweir switch (eItalic) 1157cdf0e10cSrcweir { 1158cdf0e10cSrcweir case psp::italic::Upright: return ITALIC_NONE; 1159cdf0e10cSrcweir case psp::italic::Oblique: return ITALIC_OBLIQUE; 1160cdf0e10cSrcweir case psp::italic::Italic: return ITALIC_NORMAL; 1161cdf0e10cSrcweir default: break; 1162cdf0e10cSrcweir } 1163cdf0e10cSrcweir return ITALIC_DONTKNOW; 1164cdf0e10cSrcweir } 1165cdf0e10cSrcweir 1166cdf0e10cSrcweir FontFamily PspGraphics::ToFontFamily (psp::family::type eFamily) 1167cdf0e10cSrcweir { 1168cdf0e10cSrcweir switch (eFamily) 1169cdf0e10cSrcweir { 1170cdf0e10cSrcweir case psp::family::Decorative: return FAMILY_DECORATIVE; 1171cdf0e10cSrcweir case psp::family::Modern: return FAMILY_MODERN; 1172cdf0e10cSrcweir case psp::family::Roman: return FAMILY_ROMAN; 1173cdf0e10cSrcweir case psp::family::Script: return FAMILY_SCRIPT; 1174cdf0e10cSrcweir case psp::family::Swiss: return FAMILY_SWISS; 1175cdf0e10cSrcweir case psp::family::System: return FAMILY_SYSTEM; 1176cdf0e10cSrcweir default: break; 1177cdf0e10cSrcweir } 1178cdf0e10cSrcweir return FAMILY_DONTKNOW; 1179cdf0e10cSrcweir } 1180cdf0e10cSrcweir 1181cdf0e10cSrcweir ImplDevFontAttributes PspGraphics::Info2DevFontAttributes( const psp::FastPrintFontInfo& rInfo ) 1182cdf0e10cSrcweir { 1183cdf0e10cSrcweir ImplDevFontAttributes aDFA; 1184cdf0e10cSrcweir aDFA.maName = rInfo.m_aFamilyName; 1185cdf0e10cSrcweir aDFA.maStyleName = rInfo.m_aStyleName; 1186cdf0e10cSrcweir aDFA.meFamily = ToFontFamily (rInfo.m_eFamilyStyle); 1187cdf0e10cSrcweir aDFA.meWeight = ToFontWeight (rInfo.m_eWeight); 1188cdf0e10cSrcweir aDFA.meItalic = ToFontItalic (rInfo.m_eItalic); 1189cdf0e10cSrcweir aDFA.meWidthType = ToFontWidth (rInfo.m_eWidth); 1190cdf0e10cSrcweir aDFA.mePitch = ToFontPitch (rInfo.m_ePitch); 1191cdf0e10cSrcweir aDFA.mbSymbolFlag = (rInfo.m_aEncoding == RTL_TEXTENCODING_SYMBOL); 1192cdf0e10cSrcweir 1193cdf0e10cSrcweir switch( rInfo.m_eType ) 1194cdf0e10cSrcweir { 1195cdf0e10cSrcweir case psp::fonttype::Builtin: 1196cdf0e10cSrcweir aDFA.mnQuality = 1024; 1197cdf0e10cSrcweir aDFA.mbDevice = true; 1198cdf0e10cSrcweir aDFA.mbSubsettable = false; 1199cdf0e10cSrcweir aDFA.mbEmbeddable = false; 1200cdf0e10cSrcweir break; 1201cdf0e10cSrcweir case psp::fonttype::TrueType: 1202cdf0e10cSrcweir aDFA.mnQuality = 512; 1203cdf0e10cSrcweir aDFA.mbDevice = false; 1204cdf0e10cSrcweir aDFA.mbSubsettable = true; 1205cdf0e10cSrcweir aDFA.mbEmbeddable = false; 1206cdf0e10cSrcweir break; 1207cdf0e10cSrcweir case psp::fonttype::Type1: 1208cdf0e10cSrcweir aDFA.mnQuality = 0; 1209cdf0e10cSrcweir aDFA.mbDevice = false; 1210cdf0e10cSrcweir aDFA.mbSubsettable = false; 1211cdf0e10cSrcweir aDFA.mbEmbeddable = true; 1212cdf0e10cSrcweir break; 1213cdf0e10cSrcweir default: 1214cdf0e10cSrcweir aDFA.mnQuality = 0; 1215cdf0e10cSrcweir aDFA.mbDevice = false; 1216cdf0e10cSrcweir aDFA.mbSubsettable = false; 1217cdf0e10cSrcweir aDFA.mbEmbeddable = false; 1218cdf0e10cSrcweir break; 1219cdf0e10cSrcweir } 1220cdf0e10cSrcweir 1221cdf0e10cSrcweir aDFA.mbOrientation = true; 1222cdf0e10cSrcweir 1223cdf0e10cSrcweir // add font family name aliases 1224cdf0e10cSrcweir ::std::list< OUString >::const_iterator it = rInfo.m_aAliases.begin(); 1225cdf0e10cSrcweir bool bHasMapNames = false; 1226cdf0e10cSrcweir for(; it != rInfo.m_aAliases.end(); ++it ) 1227cdf0e10cSrcweir { 1228cdf0e10cSrcweir if( bHasMapNames ) 1229cdf0e10cSrcweir aDFA.maMapNames.Append( ';' ); 1230cdf0e10cSrcweir aDFA.maMapNames.Append( (*it).getStr() ); 1231cdf0e10cSrcweir bHasMapNames = true; 1232cdf0e10cSrcweir } 1233cdf0e10cSrcweir 1234cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 2 1235cdf0e10cSrcweir if( bHasMapNames ) 1236cdf0e10cSrcweir { 1237cdf0e10cSrcweir ByteString aOrigName( aDFA.maName, osl_getThreadTextEncoding() ); 1238cdf0e10cSrcweir ByteString aAliasNames( aDFA.maMapNames, osl_getThreadTextEncoding() ); 1239cdf0e10cSrcweir fprintf( stderr, "using alias names \"%s\" for font family \"%s\"\n", 1240cdf0e10cSrcweir aAliasNames.GetBuffer(), aOrigName.GetBuffer() ); 1241cdf0e10cSrcweir } 1242cdf0e10cSrcweir #endif 1243cdf0e10cSrcweir 1244cdf0e10cSrcweir return aDFA; 1245cdf0e10cSrcweir } 1246cdf0e10cSrcweir 1247cdf0e10cSrcweir // ----------------------------------------------------------------------- 1248cdf0e10cSrcweir 1249cdf0e10cSrcweir void PspGraphics::AnnounceFonts( ImplDevFontList* pFontList, const psp::FastPrintFontInfo& aInfo ) 1250cdf0e10cSrcweir { 1251cdf0e10cSrcweir int nQuality = 0; 1252cdf0e10cSrcweir 1253cdf0e10cSrcweir if( aInfo.m_eType == psp::fonttype::TrueType ) 1254cdf0e10cSrcweir { 1255cdf0e10cSrcweir // asian type 1 fonts are not known 1256cdf0e10cSrcweir psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); 1257cdf0e10cSrcweir ByteString aFileName( rMgr.getFontFileSysPath( aInfo.m_nID ) ); 1258cdf0e10cSrcweir int nPos = aFileName.SearchBackward( '_' ); 1259cdf0e10cSrcweir if( nPos == STRING_NOTFOUND || aFileName.GetChar( nPos+1 ) == '.' ) 1260cdf0e10cSrcweir nQuality += 5; 1261cdf0e10cSrcweir else 1262cdf0e10cSrcweir { 1263cdf0e10cSrcweir static const char* pLangBoost = NULL; 1264cdf0e10cSrcweir static bool bOnce = true; 1265cdf0e10cSrcweir if( bOnce ) 1266cdf0e10cSrcweir { 1267cdf0e10cSrcweir bOnce = false; 1268cdf0e10cSrcweir const LanguageType aLang = Application::GetSettings().GetUILanguage(); 1269cdf0e10cSrcweir switch( aLang ) 1270cdf0e10cSrcweir { 1271cdf0e10cSrcweir case LANGUAGE_JAPANESE: 1272cdf0e10cSrcweir pLangBoost = "jan"; 1273cdf0e10cSrcweir break; 1274cdf0e10cSrcweir case LANGUAGE_CHINESE: 1275cdf0e10cSrcweir case LANGUAGE_CHINESE_SIMPLIFIED: 1276cdf0e10cSrcweir case LANGUAGE_CHINESE_SINGAPORE: 1277cdf0e10cSrcweir pLangBoost = "zhs"; 1278cdf0e10cSrcweir break; 1279cdf0e10cSrcweir case LANGUAGE_CHINESE_TRADITIONAL: 1280cdf0e10cSrcweir case LANGUAGE_CHINESE_HONGKONG: 1281cdf0e10cSrcweir case LANGUAGE_CHINESE_MACAU: 1282cdf0e10cSrcweir pLangBoost = "zht"; 1283cdf0e10cSrcweir break; 1284cdf0e10cSrcweir case LANGUAGE_KOREAN: 1285cdf0e10cSrcweir case LANGUAGE_KOREAN_JOHAB: 1286cdf0e10cSrcweir pLangBoost = "kor"; 1287cdf0e10cSrcweir break; 1288cdf0e10cSrcweir } 1289cdf0e10cSrcweir } 1290cdf0e10cSrcweir 1291cdf0e10cSrcweir if( pLangBoost ) 1292cdf0e10cSrcweir if( aFileName.Copy( nPos+1, 3 ).EqualsIgnoreCaseAscii( pLangBoost ) ) 1293cdf0e10cSrcweir nQuality += 10; 1294cdf0e10cSrcweir } 1295cdf0e10cSrcweir } 1296cdf0e10cSrcweir 1297cdf0e10cSrcweir ImplPspFontData* pFD = new ImplPspFontData( aInfo ); 1298cdf0e10cSrcweir pFD->mnQuality += nQuality; 1299cdf0e10cSrcweir pFontList->Add( pFD ); 1300cdf0e10cSrcweir } 1301cdf0e10cSrcweir 1302cdf0e10cSrcweir bool PspGraphics::filterText( const String& rOrig, String& rNewText, xub_StrLen nIndex, xub_StrLen& rLen, xub_StrLen& rCutStart, xub_StrLen& rCutStop ) 1303cdf0e10cSrcweir { 1304cdf0e10cSrcweir if( ! m_pPhoneNr ) 1305cdf0e10cSrcweir return false; 1306cdf0e10cSrcweir 1307cdf0e10cSrcweir rCutStop = rCutStart = STRING_NOTFOUND; 1308cdf0e10cSrcweir 1309cdf0e10cSrcweir #define FAX_PHONE_TOKEN "@@#" 1310cdf0e10cSrcweir #define FAX_PHONE_TOKEN_LENGTH 3 1311cdf0e10cSrcweir #define FAX_END_TOKEN "@@" 1312cdf0e10cSrcweir #define FAX_END_TOKEN_LENGTH 2 1313cdf0e10cSrcweir 1314cdf0e10cSrcweir bool bRet = false; 1315cdf0e10cSrcweir bool bStarted = false; 1316cdf0e10cSrcweir bool bStopped = false; 1317cdf0e10cSrcweir sal_uInt16 nPos; 1318cdf0e10cSrcweir sal_uInt16 nStart = 0; 1319cdf0e10cSrcweir sal_uInt16 nStop = rLen; 1320cdf0e10cSrcweir String aPhone = rOrig.Copy( nIndex, rLen ); 1321cdf0e10cSrcweir 1322cdf0e10cSrcweir if( ! m_bPhoneCollectionActive ) 1323cdf0e10cSrcweir { 1324cdf0e10cSrcweir if( ( nPos = aPhone.SearchAscii( FAX_PHONE_TOKEN ) ) != STRING_NOTFOUND ) 1325cdf0e10cSrcweir { 1326cdf0e10cSrcweir nStart = nPos; 1327cdf0e10cSrcweir m_bPhoneCollectionActive = true; 1328cdf0e10cSrcweir m_aPhoneCollection.Erase(); 1329cdf0e10cSrcweir bRet = true; 1330cdf0e10cSrcweir bStarted = true; 1331cdf0e10cSrcweir } 1332cdf0e10cSrcweir } 1333cdf0e10cSrcweir if( m_bPhoneCollectionActive ) 1334cdf0e10cSrcweir { 1335cdf0e10cSrcweir bRet = true; 1336cdf0e10cSrcweir nPos = bStarted ? nStart + FAX_PHONE_TOKEN_LENGTH : 0; 1337cdf0e10cSrcweir if( ( nPos = aPhone.SearchAscii( FAX_END_TOKEN, nPos ) ) != STRING_NOTFOUND ) 1338cdf0e10cSrcweir { 1339cdf0e10cSrcweir m_bPhoneCollectionActive = false; 1340cdf0e10cSrcweir nStop = nPos + FAX_END_TOKEN_LENGTH; 1341cdf0e10cSrcweir bStopped = true; 1342cdf0e10cSrcweir } 1343cdf0e10cSrcweir int nTokenStart = nStart + (bStarted ? FAX_PHONE_TOKEN_LENGTH : 0); 1344cdf0e10cSrcweir int nTokenStop = nStop - (bStopped ? FAX_END_TOKEN_LENGTH : 0); 1345cdf0e10cSrcweir m_aPhoneCollection += aPhone.Copy( nTokenStart, nTokenStop - nTokenStart ); 1346cdf0e10cSrcweir if( ! m_bPhoneCollectionActive ) 1347cdf0e10cSrcweir { 1348cdf0e10cSrcweir m_pPhoneNr->AppendAscii( "<Fax#>" ); 1349cdf0e10cSrcweir m_pPhoneNr->Append( m_aPhoneCollection ); 1350cdf0e10cSrcweir m_pPhoneNr->AppendAscii( "</Fax#>" ); 1351cdf0e10cSrcweir m_aPhoneCollection.Erase(); 1352cdf0e10cSrcweir } 1353cdf0e10cSrcweir } 1354cdf0e10cSrcweir if( m_aPhoneCollection.Len() > 1024 ) 1355cdf0e10cSrcweir { 1356cdf0e10cSrcweir m_bPhoneCollectionActive = false; 1357cdf0e10cSrcweir m_aPhoneCollection.Erase(); 1358cdf0e10cSrcweir bRet = false; 1359cdf0e10cSrcweir } 1360cdf0e10cSrcweir 1361cdf0e10cSrcweir if( bRet && m_bSwallowFaxNo ) 1362cdf0e10cSrcweir { 1363cdf0e10cSrcweir rLen -= nStop - nStart; 1364cdf0e10cSrcweir rCutStart = nStart+nIndex; 1365cdf0e10cSrcweir rCutStop = nStop+nIndex; 1366cdf0e10cSrcweir if( rCutStart ) 1367cdf0e10cSrcweir rNewText = rOrig.Copy( 0, rCutStart ); 1368cdf0e10cSrcweir rNewText += rOrig.Copy( rCutStop ); 1369cdf0e10cSrcweir } 1370cdf0e10cSrcweir 1371cdf0e10cSrcweir return bRet && m_bSwallowFaxNo; 1372cdf0e10cSrcweir } 1373cdf0e10cSrcweir 1374cdf0e10cSrcweir SystemFontData PspGraphics::GetSysFontData( int nFallbacklevel ) const 1375cdf0e10cSrcweir { 1376cdf0e10cSrcweir SystemFontData aSysFontData; 1377cdf0e10cSrcweir 1378cdf0e10cSrcweir if (nFallbacklevel >= MAX_FALLBACK) nFallbacklevel = MAX_FALLBACK - 1; 1379cdf0e10cSrcweir if (nFallbacklevel < 0 ) nFallbacklevel = 0; 1380cdf0e10cSrcweir 1381cdf0e10cSrcweir aSysFontData.nSize = sizeof( SystemFontData ); 1382cdf0e10cSrcweir aSysFontData.nFontId = 0; 1383cdf0e10cSrcweir aSysFontData.nFontFlags = 0; 1384cdf0e10cSrcweir aSysFontData.bFakeBold = false; 1385cdf0e10cSrcweir aSysFontData.bFakeItalic = false; 1386cdf0e10cSrcweir aSysFontData.bAntialias = true; 1387cdf0e10cSrcweir return aSysFontData; 1388cdf0e10cSrcweir } 1389cdf0e10cSrcweir 1390cdf0e10cSrcweir SystemGraphicsData PspGraphics::GetGraphicsData() const 1391cdf0e10cSrcweir { 1392cdf0e10cSrcweir SystemGraphicsData aRes; 1393cdf0e10cSrcweir aRes.nSize = sizeof(aRes); 1394cdf0e10cSrcweir aRes.hDrawable = 0; 1395cdf0e10cSrcweir aRes.pRenderFormat = 0; 1396cdf0e10cSrcweir return aRes; 1397cdf0e10cSrcweir } 1398cdf0e10cSrcweir 1399