LCOV - code coverage report
Current view: top level - vcl/generic/print - genpspgraphics.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 169 639 26.4 %
Date: 2012-08-25 Functions: 22 104 21.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 89 470 18.9 %

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

Generated by: LCOV version 1.10