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