diff options
25 files changed, 475 insertions, 1504 deletions
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 2b8825624803..40c0cd627810 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -272,7 +272,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/generic/print/glyphset \ vcl/generic/print/printerjob \ vcl/generic/print/psputil \ - vcl/generic/print/pspgraphics \ + vcl/generic/print/genpspgraphics \ vcl/generic/print/genprnpsp \ vcl/generic/print/text_gfx \ vcl/generic/fontmanager/fontsubst \ diff --git a/vcl/Library_vclplug_gtk3.mk b/vcl/Library_vclplug_gtk3.mk index a88e4262112e..72e7a7596754 100644 --- a/vcl/Library_vclplug_gtk3.mk +++ b/vcl/Library_vclplug_gtk3.mk @@ -121,6 +121,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_gtk3,\ vcl/headless/svpelement \ vcl/headless/svpframe \ vcl/headless/svpprn \ + vcl/headless/svppspgraphics \ vcl/headless/svptext \ vcl/headless/svpvd \ )) diff --git a/vcl/generic/fontmanager/fontsubst.cxx b/vcl/generic/fontmanager/fontsubst.cxx index 2ddcb5cb835d..bd6a0930d224 100644 --- a/vcl/generic/fontmanager/fontsubst.cxx +++ b/vcl/generic/fontmanager/fontsubst.cxx @@ -29,7 +29,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" #include "generic/geninst.h" -#include "generic/pspgraphics.h" +#include "generic/genpspgraphics.h" #include "generic/glyphcache.hxx" #include "vcl/sysdata.hxx" diff --git a/vcl/generic/print/genprnpsp.cxx b/vcl/generic/print/genprnpsp.cxx index 06e29a4d74c6..9783652ca4e8 100644 --- a/vcl/generic/print/genprnpsp.cxx +++ b/vcl/generic/print/genprnpsp.cxx @@ -57,7 +57,7 @@ #include "saldatabasic.hxx" #include "generic/genprn.h" #include "generic/geninst.h" -#include "generic/pspgraphics.h" +#include "generic/genpspgraphics.h" #include "jobset.h" #include "print.h" @@ -387,7 +387,7 @@ SalInfoPrinter* SalGenericInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQue { mbPrinterInit = true; // create and initialize SalInfoPrinter - PspSalInfoPrinter* pPrinter = new PspSalInfoPrinter; + PspSalInfoPrinter* pPrinter = new PspSalInfoPrinter(); if( pJobSetup ) { @@ -498,9 +498,8 @@ String SalGenericInstance::GetDefaultPrinter() } PspSalInfoPrinter::PspSalInfoPrinter() + : m_pGraphics( NULL ) { - m_pGraphics = NULL; - m_bPapersInit = false; } PspSalInfoPrinter::~PspSalInfoPrinter() @@ -549,8 +548,8 @@ SalGraphics* PspSalInfoPrinter::GetGraphics() SalGraphics* pRet = NULL; if( ! m_pGraphics ) { - m_pGraphics = new PspGraphics( &m_aJobData, &m_aPrinterGfx, NULL, false, this ); - m_pGraphics->SetLayout( 0 ); + m_pGraphics = GetGenericInstance()->CreatePrintGraphics(); + m_pGraphics->Init( &m_aJobData, &m_aPrinterGfx, NULL, false, this ); pRet = m_pGraphics; } return pRet; @@ -878,7 +877,7 @@ sal_uLong PspSalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, sal /* * SalPrinter */ - PspSalPrinter::PspSalPrinter( SalInfoPrinter* pInfoPrinter ) +PspSalPrinter::PspSalPrinter( SalInfoPrinter* pInfoPrinter ) : m_bFax( false ), m_bPdf( false ), m_bSwallowFaxNo( false ), @@ -1026,8 +1025,9 @@ sal_Bool PspSalPrinter::AbortJob() SalGraphics* PspSalPrinter::StartPage( ImplJobSetup* pJobSetup, sal_Bool ) { JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, m_aJobData ); - m_pGraphics = new PspGraphics( &m_aJobData, &m_aPrinterGfx, m_bFax ? &m_aFaxNr : NULL, m_bSwallowFaxNo, m_pInfoPrinter ); - m_pGraphics->SetLayout( 0 ); + m_pGraphics = GetGenericInstance()->CreatePrintGraphics(); + m_pGraphics->Init( &m_aJobData, &m_aPrinterGfx, m_bFax ? &m_aFaxNr : NULL, + m_bSwallowFaxNo, m_pInfoPrinter ); if( m_nCopies > 1 ) { // in case user did not do anything (m_nCopies=1) diff --git a/vcl/generic/print/pspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx index 7e11aeea616d..b9b82a08763e 100644 --- a/vcl/generic/print/pspgraphics.cxx +++ b/vcl/generic/print/genpspgraphics.cxx @@ -29,15 +29,18 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> -#include <sys/mman.h> -#include <sys/stat.h> -#include <sys/types.h> +// for mmap etc. +#if defined( UNX ) +# include <stdlib.h> +# include <unistd.h> +# include <fcntl.h> +# include <sys/mman.h> +# include <sys/stat.h> +# include <sys/types.h> +#endif #include "generic/geninst.h" -#include "generic/pspgraphics.h" +#include "generic/genpspgraphics.h" #include "generic/glyphcache.hxx" #include "vcl/jobdata.hxx" @@ -68,7 +71,7 @@ using ::rtl::OString; class SalPrinterBmp : public psp::PrinterBmp { - private: +private: BitmapBuffer* mpBmpBuffer; FncGetPixel mpFncGetPixel; @@ -266,15 +269,40 @@ SalPrinterBmp::GetPixelIdx (sal_uInt32 nRow, sal_uInt32 nColumn) const } /******************************************************* - * PspGraphics * + * GenPspGraphics * *******************************************************/ -PspGraphics::~PspGraphics() +GenPspGraphics::GenPspGraphics() + : m_pJobData( NULL ), + m_pPrinterGfx( NULL ), + m_pPhoneNr( NULL ), + m_bSwallowFaxNo( false ), + m_bPhoneCollectionActive( false ), + m_bFontVertical( false ), + m_pInfoPrinter( NULL ) +{ + for( int i = 0; i < MAX_FALLBACK; i++ ) + m_pServerFont[i] = NULL; +} + +void GenPspGraphics::Init( psp::JobData* pJob, psp::PrinterGfx* pGfx, + String* pPhone, bool bSwallow, + SalInfoPrinter* pInfoPrinter ) +{ + m_pJobData = pJob; + m_pPrinterGfx = pGfx; + m_pPhoneNr = pPhone; + m_bSwallowFaxNo = bSwallow; + m_pInfoPrinter = pInfoPrinter; + SetLayout( 0 ); +} + +GenPspGraphics::~GenPspGraphics() { ReleaseFonts(); } -void PspGraphics::GetResolution( sal_Int32 &rDPIX, sal_Int32 &rDPIY ) +void GenPspGraphics::GetResolution( sal_Int32 &rDPIX, sal_Int32 &rDPIY ) { if (m_pJobData != NULL) { @@ -285,22 +313,22 @@ void PspGraphics::GetResolution( sal_Int32 &rDPIX, sal_Int32 &rDPIY ) } } -sal_uInt16 PspGraphics::GetBitCount() const +sal_uInt16 GenPspGraphics::GetBitCount() const { return m_pPrinterGfx->GetBitCount(); } -long PspGraphics::GetGraphicsWidth() const +long GenPspGraphics::GetGraphicsWidth() const { return 0; } -void PspGraphics::ResetClipRegion() +void GenPspGraphics::ResetClipRegion() { m_pPrinterGfx->ResetClipRegion(); } -bool PspGraphics::setClipRegion( const Region& i_rClip ) +bool GenPspGraphics::setClipRegion( const Region& i_rClip ) { // TODO: support polygonal clipregions here m_pPrinterGfx->BeginSetClipRegion( i_rClip.GetRectCount() ); @@ -320,12 +348,12 @@ bool PspGraphics::setClipRegion( const Region& i_rClip ) return true; } -void PspGraphics::SetLineColor() +void GenPspGraphics::SetLineColor() { m_pPrinterGfx->SetLineColor (); } -void PspGraphics::SetLineColor( SalColor nSalColor ) +void GenPspGraphics::SetLineColor( SalColor nSalColor ) { psp::PrinterColor aColor (SALCOLOR_RED (nSalColor), SALCOLOR_GREEN (nSalColor), @@ -333,12 +361,12 @@ void PspGraphics::SetLineColor( SalColor nSalColor ) m_pPrinterGfx->SetLineColor (aColor); } -void PspGraphics::SetFillColor() +void GenPspGraphics::SetFillColor() { m_pPrinterGfx->SetFillColor (); } -void PspGraphics::SetFillColor( SalColor nSalColor ) +void GenPspGraphics::SetFillColor( SalColor nSalColor ) { psp::PrinterColor aColor (SALCOLOR_RED (nSalColor), SALCOLOR_GREEN (nSalColor), @@ -346,28 +374,28 @@ void PspGraphics::SetFillColor( SalColor nSalColor ) m_pPrinterGfx->SetFillColor (aColor); } -void PspGraphics::SetROPLineColor( SalROPColor ) +void GenPspGraphics::SetROPLineColor( SalROPColor ) { DBG_ASSERT( 0, "Error: PrinterGfx::SetROPLineColor() not implemented" ); } -void PspGraphics::SetROPFillColor( SalROPColor ) +void GenPspGraphics::SetROPFillColor( SalROPColor ) { DBG_ASSERT( 0, "Error: PrinterGfx::SetROPFillColor() not implemented" ); } -void PspGraphics::SetXORMode( bool bSet, bool ) +void GenPspGraphics::SetXORMode( bool bSet, bool ) { (void)bSet; DBG_ASSERT( !bSet, "Error: PrinterGfx::SetXORMode() not implemented" ); } -void PspGraphics::drawPixel( long nX, long nY ) +void GenPspGraphics::drawPixel( long nX, long nY ) { m_pPrinterGfx->DrawPixel (Point(nX, nY)); } -void PspGraphics::drawPixel( long nX, long nY, SalColor nSalColor ) +void GenPspGraphics::drawPixel( long nX, long nY, SalColor nSalColor ) { psp::PrinterColor aColor (SALCOLOR_RED (nSalColor), SALCOLOR_GREEN (nSalColor), @@ -375,59 +403,59 @@ void PspGraphics::drawPixel( long nX, long nY, SalColor nSalColor ) m_pPrinterGfx->DrawPixel (Point(nX, nY), aColor); } -void PspGraphics::drawLine( long nX1, long nY1, long nX2, long nY2 ) +void GenPspGraphics::drawLine( long nX1, long nY1, long nX2, long nY2 ) { m_pPrinterGfx->DrawLine (Point(nX1, nY1), Point(nX2, nY2)); } -void PspGraphics::drawRect( long nX, long nY, long nDX, long nDY ) +void GenPspGraphics::drawRect( long nX, long nY, long nDX, long nDY ) { m_pPrinterGfx->DrawRect (Rectangle(Point(nX, nY), Size(nDX, nDY))); } -void PspGraphics::drawPolyLine( sal_uLong nPoints, const SalPoint *pPtAry ) +void GenPspGraphics::drawPolyLine( sal_uLong nPoints, const SalPoint *pPtAry ) { m_pPrinterGfx->DrawPolyLine (nPoints, (Point*)pPtAry); } -void PspGraphics::drawPolygon( sal_uLong nPoints, const SalPoint* pPtAry ) +void GenPspGraphics::drawPolygon( sal_uLong nPoints, const SalPoint* pPtAry ) { // Point must be equal to SalPoint! see vcl/inc/salgtype.hxx m_pPrinterGfx->DrawPolygon (nPoints, (Point*)pPtAry); } -void PspGraphics::drawPolyPolygon( sal_uInt32 nPoly, +void GenPspGraphics::drawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32 *pPoints, PCONSTSALPOINT *pPtAry ) { m_pPrinterGfx->DrawPolyPolygon (nPoly, pPoints, (const Point**)pPtAry); } -bool PspGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double /*fTransparency*/ ) +bool GenPspGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double /*fTransparency*/ ) { // TODO: implement and advertise OutDevSupport_B2DDraw support return false; } -bool PspGraphics::drawPolyLine( const basegfx::B2DPolygon&, double /*fTranspareny*/, const basegfx::B2DVector& /*rLineWidths*/, basegfx::B2DLineJoin /*eJoin*/) +bool GenPspGraphics::drawPolyLine( const basegfx::B2DPolygon&, double /*fTranspareny*/, const basegfx::B2DVector& /*rLineWidths*/, basegfx::B2DLineJoin /*eJoin*/) { // TODO: a PS printer can draw B2DPolyLines almost directly return false; } -sal_Bool PspGraphics::drawPolyLineBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry ) +sal_Bool GenPspGraphics::drawPolyLineBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry ) { m_pPrinterGfx->DrawPolyLineBezier (nPoints, (Point*)pPtAry, pFlgAry); return sal_True; } -sal_Bool PspGraphics::drawPolygonBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry ) +sal_Bool GenPspGraphics::drawPolygonBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry ) { m_pPrinterGfx->DrawPolygonBezier (nPoints, (Point*)pPtAry, pFlgAry); return sal_True; } -sal_Bool PspGraphics::drawPolyPolygonBezier( sal_uInt32 nPoly, +sal_Bool GenPspGraphics::drawPolyPolygonBezier( sal_uInt32 nPoly, const sal_uInt32* pPoints, const SalPoint* const* pPtAry, const sal_uInt8* const* pFlgAry ) @@ -437,29 +465,29 @@ sal_Bool PspGraphics::drawPolyPolygonBezier( sal_uInt32 nPoly, return sal_True; } -void PspGraphics::invert( sal_uLong, +void GenPspGraphics::invert( sal_uLong, const SalPoint*, SalInvert ) { DBG_ASSERT( 0, "Error: PrinterGfx::Invert() not implemented" ); } -sal_Bool PspGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize ) +sal_Bool GenPspGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize ) { return m_pPrinterGfx->DrawEPS( Rectangle( Point( nX, nY ), Size( nWidth, nHeight ) ), pPtr, nSize ); } -void PspGraphics::copyBits( const SalTwoRect*, +void GenPspGraphics::copyBits( const SalTwoRect*, SalGraphics* ) { OSL_FAIL( "Error: PrinterGfx::CopyBits() not implemented" ); } -void PspGraphics::copyArea ( long,long,long,long,long,long,sal_uInt16 ) +void GenPspGraphics::copyArea ( long,long,long,long,long,long,sal_uInt16 ) { OSL_FAIL( "Error: PrinterGfx::CopyArea() not implemented" ); } -void PspGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap ) +void GenPspGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap ) { Rectangle aSrc (Point(pPosAry->mnSrcX, pPosAry->mnSrcY), Size(pPosAry->mnSrcWidth, pPosAry->mnSrcHeight)); @@ -474,40 +502,40 @@ void PspGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBi const_cast<SalBitmap&>(rSalBitmap).ReleaseBuffer (pBuffer, sal_True); } -void PspGraphics::drawBitmap( const SalTwoRect*, +void GenPspGraphics::drawBitmap( const SalTwoRect*, const SalBitmap&, const SalBitmap& ) { OSL_FAIL("Error: no PrinterGfx::DrawBitmap() for transparent bitmap"); } -void PspGraphics::drawBitmap( const SalTwoRect*, +void GenPspGraphics::drawBitmap( const SalTwoRect*, const SalBitmap&, SalColor ) { OSL_FAIL("Error: no PrinterGfx::DrawBitmap() for transparent color"); } -void PspGraphics::drawMask( const SalTwoRect*, +void GenPspGraphics::drawMask( const SalTwoRect*, const SalBitmap &, SalColor ) { OSL_FAIL("Error: PrinterGfx::DrawMask() not implemented"); } -SalBitmap* PspGraphics::getBitmap( long, long, long, long ) +SalBitmap* GenPspGraphics::getBitmap( long, long, long, long ) { DBG_WARNING ("Warning: PrinterGfx::GetBitmap() not implemented"); return NULL; } -SalColor PspGraphics::getPixel( long, long ) +SalColor GenPspGraphics::getPixel( long, long ) { OSL_FAIL("Warning: PrinterGfx::GetPixel() not implemented"); return 0; } -void PspGraphics::invert(long,long,long,long,SalInvert) +void GenPspGraphics::invert(long,long,long,long,SalInvert) { OSL_FAIL("Warning: PrinterGfx::Invert() not implemented"); } @@ -531,7 +559,7 @@ public: //-------------------------------------------------------------------------- ImplPspFontData::ImplPspFontData( const psp::FastPrintFontInfo& rInfo ) -: ImplFontData( PspGraphics::Info2DevFontAttributes(rInfo), PSPFD_MAGIC ), +: ImplFontData( GenPspGraphics::Info2DevFontAttributes(rInfo), PSPFD_MAGIC ), mnFontId( rInfo.m_nID ) {} @@ -767,13 +795,13 @@ void PspFontLayout::DrawText( SalGraphics& ) const DrawPrinterLayout( *this, mrPrinterGfx, false ); } -void PspGraphics::DrawServerFontLayout( const ServerFontLayout& rLayout ) +void GenPspGraphics::DrawServerFontLayout( const ServerFontLayout& rLayout ) { // print complex text DrawPrinterLayout( rLayout, *m_pPrinterGfx, true ); } -const ImplFontCharMap* PspGraphics::GetImplFontCharMap() const +const ImplFontCharMap* GenPspGraphics::GetImplFontCharMap() const { if( !m_pServerFont[0] ) return NULL; @@ -782,14 +810,14 @@ const ImplFontCharMap* PspGraphics::GetImplFontCharMap() const return pIFCMap; } -bool PspGraphics::GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const +bool GenPspGraphics::GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const { if (!m_pServerFont[0]) return false; return m_pServerFont[0]->GetFontCapabilities(rFontCapabilities); } -sal_uInt16 PspGraphics::SetFont( ImplFontSelectData *pEntry, int nFallbackLevel ) +sal_uInt16 GenPspGraphics::SetFont( ImplFontSelectData *pEntry, int nFallbackLevel ) { // release all fonts that are to be overridden for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i ) @@ -850,7 +878,7 @@ sal_uInt16 PspGraphics::SetFont( ImplFontSelectData *pEntry, int nFallbackLevel ); } -void PspGraphics::SetTextColor( SalColor nSalColor ) +void GenPspGraphics::SetTextColor( SalColor nSalColor ) { psp::PrinterColor aColor (SALCOLOR_RED (nSalColor), SALCOLOR_GREEN (nSalColor), @@ -858,12 +886,12 @@ void PspGraphics::SetTextColor( SalColor nSalColor ) m_pPrinterGfx->SetTextColor (aColor); } -bool PspGraphics::AddTempDevFont( ImplDevFontList*, const String&,const String& ) +bool GenPspGraphics::AddTempDevFont( ImplDevFontList*, const String&,const String& ) { return false; } -void PspGraphics::GetDevFontList( ImplDevFontList *pList ) +void GenPspGraphics::GetDevFontList( ImplDevFontList *pList ) { ::std::list< psp::fontID > aList; psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); @@ -880,7 +908,7 @@ void PspGraphics::GetDevFontList( ImplDevFontList *pList ) SalGenericInstance::RegisterFontSubstitutors( pList ); } -void PspGraphics::GetDevFontSubstList( OutputDevice* pOutDev ) +void GenPspGraphics::GetDevFontSubstList( OutputDevice* pOutDev ) { const psp::PrinterInfo& rInfo = psp::PrinterInfoManager::get().getPrinterInfo( m_pJobData->m_aPrinterName ); if( rInfo.m_bPerformFontSubstitution ) @@ -890,7 +918,7 @@ void PspGraphics::GetDevFontSubstList( OutputDevice* pOutDev ) } } -void PspGraphics::GetFontMetric( ImplFontMetricData *pMetric, int ) +void GenPspGraphics::GetFontMetric( ImplFontMetricData *pMetric, int ) { const psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); psp::PrintFontInfo aInfo; @@ -918,7 +946,7 @@ void PspGraphics::GetFontMetric( ImplFontMetricData *pMetric, int ) } } -sal_uLong PspGraphics::GetKernPairs( sal_uLong nPairs, ImplKernPairData *pKernPairs ) +sal_uLong GenPspGraphics::GetKernPairs( sal_uLong nPairs, ImplKernPairData *pKernPairs ) { const ::std::list< ::psp::KernPair >& rPairs( m_pPrinterGfx->getKernPairs() ); sal_uLong nHavePairs = rPairs.size(); @@ -940,7 +968,7 @@ sal_uLong PspGraphics::GetKernPairs( sal_uLong nPairs, ImplKernPairData *pKernPa return nHavePairs; } -sal_Bool PspGraphics::GetGlyphBoundRect( sal_GlyphId nGlyphIndex, Rectangle& rRect ) +sal_Bool GenPspGraphics::GetGlyphBoundRect( sal_GlyphId nGlyphIndex, Rectangle& rRect ) { int nLevel = nGlyphIndex >> GF_FONTSHIFT; if( nLevel >= MAX_FALLBACK ) @@ -956,7 +984,7 @@ sal_Bool PspGraphics::GetGlyphBoundRect( sal_GlyphId nGlyphIndex, Rectangle& rRe return sal_True; } -sal_Bool PspGraphics::GetGlyphOutline( sal_GlyphId nGlyphIndex, +sal_Bool GenPspGraphics::GetGlyphOutline( sal_GlyphId nGlyphIndex, ::basegfx::B2DPolyPolygon& rB2DPolyPoly ) { int nLevel = nGlyphIndex >> GF_FONTSHIFT; @@ -974,7 +1002,7 @@ sal_Bool PspGraphics::GetGlyphOutline( sal_GlyphId nGlyphIndex, return sal_False; } -SalLayout* PspGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel ) +SalLayout* GenPspGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel ) { // workaround for printers not handling glyph indexing for non-TT fonts int nFontId = m_pPrinterGfx->GetFontID(); @@ -1006,7 +1034,7 @@ SalLayout* PspGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel //-------------------------------------------------------------------------- -sal_Bool PspGraphics::CreateFontSubset( +sal_Bool GenPspGraphics::CreateFontSubset( const rtl::OUString& rToFile, const ImplFontData* pFont, sal_Int32* pGlyphIDs, @@ -1036,7 +1064,7 @@ sal_Bool PspGraphics::CreateFontSubset( //-------------------------------------------------------------------------- -const void* PspGraphics::GetEmbedFontData( const ImplFontData* pFont, const sal_Ucs* pUnicodes, sal_Int32* pWidths, FontSubsetInfo& rInfo, long* pDataLen ) +const Ucs2SIntMap* GenPspGraphics::GetFontEncodingVector( const ImplFontData* pFont, const Ucs2OStrMap** pNonEncoded ) { // in this context the pFont->GetFontId() is a valid PSP // font since they are the only ones left after the PDF @@ -1044,32 +1072,12 @@ const void* PspGraphics::GetEmbedFontData( const ImplFontData* pFont, const sal_ // which this method was created). The correct way would // be to have the GlyphCache search for the ImplFontData pFont psp::fontID aFont = pFont->GetFontId(); - return PspGraphics::DoGetEmbedFontData( aFont, pUnicodes, pWidths, rInfo, pDataLen ); + return GenPspGraphics::DoGetFontEncodingVector( aFont, pNonEncoded ); } //-------------------------------------------------------------------------- -void PspGraphics::FreeEmbedFontData( const void* pData, long nLen ) -{ - PspGraphics::DoFreeEmbedFontData( pData, nLen ); -} - -//-------------------------------------------------------------------------- - -const Ucs2SIntMap* PspGraphics::GetFontEncodingVector( const ImplFontData* pFont, const Ucs2OStrMap** pNonEncoded ) -{ - // in this context the pFont->GetFontId() is a valid PSP - // font since they are the only ones left after the PDF - // export has filtered its list of subsettable fonts (for - // which this method was created). The correct way would - // be to have the GlyphCache search for the ImplFontData pFont - psp::fontID aFont = pFont->GetFontId(); - return PspGraphics::DoGetFontEncodingVector( aFont, pNonEncoded ); -} - -//-------------------------------------------------------------------------- - -void PspGraphics::GetGlyphWidths( const ImplFontData* pFont, +void GenPspGraphics::GetGlyphWidths( const ImplFontData* pFont, bool bVertical, Int32Vector& rWidths, Ucs2UIntMap& rUnicodeEnc ) @@ -1080,83 +1088,10 @@ void PspGraphics::GetGlyphWidths( const ImplFontData* pFont, // which this method was created). The correct way would // be to have the GlyphCache search for the ImplFontData pFont psp::fontID aFont = pFont->GetFontId(); - PspGraphics::DoGetGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc ); -} - - -// static helpers of PspGraphics - -const void* PspGraphics::DoGetEmbedFontData( fontID aFont, const sal_Ucs* pUnicodes, sal_Int32* pWidths, FontSubsetInfo& rInfo, long* pDataLen ) -{ - psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); - - psp::PrintFontInfo aFontInfo; - if( ! rMgr.getFontInfo( aFont, aFontInfo ) ) - return NULL; - - // fill in font info - rInfo.m_nAscent = aFontInfo.m_nAscend; - rInfo.m_nDescent = aFontInfo.m_nDescend; - rInfo.m_aPSName = rMgr.getPSName( aFont ); - - int xMin, yMin, xMax, yMax; - rMgr.getFontBoundingBox( aFont, xMin, yMin, xMax, yMax ); - - psp::CharacterMetric aMetrics[256]; - sal_Ucs aUnicodes[256]; - if( aFontInfo.m_aEncoding == RTL_TEXTENCODING_SYMBOL && aFontInfo.m_eType == psp::fonttype::Type1 ) - { - for( int i = 0; i < 256; i++ ) - aUnicodes[i] = pUnicodes[i] < 0x0100 ? pUnicodes[i] + 0xf000 : pUnicodes[i]; - pUnicodes = aUnicodes; - } - if( ! rMgr.getMetrics( aFont, pUnicodes, 256, aMetrics ) ) - return NULL; - - OString aSysPath = rMgr.getFontFileSysPath( aFont ); - struct stat aStat; - if( stat( aSysPath.getStr(), &aStat ) ) - return NULL; - int fd = open( aSysPath.getStr(), O_RDONLY ); - if( fd < 0 ) - return NULL; - void* pFile = mmap( NULL, aStat.st_size, PROT_READ, MAP_SHARED, fd, 0 ); - close( fd ); - if( pFile == MAP_FAILED ) - return NULL; - - *pDataLen = aStat.st_size; - - rInfo.m_aFontBBox = Rectangle( Point( xMin, yMin ), Size( xMax-xMin, yMax-yMin ) ); - rInfo.m_nCapHeight = yMax; // Well ... - - for( int i = 0; i < 256; i++ ) - pWidths[i] = (aMetrics[i].width > 0 ? aMetrics[i].width : 0); - - switch( aFontInfo.m_eType ) - { - case psp::fonttype::TrueType: - rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF; - break; - case psp::fonttype::Type1: { - const bool bPFA = ((*(unsigned char*)pFile) < 0x80); - rInfo.m_nFontType = bPFA ? FontSubsetInfo::TYPE1_PFA : FontSubsetInfo::TYPE1_PFB; - } - break; - default: - return NULL; - } - - return pFile; -} - -void PspGraphics::DoFreeEmbedFontData( const void* pData, long nLen ) -{ - if( pData ) - munmap( (char*)pData, nLen ); + GenPspGraphics::DoGetGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc ); } -const Ucs2SIntMap* PspGraphics::DoGetFontEncodingVector( fontID aFont, const Ucs2OStrMap** pNonEncoded ) +const Ucs2SIntMap* GenPspGraphics::DoGetFontEncodingVector( fontID aFont, const Ucs2OStrMap** pNonEncoded ) { psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); @@ -1171,7 +1106,7 @@ const Ucs2SIntMap* PspGraphics::DoGetFontEncodingVector( fontID aFont, const Ucs return rMgr.getEncodingMap( aFont, pNonEncoded ); } -void PspGraphics::DoGetGlyphWidths( psp::fontID aFont, +void GenPspGraphics::DoGetGlyphWidths( psp::fontID aFont, bool bVertical, Int32Vector& rWidths, Ucs2UIntMap& rUnicodeEnc ) @@ -1181,7 +1116,7 @@ void PspGraphics::DoGetGlyphWidths( psp::fontID aFont, } // ---------------------------------------------------------------------------- -ImplDevFontAttributes PspGraphics::Info2DevFontAttributes( const psp::FastPrintFontInfo& rInfo ) +ImplDevFontAttributes GenPspGraphics::Info2DevFontAttributes( const psp::FastPrintFontInfo& rInfo ) { ImplDevFontAttributes aDFA; aDFA.maName = rInfo.m_aFamilyName; @@ -1243,7 +1178,7 @@ ImplDevFontAttributes PspGraphics::Info2DevFontAttributes( const psp::FastPrintF // ----------------------------------------------------------------------- -void PspGraphics::AnnounceFonts( ImplDevFontList* pFontList, const psp::FastPrintFontInfo& aInfo ) +void GenPspGraphics::AnnounceFonts( ImplDevFontList* pFontList, const psp::FastPrintFontInfo& aInfo ) { int nQuality = 0; @@ -1296,7 +1231,7 @@ void PspGraphics::AnnounceFonts( ImplDevFontList* pFontList, const psp::FastPrin pFontList->Add( pFD ); } -bool PspGraphics::filterText( const String& rOrig, String& rNewText, xub_StrLen nIndex, xub_StrLen& rLen, xub_StrLen& rCutStart, xub_StrLen& rCutStop ) +bool GenPspGraphics::filterText( const String& rOrig, String& rNewText, xub_StrLen nIndex, xub_StrLen& rLen, xub_StrLen& rCutStart, xub_StrLen& rCutStop ) { if( ! m_pPhoneNr ) return false; @@ -1368,19 +1303,19 @@ bool PspGraphics::filterText( const String& rOrig, String& rNewText, xub_StrLen return bRet && m_bSwallowFaxNo; } -bool PspGraphics::drawAlphaBitmap( const SalTwoRect&, +bool GenPspGraphics::drawAlphaBitmap( const SalTwoRect&, const SalBitmap&, const SalBitmap& ) { return false; } -bool PspGraphics::drawAlphaRect( long, long, long, long, sal_uInt8 ) +bool GenPspGraphics::drawAlphaRect( long, long, long, long, sal_uInt8 ) { return false; } -SystemGraphicsData PspGraphics::GetGraphicsData() const +SystemGraphicsData GenPspGraphics::GetGraphicsData() const { SystemGraphicsData aRes; aRes.nSize = sizeof(aRes); @@ -1389,7 +1324,7 @@ SystemGraphicsData PspGraphics::GetGraphicsData() const return aRes; } -SystemFontData PspGraphics::GetSysFontData( int nFallbacklevel ) const +SystemFontData GenPspGraphics::GetSysFontData( int nFallbacklevel ) const { SystemFontData aSysFontData; @@ -1405,9 +1340,116 @@ SystemFontData PspGraphics::GetSysFontData( int nFallbacklevel ) const return aSysFontData; } -bool PspGraphics::supportsOperation( OutDevSupportType ) const +bool GenPspGraphics::supportsOperation( OutDevSupportType ) const { return false; } +void GenPspGraphics::DoFreeEmbedFontData( const void* pData, long nLen ) +{ +#if defined( UNX ) + if( pData ) + munmap( (char*)pData, nLen ); +#else + rtl_freeMemory( pData ); +#endif +} + +const void* GenPspGraphics::DoGetEmbedFontData( psp::fontID aFont, const sal_Ucs* pUnicodes, sal_Int32* pWidths, FontSubsetInfo& rInfo, long* pDataLen ) +{ + + psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); + + psp::PrintFontInfo aFontInfo; + if( ! rMgr.getFontInfo( aFont, aFontInfo ) ) + return NULL; + + // fill in font info + rInfo.m_nAscent = aFontInfo.m_nAscend; + rInfo.m_nDescent = aFontInfo.m_nDescend; + rInfo.m_aPSName = rMgr.getPSName( aFont ); + + int xMin, yMin, xMax, yMax; + rMgr.getFontBoundingBox( aFont, xMin, yMin, xMax, yMax ); + + psp::CharacterMetric aMetrics[256]; + sal_Ucs aUnicodes[256]; + if( aFontInfo.m_aEncoding == RTL_TEXTENCODING_SYMBOL && aFontInfo.m_eType == psp::fonttype::Type1 ) + { + for( int i = 0; i < 256; i++ ) + aUnicodes[i] = pUnicodes[i] < 0x0100 ? pUnicodes[i] + 0xf000 : pUnicodes[i]; + pUnicodes = aUnicodes; + } + if( ! rMgr.getMetrics( aFont, pUnicodes, 256, aMetrics ) ) + return NULL; + + OString aSysPath = rMgr.getFontFileSysPath( aFont ); + +#if defined( UNX ) + struct stat aStat; + if( stat( aSysPath.getStr(), &aStat ) ) + return NULL; + int fd = open( aSysPath.getStr(), O_RDONLY ); + if( fd < 0 ) + return NULL; + void* pFile = mmap( NULL, aStat.st_size, PROT_READ, MAP_SHARED, fd, 0 ); + close( fd ); + if( pFile == MAP_FAILED ) + return NULL; + *pDataLen = aStat.st_size; +#else + // FIXME: test me ! ... + rtl::OUString aURL; + if( !getFileURLFromSystemPath( rtl::OStringToOUString( aSysPath, osl_getThreadTextEncoding(), aURL ) ) ) + return NULL; + osl::File aFile( aURL ); + if( aFile.open( osl_File_OpenFlag_Read | osl_File_OpenFlag_NoLock ) != osl_File_E_None ) + return NULL; + + pFile = rtl_allocMemory( aFile.getFileSize() ); + sal_uInt64 nRead = 0; + aFile.read( pFile, aFile.getFileSize(), nRead ); + *pDataLen = (long) nRead; +#endif + + rInfo.m_aFontBBox = Rectangle( Point( xMin, yMin ), Size( xMax-xMin, yMax-yMin ) ); + rInfo.m_nCapHeight = yMax; // Well ... + + for( int i = 0; i < 256; i++ ) + pWidths[i] = (aMetrics[i].width > 0 ? aMetrics[i].width : 0); + + switch( aFontInfo.m_eType ) + { + case psp::fonttype::TrueType: + rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF; + break; + case psp::fonttype::Type1: { + const bool bPFA = ((*(unsigned char*)pFile) < 0x80); + rInfo.m_nFontType = bPFA ? FontSubsetInfo::TYPE1_PFA : FontSubsetInfo::TYPE1_PFB; + } + break; + default: + DoFreeEmbedFontData( pFile, *pDataLen ); + return NULL; + } + + return pFile; +} + +void GenPspGraphics::FreeEmbedFontData( const void* pData, long nLen ) +{ + DoFreeEmbedFontData( pData, nLen ); +} + +const void* GenPspGraphics::GetEmbedFontData( const ImplFontData* pFont, const sal_Ucs* pUnicodes, sal_Int32* pWidths, FontSubsetInfo& rInfo, long* pDataLen ) +{ + // in this context the pFont->GetFontId() is a valid PSP + // font since they are the only ones left after the PDF + // export has filtered its list of subsettable fonts (for + // which this method was created). The correct way would + // be to have the GlyphCache search for the ImplFontData pFont + psp::fontID aFont = pFont->GetFontId(); + return DoGetEmbedFontData( aFont, pUnicodes, pWidths, rInfo, pDataLen ); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/svpprn.cxx b/vcl/headless/svpprn.cxx index ded175afea94..ff779f2662d1 100644 --- a/vcl/headless/svpprn.cxx +++ b/vcl/headless/svpprn.cxx @@ -173,13 +173,11 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData ) * SalInstance */ -// ----------------------------------------------------------------------- - SalInfoPrinter* SvpSalInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueInfo, ImplJobSetup* pJobSetup ) { // create and initialize SalInfoPrinter - SvpSalInfoPrinter* pPrinter = new SvpSalInfoPrinter; + SvpSalInfoPrinter* pPrinter = new SvpSalInfoPrinter(); if( pJobSetup ) { @@ -212,15 +210,11 @@ SalInfoPrinter* SvpSalInstance::CreateInfoPrinter( SalPrinterQueueInfo* pQueueIn return pPrinter; } -// ----------------------------------------------------------------------- - void SvpSalInstance::DestroyInfoPrinter( SalInfoPrinter* pPrinter ) { delete pPrinter; } -// ----------------------------------------------------------------------- - SalPrinter* SvpSalInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter ) { // create and initialize SalPrinter @@ -230,15 +224,11 @@ SalPrinter* SvpSalInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter ) return pPrinter; } -// ----------------------------------------------------------------------- - void SvpSalInstance::DestroyPrinter( SalPrinter* pPrinter ) { delete pPrinter; } -// ----------------------------------------------------------------------- - void SvpSalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList ) { PrinterInfoManager& rManager( PrinterInfoManager::get() ); @@ -277,29 +267,21 @@ void SvpSalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList ) } } -// ----------------------------------------------------------------------- - void SvpSalInstance::DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo ) { delete pInfo; } -// ----------------------------------------------------------------------- - void SvpSalInstance::GetPrinterQueueState( SalPrinterQueueInfo* ) { } -// ----------------------------------------------------------------------- - String SvpSalInstance::GetDefaultPrinter() { PrinterInfoManager& rManager( PrinterInfoManager::get() ); return rManager.getDefaultPrinter(); } -// ----------------------------------------------------------------------- - void SvpSalInstance::PostPrintersChanged() { const std::list< SalFrame* >& rList = SvpSalInstance::s_pDefaultInstance->getFrames(); @@ -308,11 +290,19 @@ void SvpSalInstance::PostPrintersChanged() SvpSalInstance::s_pDefaultInstance->PostEvent( *it, NULL, SALEVENT_PRINTERCHANGED ); } -// ----------------------------------------------------------------------- +GenPspGraphics *SvpSalInstance::CreatePrintGraphics() +{ + return new SvpPspGraphics(); +} sal_Bool SvpSalInfoPrinter::Setup( SalFrame*, ImplJobSetup* ) { return sal_False; } +SvpSalPrinter::SvpSalPrinter( SalInfoPrinter* pInfoPrinter ) + : PspSalPrinter( pInfoPrinter ) +{ +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/svppspgraphics.cxx b/vcl/headless/svppspgraphics.cxx index 5a792538948b..9728d997fe22 100644 --- a/vcl/headless/svppspgraphics.cxx +++ b/vcl/headless/svppspgraphics.cxx @@ -63,6 +63,10 @@ using namespace basebmp; using namespace basegfx; using ::rtl::OUString; using ::rtl::OString; + +#warning FIXME: this is presumed un-necessary the generic/ BitmapBuffer code should work just as well - surely + +#ifdef USE_SVP_BITMAP // ----- Implementation of PrinterBmp by means of SalBitmap/BitmapBuffer --------------- class SalPrinterBmp : public psp::PrinterBmp @@ -172,219 +176,7 @@ SalPrinterBmp::GetPixelIdx (sal_uInt32 nRow, sal_uInt32 nColumn) const return nIdx; } -/******************************************************* - * PspGraphics * - *******************************************************/ - -bool PspGraphics::drawAlphaBitmap( const SalTwoRect&, const SalBitmap& /*rSourceBitmap*/, const SalBitmap& /*rAlphaBitmap*/ ) -{ - return false; -} - -bool PspGraphics::drawAlphaRect( long /*nX*/, long /*nY*/, long /*nWidth*/, long /*nHeight*/, sal_uInt8 /*nTransparency*/ ) -{ - return false; -} - -bool PspGraphics::supportsOperation( OutDevSupportType ) const -{ - return false; -} - -PspGraphics::~PspGraphics() -{ - ReleaseFonts(); -} - -void PspGraphics::GetResolution( sal_Int32 &rDPIX, sal_Int32 &rDPIY ) -{ - if (m_pJobData != NULL) - { - int x = m_pJobData->m_aContext.getRenderResolution(); - - rDPIX = x; - rDPIY = x; - } -} - -sal_uInt16 PspGraphics::GetBitCount() const -{ - return m_pPrinterGfx->GetBitCount(); -} - -long PspGraphics::GetGraphicsWidth() const -{ - return 0; -} - -void PspGraphics::ResetClipRegion() -{ - m_pPrinterGfx->ResetClipRegion(); -} - -bool PspGraphics::setClipRegion( const Region& i_rClip ) -{ - // TODO: support polygonal clipregions here - m_pPrinterGfx->BeginSetClipRegion( i_rClip.GetRectCount() ); - - ImplRegionInfo aInfo; - long nX, nY, nW, nH; - bool bRegionRect = i_rClip.ImplGetFirstRect(aInfo, nX, nY, nW, nH ); - while( bRegionRect ) - { - if ( nW && nH ) - { - m_pPrinterGfx->UnionClipRegion( nX, nY, nW, nH ); - } - bRegionRect = i_rClip.ImplGetNextRect( aInfo, nX, nY, nW, nH ); - } - m_pPrinterGfx->EndSetClipRegion(); - return true; -} - -void PspGraphics::SetLineColor() -{ - m_pPrinterGfx->SetLineColor (); -} - -void PspGraphics::SetLineColor( SalColor nSalColor ) -{ - psp::PrinterColor aColor (SALCOLOR_RED (nSalColor), - SALCOLOR_GREEN (nSalColor), - SALCOLOR_BLUE (nSalColor)); - m_pPrinterGfx->SetLineColor (aColor); -} - -void PspGraphics::SetFillColor() -{ - m_pPrinterGfx->SetFillColor (); -} - -void PspGraphics::SetFillColor( SalColor nSalColor ) -{ - psp::PrinterColor aColor (SALCOLOR_RED (nSalColor), - SALCOLOR_GREEN (nSalColor), - SALCOLOR_BLUE (nSalColor)); - m_pPrinterGfx->SetFillColor (aColor); -} - -void PspGraphics::SetROPLineColor( SalROPColor ) -{ - DBG_ASSERT( 0, "Error: PrinterGfx::SetROPLineColor() not implemented" ); -} - -void PspGraphics::SetROPFillColor( SalROPColor ) -{ - DBG_ASSERT( 0, "Error: PrinterGfx::SetROPFillColor() not implemented" ); -} - -void PspGraphics::SetXORMode( bool bSet, bool ) -{ - (void)bSet; - DBG_ASSERT( !bSet, "Error: PrinterGfx::SetXORMode() not implemented" ); -} - -void PspGraphics::drawPixel( long nX, long nY ) -{ - m_pPrinterGfx->DrawPixel (Point(nX, nY)); -} - -void PspGraphics::drawPixel( long nX, long nY, SalColor nSalColor ) -{ - psp::PrinterColor aColor (SALCOLOR_RED (nSalColor), - SALCOLOR_GREEN (nSalColor), - SALCOLOR_BLUE (nSalColor)); - m_pPrinterGfx->DrawPixel (Point(nX, nY), aColor); -} - -void PspGraphics::drawLine( long nX1, long nY1, long nX2, long nY2 ) -{ - m_pPrinterGfx->DrawLine (Point(nX1, nY1), Point(nX2, nY2)); -} - -void PspGraphics::drawRect( long nX, long nY, long nDX, long nDY ) -{ - m_pPrinterGfx->DrawRect (Rectangle(Point(nX, nY), Size(nDX, nDY))); -} - -void PspGraphics::drawPolyLine( sal_uLong nPoints, const SalPoint *pPtAry ) -{ - m_pPrinterGfx->DrawPolyLine (nPoints, (Point*)pPtAry); -} - -void PspGraphics::drawPolygon( sal_uLong nPoints, const SalPoint* pPtAry ) -{ - // Point must be equal to SalPoint! see vcl/inc/salgtype.hxx - m_pPrinterGfx->DrawPolygon (nPoints, (Point*)pPtAry); -} - -void PspGraphics::drawPolyPolygon( sal_uInt32 nPoly, - const sal_uInt32 *pPoints, - PCONSTSALPOINT *pPtAry ) -{ - m_pPrinterGfx->DrawPolyPolygon (nPoly, pPoints, (const Point**)pPtAry); -} - -bool PspGraphics::drawPolyLine( const ::basegfx::B2DPolygon&, double /*fTransparency*/, const ::basegfx::B2DVector& /*rLineWidths*/, basegfx::B2DLineJoin /*eJoin*/ ) -{ - // TODO: implement and advertise OutDevSupport_B2DDraw support - return false; -} - -sal_Bool PspGraphics::drawPolyLineBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry ) -{ - m_pPrinterGfx->DrawPolyLineBezier (nPoints, (Point*)pPtAry, pFlgAry); - return sal_True; -} - -sal_Bool PspGraphics::drawPolygonBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry ) -{ - m_pPrinterGfx->DrawPolygonBezier (nPoints, (Point*)pPtAry, pFlgAry); - return sal_True; -} - -sal_Bool PspGraphics::drawPolyPolygonBezier( sal_uInt32 nPoly, - const sal_uInt32* pPoints, - const SalPoint* const* pPtAry, - const sal_uInt8* const* pFlgAry ) -{ - // Point must be equal to SalPoint! see vcl/inc/salgtype.hxx - m_pPrinterGfx->DrawPolyPolygonBezier (nPoly, pPoints, (Point**)pPtAry, (sal_uInt8**)pFlgAry); - return sal_True; -} - -bool PspGraphics::drawPolyPolygon( const basegfx::B2DPolyPolygon&, double /*fTransparency*/ ) -{ - // TODO: implement and advertise OutDevSupport_B2DDraw support - return false; -} - -void PspGraphics::invert( sal_uLong /*nPoints*/, - const SalPoint* /*pPtAry*/, - SalInvert /*nFlags*/ ) -{ - DBG_ASSERT( 0, "Error: PrinterGfx::Invert() not implemented" ); -} -sal_Bool PspGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize ) -{ - return m_pPrinterGfx->DrawEPS( Rectangle( Point( nX, nY ), Size( nWidth, nHeight ) ), pPtr, nSize ); -} - -void PspGraphics::copyBits( const SalTwoRect* /*pPosAry*/, - SalGraphics* /*pSSrcGraphics*/ ) -{ - OSL_FAIL( "Error: PrinterGfx::CopyBits() not implemented" ); -} - -void PspGraphics::copyArea ( long /*nDestX*/, long /*nDestY*/, - long /*nSrcX*/, long /*nSrcY*/, - long /*nSrcWidth*/, long /*nSrcHeight*/, - sal_uInt16 /*nFlags*/ ) -{ - OSL_FAIL( "Error: PrinterGfx::CopyArea() not implemented" ); -} - -void PspGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap ) +void SvpPspGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap ) { Rectangle aSrc (Point(pPosAry->mnSrcX, pPosAry->mnSrcY), Size(pPosAry->mnSrcWidth, pPosAry->mnSrcHeight)); @@ -399,904 +191,10 @@ void PspGraphics::drawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBi } } -void PspGraphics::drawBitmap( const SalTwoRect* /*pPosAry*/, - const SalBitmap& /*rSalBitmap*/, - const SalBitmap& /*rTransBitmap*/ ) -{ - OSL_FAIL("Error: no PrinterGfx::DrawBitmap() for transparent bitmap"); -} - -void PspGraphics::drawBitmap( const SalTwoRect* /*pPosAry*/, - const SalBitmap& /*rSalBitmap*/, - SalColor /*nTransparentColor*/ ) -{ - OSL_FAIL("Error: no PrinterGfx::DrawBitmap() for transparent color"); -} - -void PspGraphics::drawMask( const SalTwoRect* /*pPosAry*/, - const SalBitmap& /*rSalBitmap*/, - SalColor /*nMaskColor*/ ) -{ - OSL_FAIL("Error: PrinterGfx::DrawMask() not implemented"); -} - -SalBitmap* PspGraphics::getBitmap( long /*nX*/, long /*nY*/, long /*nDX*/, long /*nDY*/ ) -{ - DBG_WARNING ("Warning: PrinterGfx::GetBitmap() not implemented"); - return NULL; -} - -SalColor PspGraphics::getPixel( long /*nX*/, long /*nY*/ ) -{ - OSL_FAIL("Warning: PrinterGfx::GetPixel() not implemented"); - return 0; -} - -void PspGraphics::invert( - long /*nX*/, - long /*nY*/, - long /*nDX*/, - long /*nDY*/, - SalInvert /*nFlags*/ ) -{ - OSL_FAIL("Warning: PrinterGfx::Invert() not implemented"); -} - -//========================================================================== - -class ImplPspFontData : public ImplFontData -{ -private: - enum { PSPFD_MAGIC = 0xb5bf01f0 }; - sal_IntPtr mnFontId; - -public: - ImplPspFontData( const psp::FastPrintFontInfo& ); - virtual sal_IntPtr GetFontId() const { return mnFontId; } - virtual ImplFontData* Clone() const { return new ImplPspFontData( *this ); } - virtual ImplFontEntry* CreateFontInstance( ImplFontSelectData& ) const; - static bool CheckFontData( const ImplFontData& r ) { return r.CheckMagic( PSPFD_MAGIC ); } -}; - -//-------------------------------------------------------------------------- - -ImplPspFontData::ImplPspFontData( const psp::FastPrintFontInfo& rInfo ) -: ImplFontData( PspGraphics::Info2DevFontAttributes(rInfo), PSPFD_MAGIC ), - mnFontId( rInfo.m_nID ) -{} - -//-------------------------------------------------------------------------- - -ImplFontEntry* ImplPspFontData::CreateFontInstance( ImplFontSelectData& rFSD ) const -{ - ImplServerFontEntry* pEntry = new ImplServerFontEntry( rFSD ); - return pEntry; -} - -//========================================================================== - -class PspFontLayout : public GenericSalLayout -{ -public: - PspFontLayout( ::psp::PrinterGfx& ); - virtual bool LayoutText( ImplLayoutArgs& ); - virtual void InitFont() const; - virtual void DrawText( SalGraphics& ) const; -private: - ::psp::PrinterGfx& mrPrinterGfx; - sal_IntPtr mnFontID; - int mnFontHeight; - int mnFontWidth; - bool mbVertical; - bool mbArtItalic; - bool mbArtBold; -}; - -//-------------------------------------------------------------------------- - -PspFontLayout::PspFontLayout( ::psp::PrinterGfx& rGfx ) -: mrPrinterGfx( rGfx ) -{ - mnFontID = mrPrinterGfx.GetFontID(); - mnFontHeight = mrPrinterGfx.GetFontHeight(); - mnFontWidth = mrPrinterGfx.GetFontWidth(); - mbVertical = mrPrinterGfx.GetFontVertical(); - mbArtItalic = mrPrinterGfx.GetArtificialItalic(); - mbArtBold = mrPrinterGfx.GetArtificialBold(); -} - -//-------------------------------------------------------------------------- - -bool PspFontLayout::LayoutText( ImplLayoutArgs& rArgs ) -{ - mbVertical = ((rArgs.mnFlags & SAL_LAYOUT_VERTICAL) != 0); - - long nUnitsPerPixel = 1; - int nOldGlyphId = -1; - long nGlyphWidth = 0; - int nCharPos = -1; - Point aNewPos( 0, 0 ); - GlyphItem aPrevItem; - rtl_TextEncoding aFontEnc = mrPrinterGfx.GetFontMgr().getFontEncoding( mnFontID ); - for(;;) - { - bool bRightToLeft; - if( !rArgs.GetNextPos( &nCharPos, &bRightToLeft ) ) - break; - - sal_UCS4 cChar = rArgs.mpStr[ nCharPos ]; - if( bRightToLeft ) - cChar = GetMirroredChar( cChar ); - // symbol font aliasing: 0x0020-0x00ff -> 0xf020 -> 0xf0ff - if( aFontEnc == RTL_TEXTENCODING_SYMBOL ) - if( cChar < 256 ) - cChar += 0xf000; - int nGlyphIndex = cChar; // printer glyphs = unicode - - // update fallback_runs if needed - psp::CharacterMetric aMetric; - mrPrinterGfx.GetFontMgr().getMetrics( mnFontID, cChar, cChar, &aMetric, mbVertical ); - if( aMetric.width == -1 && aMetric.height == -1 ) - rArgs.NeedFallback( nCharPos, bRightToLeft ); - - // apply pair kerning to prev glyph if requested - if( SAL_LAYOUT_KERNING_PAIRS & rArgs.mnFlags ) - { - if( nOldGlyphId > 0 ) - { - const std::list< KernPair >& rKernPairs = mrPrinterGfx.getKernPairs(mbVertical); - for( std::list< KernPair >::const_iterator it = rKernPairs.begin(); - it != rKernPairs.end(); ++it ) - { - if( it->first == nOldGlyphId && it->second == nGlyphIndex ) - { - int nTextScale = mrPrinterGfx.GetFontWidth(); - if( ! nTextScale ) - nTextScale = mrPrinterGfx.GetFontHeight(); - int nKern = (mbVertical ? it->kern_y : it->kern_x) * nTextScale; - nGlyphWidth += nKern; - aPrevItem.mnNewWidth = nGlyphWidth; - break; - } - } - } - } - - // finish previous glyph - if( nOldGlyphId >= 0 ) - AppendGlyph( aPrevItem ); - nOldGlyphId = nGlyphIndex; - aNewPos.X() += nGlyphWidth; - - // prepare GlyphItem for appending it in next round - nUnitsPerPixel = mrPrinterGfx.GetCharWidth( cChar, cChar, &nGlyphWidth ); - int nGlyphFlags = bRightToLeft ? GlyphItem::IS_RTL_GLYPH : 0; - nGlyphIndex |= GF_ISCHAR; - aPrevItem = GlyphItem( nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nGlyphWidth ); - } - - // append last glyph item if any - if( nOldGlyphId >= 0 ) - AppendGlyph( aPrevItem ); - - SetOrientation( mrPrinterGfx.GetFontAngle() ); - SetUnitsPerPixel( nUnitsPerPixel ); - return (nOldGlyphId >= 0); -} - -class PspServerFontLayout : public ServerFontLayout -{ -public: - PspServerFontLayout( psp::PrinterGfx&, ServerFont& rFont, const ImplLayoutArgs& rArgs ); - - virtual void InitFont() const; - const sal_Unicode* getTextPtr() const { return maText.getStr() - mnMinCharPos; } - int getMinCharPos() const { return mnMinCharPos; } - int getMaxCharPos() const { return mnMinCharPos+maText.getLength()-1; } -private: - ::psp::PrinterGfx& mrPrinterGfx; - sal_IntPtr mnFontID; - int mnFontHeight; - int mnFontWidth; - bool mbVertical; - bool mbArtItalic; - bool mbArtBold; - rtl::OUString maText; - int mnMinCharPos; -}; - -PspServerFontLayout::PspServerFontLayout( ::psp::PrinterGfx& rGfx, ServerFont& rFont, const ImplLayoutArgs& rArgs ) - : ServerFontLayout( rFont ), - mrPrinterGfx( rGfx ) -{ - mnFontID = mrPrinterGfx.GetFontID(); - mnFontHeight = mrPrinterGfx.GetFontHeight(); - mnFontWidth = mrPrinterGfx.GetFontWidth(); - mbVertical = mrPrinterGfx.GetFontVertical(); - mbArtItalic = mrPrinterGfx.GetArtificialItalic(); - mbArtBold = mrPrinterGfx.GetArtificialBold(); - maText = OUString( rArgs.mpStr + rArgs.mnMinCharPos, rArgs.mnEndCharPos - rArgs.mnMinCharPos+1 ); - mnMinCharPos = rArgs.mnMinCharPos; -} - -void PspServerFontLayout::InitFont() const -{ - mrPrinterGfx.SetFont( mnFontID, mnFontHeight, mnFontWidth, - mnOrientation, mbVertical, mbArtItalic, mbArtBold ); -} - -//-------------------------------------------------------------------------- - -static void DrawPrinterLayout( const SalLayout& rLayout, ::psp::PrinterGfx& rGfx, bool bIsPspServerFontLayout ) -{ - const int nMaxGlyphs = 200; - sal_GlyphId aGlyphAry[ nMaxGlyphs ]; - sal_Int32 aWidthAry[ nMaxGlyphs ]; - sal_Int32 aIdxAry [ nMaxGlyphs ]; - sal_Ucs aUnicodes[ nMaxGlyphs ]; - int aCharPosAry [ nMaxGlyphs ]; - - Point aPos; - long nUnitsPerPixel = rLayout.GetUnitsPerPixel(); - const sal_Unicode* pText = bIsPspServerFontLayout ? static_cast<const PspServerFontLayout&>(rLayout).getTextPtr() : NULL; - int nMinCharPos = bIsPspServerFontLayout ? static_cast<const PspServerFontLayout&>(rLayout).getMinCharPos() : 0; - int nMaxCharPos = bIsPspServerFontLayout ? static_cast<const PspServerFontLayout&>(rLayout).getMaxCharPos() : 0; - for( int nStart = 0;; ) - { - int nGlyphCount = rLayout.GetNextGlyphs( nMaxGlyphs, aGlyphAry, aPos, nStart, aWidthAry, bIsPspServerFontLayout ? aCharPosAry : NULL ); - if( !nGlyphCount ) - break; - - sal_Int32 nXOffset = 0; - for( int i = 0; i < nGlyphCount; ++i ) - { - nXOffset += aWidthAry[ i ]; - aIdxAry[ i ] = nXOffset / nUnitsPerPixel; - sal_Int32 nGlyphIdx = aGlyphAry[i] & (GF_IDXMASK | GF_ROTMASK); - if( bIsPspServerFontLayout ) - aUnicodes[i] = (aCharPosAry[i] >= nMinCharPos && aCharPosAry[i] <= nMaxCharPos) ? pText[ aCharPosAry[i] ] : 0; - else - aUnicodes[i] = (aGlyphAry[i] & GF_ISCHAR) ? nGlyphIdx : 0; - aGlyphAry[i] = nGlyphIdx; - } - - rGfx.DrawGlyphs( aPos, (sal_uInt32 *)aGlyphAry, aUnicodes, nGlyphCount, aIdxAry ); - } -} - -//-------------------------------------------------------------------------- - -void PspFontLayout::InitFont() const -{ - mrPrinterGfx.SetFont( mnFontID, mnFontHeight, mnFontWidth, - mnOrientation, mbVertical, mbArtItalic, mbArtBold ); -} - -//-------------------------------------------------------------------------- - -void PspFontLayout::DrawText( SalGraphics& ) const -{ - DrawPrinterLayout( *this, mrPrinterGfx, false ); -} - -void PspGraphics::DrawServerFontLayout( const ServerFontLayout& rLayout ) -{ - // print complex text - DrawPrinterLayout( rLayout, *m_pPrinterGfx, true ); -} - -const ImplFontCharMap* PspGraphics::GetImplFontCharMap() const -{ - if( !m_pServerFont[0] ) - return NULL; - - const ImplFontCharMap* pIFCMap = m_pServerFont[0]->GetImplFontCharMap(); - return pIFCMap; -} - -bool PspGraphics::GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const -{ - if (!m_pServerFont[0]) - return false; - return m_pServerFont[0]->GetFontCapabilities(rFontCapabilities); -} - -sal_uInt16 PspGraphics::SetFont( ImplFontSelectData *pEntry, int nFallbackLevel ) -{ - // release all fonts that are to be overridden - for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i ) - { - if( m_pServerFont[i] != NULL ) - { - // old server side font is no longer referenced - GlyphCache::GetInstance().UncacheFont( *m_pServerFont[i] ); - m_pServerFont[i] = NULL; - } - } - - // return early if there is no new font - if( !pEntry ) - return 0; - - sal_IntPtr nID = pEntry->mpFontData ? pEntry->mpFontData->GetFontId() : 0; - - // determine which font attributes need to be emulated - bool bArtItalic = false; - bool bArtBold = false; - if( pEntry->meItalic == ITALIC_OBLIQUE || pEntry->meItalic == ITALIC_NORMAL ) - { - FontItalic eItalic = m_pPrinterGfx->GetFontMgr().getFontItalic( nID ); - if( eItalic != ITALIC_NORMAL && eItalic != ITALIC_OBLIQUE ) - bArtItalic = true; - } - int nWeight = (int)pEntry->meWeight; - int nRealWeight = (int)m_pPrinterGfx->GetFontMgr().getFontWeight( nID ); - if( nRealWeight <= (int)WEIGHT_MEDIUM && nWeight > (int)WEIGHT_MEDIUM ) - { - bArtBold = true; - } - - // also set the serverside font for layouting - m_bFontVertical = pEntry->mbVertical; - if( pEntry->mpFontData ) - { - // requesting a font provided by builtin rasterizer - ServerFont* pServerFont = GlyphCache::GetInstance().CacheFont( *pEntry ); - if( pServerFont != NULL ) - { - if( pServerFont->TestFont() ) - m_pServerFont[ nFallbackLevel ] = pServerFont; - else - GlyphCache::GetInstance().UncacheFont( *pServerFont ); - } - } - - // set the printer font - return m_pPrinterGfx->SetFont( nID, - pEntry->mnHeight, - pEntry->mnWidth, - pEntry->mnOrientation, - pEntry->mbVertical, - bArtItalic, - bArtBold - ); -} - -void PspGraphics::SetTextColor( SalColor nSalColor ) -{ - psp::PrinterColor aColor (SALCOLOR_RED (nSalColor), - SALCOLOR_GREEN (nSalColor), - SALCOLOR_BLUE (nSalColor)); - m_pPrinterGfx->SetTextColor (aColor); -} - -bool PspGraphics::AddTempDevFont( ImplDevFontList*, const String&, const String& ) -{ - return false; -} - -void PspGraphics::GetDevFontList( ImplDevFontList *pList ) -{ - ::std::list< psp::fontID > aList; - psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); - rMgr.getFontList( aList, m_pJobData->m_pParser, m_pInfoPrinter->m_bCompatMetrics ); - - ::std::list< psp::fontID >::iterator it; - psp::FastPrintFontInfo aInfo; - for (it = aList.begin(); it != aList.end(); ++it) - if (rMgr.getFontFastInfo (*it, aInfo)) - AnnounceFonts( pList, aInfo ); -} - -void PspGraphics::GetDevFontSubstList( OutputDevice* pOutDev ) -{ - const psp::PrinterInfo& rInfo = psp::PrinterInfoManager::get().getPrinterInfo( m_pJobData->m_aPrinterName ); - if( rInfo.m_bPerformFontSubstitution ) - { - for( boost::unordered_map< rtl::OUString, rtl::OUString, rtl::OUStringHash >::const_iterator it = rInfo.m_aFontSubstitutes.begin(); it != rInfo.m_aFontSubstitutes.end(); ++it ) - AddDevFontSubstitute( pOutDev, it->first, it->second, FONT_SUBSTITUTE_ALWAYS ); - } -} - -void PspGraphics::GetFontMetric( ImplFontMetricData *pMetric, int ) -{ - const psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); - psp::PrintFontInfo aInfo; - - if (rMgr.getFontInfo (m_pPrinterGfx->GetFontID(), aInfo)) - { - ImplDevFontAttributes aDFA = Info2DevFontAttributes( aInfo ); - static_cast<ImplFontAttributes&>(*pMetric) = aDFA; - pMetric->mbDevice = aDFA.mbDevice; - pMetric->mbScalableFont = true; - - pMetric->mnOrientation = m_pPrinterGfx->GetFontAngle(); - pMetric->mnSlant = 0; - - sal_Int32 nTextHeight = m_pPrinterGfx->GetFontHeight(); - sal_Int32 nTextWidth = m_pPrinterGfx->GetFontWidth(); - if( ! nTextWidth ) - nTextWidth = nTextHeight; - - pMetric->mnWidth = nTextWidth; - pMetric->mnAscent = ( aInfo.m_nAscend * nTextHeight + 500 ) / 1000; - pMetric->mnDescent = ( aInfo.m_nDescend * nTextHeight + 500 ) / 1000; - pMetric->mnIntLeading = ( aInfo.m_nLeading * nTextHeight + 500 ) / 1000; - pMetric->mnExtLeading = 0; - } -} - -sal_uLong PspGraphics::GetKernPairs( sal_uLong nPairs, ImplKernPairData *pKernPairs ) -{ - const ::std::list< ::psp::KernPair >& rPairs( m_pPrinterGfx->getKernPairs() ); - sal_uLong nHavePairs = rPairs.size(); - if( pKernPairs && nPairs ) - { - ::std::list< ::psp::KernPair >::const_iterator it; - unsigned int i; - int nTextScale = m_pPrinterGfx->GetFontWidth(); - if( ! nTextScale ) - nTextScale = m_pPrinterGfx->GetFontHeight(); - for( i = 0, it = rPairs.begin(); i < nPairs && i < nHavePairs; i++, ++it ) - { - pKernPairs[i].mnChar1 = it->first; - pKernPairs[i].mnChar2 = it->second; - pKernPairs[i].mnKern = it->kern_x * nTextScale / 1000; - } - - } - return nHavePairs; -} - -sal_Bool PspGraphics::GetGlyphBoundRect( sal_GlyphId nGlyphIndex, Rectangle& rRect ) -{ - int nLevel = nGlyphIndex >> GF_FONTSHIFT; - if( nLevel >= MAX_FALLBACK ) - return sal_False; - - ServerFont* pSF = m_pServerFont[ nLevel ]; - if( !pSF ) - return sal_False; - - nGlyphIndex &= GF_IDXMASK; - const GlyphMetric& rGM = pSF->GetGlyphMetric( nGlyphIndex ); - rRect = Rectangle( rGM.GetOffset(), rGM.GetSize() ); - return sal_True; -} - -sal_Bool PspGraphics::GetGlyphOutline( sal_GlyphId nGlyphIndex, - ::basegfx::B2DPolyPolygon& rB2DPolyPoly ) -{ - int nLevel = nGlyphIndex >> GF_FONTSHIFT; - if( nLevel >= MAX_FALLBACK ) - return sal_False; - - ServerFont* pSF = m_pServerFont[ nLevel ]; - if( !pSF ) - return sal_False; - - nGlyphIndex &= GF_IDXMASK; - if( pSF->GetGlyphOutline( nGlyphIndex, rB2DPolyPoly ) ) - return sal_True; - - return sal_False; -} - -SalLayout* PspGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLevel ) -{ - // workaround for printers not handling glyph indexing for non-TT fonts - int nFontId = m_pPrinterGfx->GetFontID(); - if( psp::fonttype::TrueType != psp::PrintFontManager::get().getFontType( nFontId ) ) - rArgs.mnFlags |= SAL_LAYOUT_DISABLE_GLYPH_PROCESSING; - else if( nFallbackLevel > 0 ) - rArgs.mnFlags &= ~SAL_LAYOUT_DISABLE_GLYPH_PROCESSING; - - GenericSalLayout* pLayout = NULL; - - if( m_pServerFont[ nFallbackLevel ] - && !(rArgs.mnFlags & SAL_LAYOUT_DISABLE_GLYPH_PROCESSING) ) - pLayout = new PspServerFontLayout( *m_pPrinterGfx, *m_pServerFont[nFallbackLevel], rArgs ); - else - pLayout = new PspFontLayout( *m_pPrinterGfx ); - - return pLayout; -} - -//-------------------------------------------------------------------------- - -sal_Bool PspGraphics::CreateFontSubset( - const rtl::OUString& rToFile, - const ImplFontData* pFont, - sal_Int32* pGlyphIDs, - sal_uInt8* pEncoding, - sal_Int32* pWidths, - int nGlyphCount, - FontSubsetInfo& rInfo - ) -{ - // in this context the pFont->GetFontId() is a valid PSP - // font since they are the only ones left after the PDF - // export has filtered its list of subsettable fonts (for - // which this method was created). The correct way would - // be to have the GlyphCache search for the ImplFontData pFont - psp::fontID aFont = pFont->GetFontId(); - - psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); - bool bSuccess = rMgr.createFontSubset( rInfo, - aFont, - rToFile, - pGlyphIDs, - pEncoding, - pWidths, - nGlyphCount ); - return bSuccess; -} - -//-------------------------------------------------------------------------- - -const void* PspGraphics::GetEmbedFontData( const ImplFontData* pFont, const sal_Ucs* pUnicodes, sal_Int32* pWidths, FontSubsetInfo& rInfo, long* pDataLen ) -{ - // in this context the pFont->GetFontId() is a valid PSP - // font since they are the only ones left after the PDF - // export has filtered its list of subsettable fonts (for - // which this method was created). The correct way would - // be to have the GlyphCache search for the ImplFontData pFont - psp::fontID aFont = pFont->GetFontId(); - return PspGraphics::DoGetEmbedFontData( aFont, pUnicodes, pWidths, rInfo, pDataLen ); -} - -//-------------------------------------------------------------------------- - -void PspGraphics::FreeEmbedFontData( const void* pData, long nLen ) -{ - PspGraphics::DoFreeEmbedFontData( pData, nLen ); -} - -//-------------------------------------------------------------------------- - -const Ucs2SIntMap* PspGraphics::GetFontEncodingVector( const ImplFontData* pFont, const Ucs2OStrMap** pNonEncoded ) -{ - // in this context the pFont->GetFontId() is a valid PSP - // font since they are the only ones left after the PDF - // export has filtered its list of subsettable fonts (for - // which this method was created). The correct way would - // be to have the GlyphCache search for the ImplFontData pFont - psp::fontID aFont = pFont->GetFontId(); - return PspGraphics::DoGetFontEncodingVector( aFont, pNonEncoded ); -} - -//-------------------------------------------------------------------------- - -void PspGraphics::GetGlyphWidths( const ImplFontData* pFont, - bool bVertical, - Int32Vector& rWidths, - Ucs2UIntMap& rUnicodeEnc ) -{ - // in this context the pFont->GetFontId() is a valid PSP - // font since they are the only ones left after the PDF - // export has filtered its list of subsettable fonts (for - // which this method was created). The correct way would - // be to have the GlyphCache search for the ImplFontData pFont - psp::fontID aFont = pFont->GetFontId(); - PspGraphics::DoGetGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc ); -} - -// static helpers of PspGraphics - -const void* PspGraphics::DoGetEmbedFontData( fontID aFont, const sal_Ucs* pUnicodes, sal_Int32* pWidths, FontSubsetInfo& rInfo, long* pDataLen ) -{ - psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); - - psp::PrintFontInfo aFontInfo; - if( ! rMgr.getFontInfo( aFont, aFontInfo ) ) - return NULL; - - // fill in font info - rInfo.m_nAscent = aFontInfo.m_nAscend; - rInfo.m_nDescent = aFontInfo.m_nDescend; - rInfo.m_aPSName = rMgr.getPSName( aFont ); - - int xMin, yMin, xMax, yMax; - rMgr.getFontBoundingBox( aFont, xMin, yMin, xMax, yMax ); - - psp::CharacterMetric aMetrics[256]; - sal_Ucs aUnicodes[256]; - if( aFontInfo.m_aEncoding == RTL_TEXTENCODING_SYMBOL && aFontInfo.m_eType == psp::fonttype::Type1 ) - { - for( int i = 0; i < 256; i++ ) - aUnicodes[i] = pUnicodes[i] < 0x0100 ? pUnicodes[i] + 0xf000 : pUnicodes[i]; - pUnicodes = aUnicodes; - } - if( ! rMgr.getMetrics( aFont, pUnicodes, 256, aMetrics ) ) - return NULL; - - OString aSysPath = rMgr.getFontFileSysPath( aFont ); - struct stat aStat; - if( stat( aSysPath.getStr(), &aStat ) ) - return NULL; - int fd = open( aSysPath.getStr(), O_RDONLY ); - if( fd < 0 ) - return NULL; - void* pFile = mmap( NULL, aStat.st_size, PROT_READ, MAP_SHARED, fd, 0 ); - close( fd ); - if( pFile == MAP_FAILED ) - return NULL; - - *pDataLen = aStat.st_size; - - rInfo.m_aFontBBox = Rectangle( Point( xMin, yMin ), Size( xMax-xMin, yMax-yMin ) ); - rInfo.m_nCapHeight = yMax; // Well ... - - for( int i = 0; i < 256; i++ ) - pWidths[i] = (aMetrics[i].width > 0 ? aMetrics[i].width : 0); - - switch( aFontInfo.m_eType ) - { - case psp::fonttype::TrueType: - rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF; - break; - case psp::fonttype::Type1: { - const bool bPFA = ((*(unsigned char*)pFile) < 0x80); - rInfo.m_nFontType = bPFA ? FontSubsetInfo::TYPE1_PFA : FontSubsetInfo::TYPE1_PFB; - } - break; - default: - return NULL; - } - - return pFile; -} - -void PspGraphics::DoFreeEmbedFontData( const void* pData, long nLen ) -{ - if( pData ) - munmap( (char*)pData, nLen ); -} - -const Ucs2SIntMap* PspGraphics::DoGetFontEncodingVector( fontID aFont, const Ucs2OStrMap** pNonEncoded ) -{ - psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); - - psp::PrintFontInfo aFontInfo; - if( ! rMgr.getFontInfo( aFont, aFontInfo ) ) - { - if( pNonEncoded ) - *pNonEncoded = NULL; - return NULL; - } - - return rMgr.getEncodingMap( aFont, pNonEncoded ); -} - -void PspGraphics::DoGetGlyphWidths( psp::fontID aFont, - bool bVertical, - Int32Vector& rWidths, - Ucs2UIntMap& rUnicodeEnc ) -{ - psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); - rMgr.getGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc ); -} - -// ---------------------------------------------------------------------------- - -ImplDevFontAttributes PspGraphics::Info2DevFontAttributes( const psp::FastPrintFontInfo& rInfo ) -{ - ImplDevFontAttributes aDFA; - aDFA.maName = rInfo.m_aFamilyName; - aDFA.maStyleName = rInfo.m_aStyleName; - aDFA.meFamily = rInfo.m_eFamilyStyle; - aDFA.meWeight = rInfo.m_eWeight; - aDFA.meItalic = rInfo.m_eItalic; - aDFA.meWidthType = rInfo.m_eWidth; - aDFA.mePitch = rInfo.m_ePitch; - aDFA.mbSymbolFlag = (rInfo.m_aEncoding == RTL_TEXTENCODING_SYMBOL); - - switch( rInfo.m_eType ) - { - case psp::fonttype::Builtin: - aDFA.mnQuality = 1024; - aDFA.mbDevice = true; - aDFA.mbSubsettable = false; - aDFA.mbEmbeddable = false; - break; - case psp::fonttype::TrueType: - aDFA.mnQuality = 512; - aDFA.mbDevice = false; - aDFA.mbSubsettable = true; - aDFA.mbEmbeddable = false; - break; - case psp::fonttype::Type1: - aDFA.mnQuality = 0; - aDFA.mbDevice = false; - aDFA.mbSubsettable = false; - aDFA.mbEmbeddable = true; - break; - default: - aDFA.mnQuality = 0; - aDFA.mbDevice = false; - aDFA.mbSubsettable = false; - aDFA.mbEmbeddable = false; - break; - } - - aDFA.mbOrientation = true; - - // add font family name aliases - ::std::list< OUString >::const_iterator it = rInfo.m_aAliases.begin(); - bool bHasMapNames = false; - for(; it != rInfo.m_aAliases.end(); ++it ) - { - if( bHasMapNames ) - aDFA.maMapNames.Append( ';' ); - aDFA.maMapNames.Append( (*it).getStr() ); - bHasMapNames = true; - } - -#if OSL_DEBUG_LEVEL > 2 - if( bHasMapNames ) - { - rtl::OString aOrigName(rtl::OUStringToOString(aDFA.maName, - osl_getThreadTextEncoding())); - rtl::OString aAliasNames(rtl::OUStringToOString(aDFA.maMapNames, - osl_getThreadTextEncoding())); - fprintf( stderr, "using alias names \"%s\" for font family \"%s\"\n", - aAliasNames.getStr(), aOrigName.getStr() ); - } #endif - return aDFA; -} - -// ----------------------------------------------------------------------- - -void PspGraphics::AnnounceFonts( ImplDevFontList* pFontList, const psp::FastPrintFontInfo& aInfo ) -{ - int nQuality = 0; - - if( aInfo.m_eType == psp::fonttype::TrueType ) - { - // asian type 1 fonts are not known - psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); - ByteString aFileName( rMgr.getFontFileSysPath( aInfo.m_nID ) ); - int nPos = aFileName.SearchBackward( '_' ); - if( nPos == STRING_NOTFOUND || aFileName.GetChar( nPos+1 ) == '.' ) - nQuality += 5; - else - { - static const char* pLangBoost = NULL; - static bool bOnce = true; - if( bOnce ) - { - bOnce = false; - const LanguageType aLang = Application::GetSettings().GetUILanguage(); - switch( aLang ) - { - case LANGUAGE_JAPANESE: - pLangBoost = "jan"; - break; - case LANGUAGE_CHINESE: - case LANGUAGE_CHINESE_SIMPLIFIED: - case LANGUAGE_CHINESE_SINGAPORE: - pLangBoost = "zhs"; - break; - case LANGUAGE_CHINESE_TRADITIONAL: - case LANGUAGE_CHINESE_HONGKONG: - case LANGUAGE_CHINESE_MACAU: - pLangBoost = "zht"; - break; - case LANGUAGE_KOREAN: - case LANGUAGE_KOREAN_JOHAB: - pLangBoost = "kor"; - break; - } - } - - if( pLangBoost ) - if( aFileName.Copy( nPos+1, 3 ).EqualsIgnoreCaseAscii( pLangBoost ) ) - nQuality += 10; - } - } - - ImplPspFontData* pFD = new ImplPspFontData( aInfo ); - pFD->mnQuality += nQuality; - pFontList->Add( pFD ); -} - -bool PspGraphics::filterText( const String& rOrig, String& rNewText, xub_StrLen nIndex, xub_StrLen& rLen, xub_StrLen& rCutStart, xub_StrLen& rCutStop ) -{ - if( ! m_pPhoneNr ) - return false; - - rCutStop = rCutStart = STRING_NOTFOUND; - -#define FAX_PHONE_TOKEN "@@#" -#define FAX_PHONE_TOKEN_LENGTH 3 -#define FAX_END_TOKEN "@@" -#define FAX_END_TOKEN_LENGTH 2 - - bool bRet = false; - bool bStarted = false; - bool bStopped = false; - sal_uInt16 nPos; - sal_uInt16 nStart = 0; - sal_uInt16 nStop = rLen; - String aPhone = rOrig.Copy( nIndex, rLen ); - - if( ! m_bPhoneCollectionActive ) - { - if( ( nPos = aPhone.SearchAscii( FAX_PHONE_TOKEN ) ) != STRING_NOTFOUND ) - { - nStart = nPos; - m_bPhoneCollectionActive = true; - m_aPhoneCollection.Erase(); - bRet = true; - bStarted = true; - } - } - if( m_bPhoneCollectionActive ) - { - bRet = true; - nPos = bStarted ? nStart + FAX_PHONE_TOKEN_LENGTH : 0; - if( ( nPos = aPhone.SearchAscii( FAX_END_TOKEN, nPos ) ) != STRING_NOTFOUND ) - { - m_bPhoneCollectionActive = false; - nStop = nPos + FAX_END_TOKEN_LENGTH; - bStopped = true; - } - int nTokenStart = nStart + (bStarted ? FAX_PHONE_TOKEN_LENGTH : 0); - int nTokenStop = nStop - (bStopped ? FAX_END_TOKEN_LENGTH : 0); - m_aPhoneCollection += aPhone.Copy( nTokenStart, nTokenStop - nTokenStart ); - if( ! m_bPhoneCollectionActive ) - { - m_pPhoneNr->AppendAscii( "<Fax#>" ); - m_pPhoneNr->Append( m_aPhoneCollection ); - m_pPhoneNr->AppendAscii( "</Fax#>" ); - m_aPhoneCollection.Erase(); - } - } - if( m_aPhoneCollection.Len() > 1024 ) - { - m_bPhoneCollectionActive = false; - m_aPhoneCollection.Erase(); - bRet = false; - } - - if( bRet && m_bSwallowFaxNo ) - { - rLen -= nStop - nStart; - rCutStart = nStart+nIndex; - rCutStop = nStop+nIndex; - if( rCutStart ) - rNewText = rOrig.Copy( 0, rCutStart ); - rNewText += rOrig.Copy( rCutStop ); - } - - return bRet && m_bSwallowFaxNo; -} - -SystemFontData PspGraphics::GetSysFontData( int nFallbacklevel ) const -{ - SystemFontData aSysFontData; - - if (nFallbacklevel >= MAX_FALLBACK) nFallbacklevel = MAX_FALLBACK - 1; - if (nFallbacklevel < 0 ) nFallbacklevel = 0; - - aSysFontData.nSize = sizeof( SystemFontData ); - aSysFontData.nFontId = 0; - aSysFontData.nFontFlags = 0; - aSysFontData.bFakeBold = false; - aSysFontData.bFakeItalic = false; - aSysFontData.bAntialias = true; - return aSysFontData; -} - -SystemGraphicsData PspGraphics::GetGraphicsData() const +SvpPspGraphics::~SvpPspGraphics() { - SystemGraphicsData aRes; - aRes.nSize = sizeof(aRes); - aRes.hDrawable = 0; - aRes.pXRenderFormat = 0; - return aRes; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/headless/svptext.cxx b/vcl/headless/svptext.cxx index 64367063fa9b..823699f6f0c9 100644 --- a/vcl/headless/svptext.cxx +++ b/vcl/headless/svptext.cxx @@ -352,7 +352,7 @@ void SvpSalGraphics::GetDevFontList( ImplDevFontList* pDevFontList ) pExtraKernInfo = new PspKernInfo( *it ); // inform GlyphCache about this font provided by the PsPrint subsystem - ImplDevFontAttributes aDFA = PspGraphics::Info2DevFontAttributes( aInfo ); + ImplDevFontAttributes aDFA = GenPspGraphics::Info2DevFontAttributes( aInfo ); aDFA.mnQuality += 4096; const rtl::OString& rFileName = rMgr.getFontFileSysPath( aInfo.m_nID ); rGC.AddFontFile( rFileName, nFaceNum, aInfo.m_nID, aDFA, pExtraKernInfo ); @@ -415,7 +415,7 @@ const Ucs2SIntMap* SvpSalGraphics::GetFontEncodingVector( const ImplFontData* pF // which this method was created). The correct way would // be to have the GlyphCache search for the ImplFontData pFont psp::fontID aFont = pFont->GetFontId(); - return PspGraphics::DoGetFontEncodingVector( aFont, pNonEncoded ); + return GenPspGraphics::DoGetFontEncodingVector( aFont, pNonEncoded ); } // --------------------------------------------------------------------------- @@ -434,14 +434,14 @@ const void* SvpSalGraphics::GetEmbedFontData( // which this method was created). The correct way would // be to have the GlyphCache search for the ImplFontData pFont psp::fontID aFont = pFont->GetFontId(); - return PspGraphics::DoGetEmbedFontData( aFont, pUnicodes, pWidths, rInfo, pDataLen ); + return GenPspGraphics::DoGetEmbedFontData( aFont, pUnicodes, pWidths, rInfo, pDataLen ); } // --------------------------------------------------------------------------- void SvpSalGraphics::FreeEmbedFontData( const void* pData, long nLen ) { - PspGraphics::DoFreeEmbedFontData( pData, nLen ); + GenPspGraphics::DoFreeEmbedFontData( pData, nLen ); } void SvpSalGraphics::GetGlyphWidths( const ImplFontData* pFont, @@ -455,7 +455,7 @@ void SvpSalGraphics::GetGlyphWidths( const ImplFontData* pFont, // which this method was created). The correct way would // be to have the GlyphCache search for the ImplFontData pFont psp::fontID aFont = pFont->GetFontId(); - PspGraphics::DoGetGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc ); + GenPspGraphics::DoGetGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc ); } // --------------------------------------------------------------------------- diff --git a/vcl/inc/generic/geninst.h b/vcl/inc/generic/geninst.h index 4fd8866d2b3a..621ff175f6fb 100644 --- a/vcl/inc/generic/geninst.h +++ b/vcl/inc/generic/geninst.h @@ -34,6 +34,7 @@ #include <vcl/solarmutex.hxx> #include <salinst.hxx> #include <saldatabasic.hxx> +#include <generic/genprn.h> class VCL_DLLPUBLIC SalYieldMutexReleaser { @@ -73,6 +74,7 @@ public: /* * Abstract generic class to build vclplugin's instance classes from */ +class GenPspGraphics; class ImplDevFontList; class VCL_DLLPUBLIC SalGenericInstance : public SalInstance { @@ -106,12 +108,18 @@ public: virtual void jobStartedPrinterUpdate(); virtual void jobEndedPrinterUpdate(); bool isPrinterInit() const { return mbPrinterInit; } + virtual GenPspGraphics *CreatePrintGraphics() = 0; // prolly belongs somewhere else ... just a font help static void RegisterFontSubstitutors( ImplDevFontList* pList ); static int FetchFontSubstitutionFlags(); }; +inline SalGenericInstance *GetGenericInstance() +{ + return static_cast<SalGenericInstance *>(GetSalData()->m_pInstance); +} + #endif // _SV_GENERIC_INST_H /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/generic/genprn.h b/vcl/inc/generic/genprn.h index c3684ca4b9ab..4b8661e4e30c 100644 --- a/vcl/inc/generic/genprn.h +++ b/vcl/inc/generic/genprn.h @@ -35,12 +35,11 @@ #include "salprn.hxx" #include "vclpluginapi.h" -class PspGraphics; - +class GenPspGraphics; class VCL_DLLPUBLIC PspSalInfoPrinter : public SalInfoPrinter { public: - PspGraphics* m_pGraphics; + GenPspGraphics* m_pGraphics; psp::JobData m_aJobData; psp::PrinterGfx m_aPrinterGfx; @@ -74,7 +73,7 @@ public: bool m_bPdf:1; bool m_bSwallowFaxNo:1; bool m_bIsPDFWriterJob:1; - PspGraphics* m_pGraphics; + GenPspGraphics* m_pGraphics; psp::PrinterJob m_aPrintJob; psp::JobData m_aJobData; psp::PrinterGfx m_aPrinterGfx; @@ -82,7 +81,7 @@ public: bool m_bCollate; SalInfoPrinter* m_pInfoPrinter; - PspSalPrinter( SalInfoPrinter* ); + PspSalPrinter( SalInfoPrinter *pPrinter ); virtual ~PspSalPrinter(); // overload all pure virtual methods diff --git a/vcl/inc/generic/pspgraphics.h b/vcl/inc/generic/genpspgraphics.h index fd0a54d6ff1f..026113a1dc70 100644 --- a/vcl/inc/generic/pspgraphics.h +++ b/vcl/inc/generic/genpspgraphics.h @@ -26,8 +26,8 @@ * ************************************************************************/ -#ifndef _VCL_PSPGRAPHICS_H -#define _VCL_PSPGRAPHICS_H +#ifndef _VCL_GENPSPGRAPHICS_H +#define _VCL_GENPSPGRAPHICS_H #include "vcl/fontmanager.hxx" @@ -43,8 +43,9 @@ class ServerFont; class ImplDevFontAttributes; class SalInfoPrinter; -class VCL_DLLPUBLIC PspGraphics : public SalGraphics +class VCL_DLLPUBLIC GenPspGraphics : public SalGraphics { + protected: psp::JobData* m_pJobData; psp::PrinterGfx* m_pPrinterGfx; String* m_pPhoneNr; @@ -56,20 +57,20 @@ class VCL_DLLPUBLIC PspGraphics : public SalGraphics bool m_bFontVertical; SalInfoPrinter* m_pInfoPrinter; public: - PspGraphics( psp::JobData* pJob, psp::PrinterGfx* pGfx, String* pPhone, bool bSwallow, SalInfoPrinter* pInfoPrinter ) - : m_pJobData( pJob ), - m_pPrinterGfx( pGfx ), - m_pPhoneNr( pPhone ), - m_bSwallowFaxNo( bSwallow ), - m_bPhoneCollectionActive( false ), - m_bFontVertical( false ), - m_pInfoPrinter( pInfoPrinter ) - { for( int i = 0; i < MAX_FALLBACK; i++ ) m_pServerFont[i] = 0; } - virtual ~PspGraphics(); + GenPspGraphics(); + virtual ~GenPspGraphics(); + + void Init( psp::JobData* pJob, psp::PrinterGfx* pGfx, + String* pPhone, bool bSwallow, + SalInfoPrinter* pInfoPrinter ); + + // helper methods + static const void * DoGetEmbedFontData ( psp::fontID aFont, const sal_Ucs* pUnicodes, + sal_Int32* pWidths, FontSubsetInfo& rInfo, + long* pDataLen ); + static void DoFreeEmbedFontData( const void* pData, long nLen ); // helper methods for sharing with X11SalGraphics - static const void* DoGetEmbedFontData( psp::fontID aFont, const sal_Ucs* pUnicodes, sal_Int32* pWidths, FontSubsetInfo& rInfo, long* pDataLen ); - static void DoFreeEmbedFontData( const void* pData, long nLen ); static const Ucs2SIntMap* DoGetFontEncodingVector( psp::fontID aFont, const Ucs2OStrMap** pNonEncoded ); static void DoGetGlyphWidths( psp::fontID aFont, bool bVertical, @@ -114,11 +115,11 @@ public: FontSubsetInfo& rInfo ); virtual const Ucs2SIntMap* GetFontEncodingVector( const ImplFontData*, const Ucs2OStrMap** ppNonEncoded ); - virtual const void* GetEmbedFontData( const ImplFontData*, - const sal_Ucs* pUnicodes, - sal_Int32* pWidths, - FontSubsetInfo& rInfo, - long* pDataLen ); + virtual const void* GetEmbedFontData( const ImplFontData*, + const sal_Ucs* pUnicodes, + sal_Int32* pWidths, + FontSubsetInfo& rInfo, + long* pDataLen ); virtual void FreeEmbedFontData( const void* pData, long nDataLen ); virtual void GetGlyphWidths( const ImplFontData*, bool bVertical, @@ -187,6 +188,6 @@ public: virtual SystemFontData GetSysFontData( int nFallbacklevel ) const; }; -#endif // _VCL_PSPGRAPHICS_H +#endif // _VCL_GENPSPGRAPHICS_H /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/headless/svpinst.hxx b/vcl/inc/headless/svpinst.hxx index d3307abdb5ed..4fcdc2e13d6d 100644 --- a/vcl/inc/headless/svpinst.hxx +++ b/vcl/inc/headless/svpinst.hxx @@ -37,6 +37,7 @@ #include <salwtype.hxx> #include <saltimer.hxx> #include <generic/geninst.h> +#include <generic/genprn.h> #include <list> @@ -66,6 +67,7 @@ public: // - SalInstance - // --------------- class SvpSalFrame; +class GenPspGraphics; class SvpSalInstance : public SalGenericInstance { timeval m_aTimeout; @@ -168,6 +170,7 @@ public: virtual void AddToRecentDocumentList(const rtl::OUString& rFileUrl, const rtl::OUString& rMimeType); + virtual GenPspGraphics *CreatePrintGraphics(); }; #endif // _SV_SALINST_HXX diff --git a/vcl/inc/headless/svpprn.hxx b/vcl/inc/headless/svpprn.hxx index 67861f6e6cb5..e4ab5bd8b5fd 100644 --- a/vcl/inc/headless/svpprn.hxx +++ b/vcl/inc/headless/svpprn.hxx @@ -36,21 +36,20 @@ #include "vclpluginapi.h" -class PspGraphics; +class SvpPspGraphics; class SvpSalInfoPrinter : public PspSalInfoPrinter { public: - virtual sal_Bool Setup( SalFrame* pFrame, ImplJobSetup* pSetupData ); + virtual sal_Bool Setup( SalFrame* pFrame, ImplJobSetup* pSetupData ); }; class SvpSalPrinter : public PspSalPrinter { public: - SvpSalPrinter( SalInfoPrinter* pInfoPrinter ) : PspSalPrinter(pInfoPrinter) {} + SvpSalPrinter( SalInfoPrinter* pInfoPrinter ); }; #endif // _SVP_SVPPRN_HXX - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/inc/headless/svppspgraphics.hxx b/vcl/inc/headless/svppspgraphics.hxx index 1ce9109918d5..ad487687d839 100644 --- a/vcl/inc/headless/svppspgraphics.hxx +++ b/vcl/inc/headless/svppspgraphics.hxx @@ -29,159 +29,13 @@ #ifndef _SVP_PSPGRAPHICS_HXX #define _SVP_PSPGRAPHICS_HXX +#include "generic/genpspgraphics.h" -#include "vcl/fontmanager.hxx" - -#include "sallayout.hxx" -#include "salgdi.hxx" - -namespace psp { struct JobData; class PrinterGfx; } - -class ServerFont; -class ImplDevFontAttributes; -class SalInfoPrinter; - -class PspGraphics : public SalGraphics +class SvpPspGraphics : public GenPspGraphics { - psp::JobData* m_pJobData; - psp::PrinterGfx* m_pPrinterGfx; - String* m_pPhoneNr; - bool m_bSwallowFaxNo; - String m_aPhoneCollection; - bool m_bPhoneCollectionActive; - - ServerFont* m_pServerFont[ MAX_FALLBACK ]; - bool m_bFontVertical; - SalInfoPrinter* m_pInfoPrinter; - -protected: - virtual bool drawAlphaBitmap( const SalTwoRect&, const SalBitmap& rSourceBitmap, const SalBitmap& rAlphaBitmap ); - virtual bool drawAlphaRect( long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency ); - public: - PspGraphics( psp::JobData* pJob, psp::PrinterGfx* pGfx, String* pPhone, bool bSwallow, SalInfoPrinter* pInfoPrinter ) - : m_pJobData( pJob ), - m_pPrinterGfx( pGfx ), - m_pPhoneNr( pPhone ), - m_bSwallowFaxNo( bSwallow ), - m_bPhoneCollectionActive( false ), - m_bFontVertical( false ), - m_pInfoPrinter( pInfoPrinter ) - { for( int i = 0; i < MAX_FALLBACK; i++ ) m_pServerFont[i] = 0; } - virtual ~PspGraphics(); - - // helper methods for sharing with X11SalGraphics - static const void* DoGetEmbedFontData( psp::fontID aFont, const sal_Ucs* pUnicodes, sal_Int32* pWidths, FontSubsetInfo& rInfo, long* pDataLen ); - static void DoFreeEmbedFontData( const void* pData, long nLen ); - static const Ucs2SIntMap* DoGetFontEncodingVector( psp::fontID aFont, const Ucs2OStrMap** pNonEncoded ); - static void DoGetGlyphWidths( psp::fontID aFont, - bool bVertical, - Int32Vector& rWidths, - Ucs2UIntMap& rUnicodeEnc ); - static ImplDevFontAttributes Info2DevFontAttributes( const psp::FastPrintFontInfo& ); - static void AnnounceFonts( ImplDevFontList*, const psp::FastPrintFontInfo& ); - - // overload all pure virtual methods - virtual void GetResolution( sal_Int32& rDPIX, sal_Int32& rDPIY ); - virtual sal_uInt16 GetBitCount() const; - virtual long GetGraphicsWidth() const; - - virtual void ResetClipRegion(); - virtual bool setClipRegion( const Region& ); - - virtual void SetLineColor(); - virtual void SetLineColor( SalColor nSalColor ); - virtual void SetFillColor(); - virtual void SetFillColor( SalColor nSalColor ); - virtual void SetXORMode( bool bSet, bool ); - virtual void SetROPLineColor( SalROPColor nROPColor ); - virtual void SetROPFillColor( SalROPColor nROPColor ); - - virtual void SetTextColor( SalColor nSalColor ); - virtual sal_uInt16 SetFont( ImplFontSelectData*, int nFallbackLevel ); - virtual void GetFontMetric( ImplFontMetricData*, int nFallbackLevel ); - virtual sal_uLong GetKernPairs( sal_uLong nPairs, ImplKernPairData* pKernPairs ); - virtual const ImplFontCharMap* GetImplFontCharMap() const; - virtual bool GetImplFontCapabilities(vcl::FontCapabilities &rFontCapabilities) const; - virtual void GetDevFontList( ImplDevFontList* ); - virtual void GetDevFontSubstList( OutputDevice* ); - virtual bool AddTempDevFont( ImplDevFontList*, const String& rFileURL, const String& rFontName ); - virtual sal_Bool CreateFontSubset( const rtl::OUString& rToFile, - const ImplFontData*, - sal_Int32* pGlyphIDs, - sal_uInt8* pEncoding, - sal_Int32* pWidths, - int nGlyphs, - FontSubsetInfo& rInfo - ); - virtual const Ucs2SIntMap* GetFontEncodingVector( const ImplFontData*, const Ucs2OStrMap** ppNonEncoded ); - virtual const void* GetEmbedFontData( const ImplFontData*, - const sal_Ucs* pUnicodes, - sal_Int32* pWidths, - FontSubsetInfo& rInfo, - long* pDataLen ); - virtual void FreeEmbedFontData( const void* pData, long nDataLen ); - virtual void GetGlyphWidths( const ImplFontData*, - bool bVertical, - Int32Vector& rWidths, - Ucs2UIntMap& rUnicodeEnc ); - virtual sal_Bool GetGlyphBoundRect( sal_GlyphId nIndex, Rectangle& ); - virtual sal_Bool GetGlyphOutline( sal_GlyphId nIndex, ::basegfx::B2DPolyPolygon& ); - virtual SalLayout* GetTextLayout( ImplLayoutArgs&, int nFallbackLevel ); - virtual void DrawServerFontLayout( const ServerFontLayout& ); - virtual bool supportsOperation( OutDevSupportType ) const; - virtual void drawPixel( long nX, long nY ); - virtual void drawPixel( long nX, long nY, SalColor nSalColor ); - virtual void drawLine( long nX1, long nY1, long nX2, long nY2 ); - virtual void drawRect( long nX, long nY, long nWidth, long nHeight ); - virtual void drawPolyLine( sal_uLong nPoints, const SalPoint* pPtAry ); - virtual void drawPolygon( sal_uLong nPoints, const SalPoint* pPtAry ); - virtual bool drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double fTransparency ); - virtual bool drawPolyLine( const ::basegfx::B2DPolygon&, double fTransparency, const ::basegfx::B2DVector& rLineWidths, basegfx::B2DLineJoin ); - virtual void drawPolyPolygon( sal_uInt32 nPoly, - const sal_uInt32* pPoints, - PCONSTSALPOINT* pPtAry ); - virtual sal_Bool drawPolyLineBezier( sal_uLong nPoints, - const SalPoint* pPtAry, - const sal_uInt8* pFlgAry ); - virtual sal_Bool drawPolygonBezier( sal_uLong nPoints, - const SalPoint* pPtAry, - const sal_uInt8* pFlgAry ); - virtual sal_Bool drawPolyPolygonBezier( sal_uInt32 nPoly, - const sal_uInt32* pPoints, - const SalPoint* const* pPtAry, - const sal_uInt8* const* pFlgAry ); - - virtual void copyArea( long nDestX, - long nDestY, - long nSrcX, - long nSrcY, - long nSrcWidth, - long nSrcHeight, - sal_uInt16 nFlags ); - virtual void copyBits( const SalTwoRect* pPosAry, - SalGraphics* pSrcGraphics ); - virtual void drawBitmap( const SalTwoRect* pPosAry, - const SalBitmap& rSalBitmap ); - virtual void drawBitmap( const SalTwoRect* pPosAry, - const SalBitmap& rSalBitmap, - SalColor nTransparentColor ); - virtual void drawBitmap( const SalTwoRect* pPosAry, - const SalBitmap& rSalBitmap, - const SalBitmap& rTransparentBitmap ); - virtual void drawMask( const SalTwoRect* pPosAry, - const SalBitmap& rSalBitmap, - SalColor nMaskColor ); - virtual SalBitmap* getBitmap( long nX, long nY, long nWidth, long nHeight ); - virtual SalColor getPixel( long nX, long nY ); - virtual void invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags ); - virtual void invert( sal_uLong nPoints, const SalPoint* pPtAry, SalInvert nFlags ); - - virtual sal_Bool drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize ); - virtual bool filterText( const String& rOrigText, String& rNewText, xub_StrLen nIndex, xub_StrLen& rLen, xub_StrLen& rCutStart, xub_StrLen& rCutStop ); - - virtual SystemGraphicsData GetGraphicsData() const; - virtual SystemFontData GetSysFontData( int nFallbacklevel ) const; + SvpPspGraphics() {} + virtual ~SvpPspGraphics(); }; #endif // _SVP_PSPGRAPHICS_HXX diff --git a/vcl/inc/unx/gtk/gtkinst.hxx b/vcl/inc/unx/gtk/gtkinst.hxx index 80497dd8a572..98a162ab93d2 100644 --- a/vcl/inc/unx/gtk/gtkinst.hxx +++ b/vcl/inc/unx/gtk/gtkinst.hxx @@ -34,6 +34,7 @@ #include <headless/svpinst.hxx> #include <gtk/gtk.h> +class GenPspGraphics; class GtkYieldMutex : public SalYieldMutex { public: @@ -106,6 +107,8 @@ public: virtual void Yield( bool bWait, bool bHandleAllCurrentEvents ); virtual bool AnyInput( sal_uInt16 nType ); + virtual GenPspGraphics *CreatePrintGraphics(); + void RemoveTimer (SalTimer *pTimer); // for managing a mirror of the in-flight un-dispatched gdk event queue diff --git a/vcl/inc/unx/salinst.h b/vcl/inc/unx/salinst.h index e89efd8b17e2..7ca4bf4603cc 100644 --- a/vcl/inc/unx/salinst.h +++ b/vcl/inc/unx/salinst.h @@ -60,6 +60,7 @@ public: sal_uInt16 nBitCount, const SystemGraphicsData *pData = NULL ); virtual void DestroyVirtualDevice( SalVirtualDevice* pDevice ); virtual void PostPrintersChanged(); + virtual GenPspGraphics *CreatePrintGraphics(); virtual SalTimer* CreateSalTimer(); virtual SalI18NImeStatus* CreateI18NImeStatus(); diff --git a/vcl/unx/generic/app/salinst.cxx b/vcl/unx/generic/app/salinst.cxx index c6425baef1a8..27ceda05fc99 100644 --- a/vcl/unx/generic/app/salinst.cxx +++ b/vcl/unx/generic/app/salinst.cxx @@ -40,6 +40,7 @@ #include "unx/saldata.hxx" #include "unx/saldisp.hxx" #include "generic/geninst.h" +#include "generic/genpspgraphics.h" #include "unx/salframe.h" #include "generic/genprn.h" #include "unx/sm.hxx" @@ -356,4 +357,9 @@ void X11SalInstance::PostPrintersChanged() pDisp->SendInternalEvent( *it, NULL, SALEVENT_PRINTERCHANGED ); } +GenPspGraphics *X11SalInstance::CreatePrintGraphics() +{ + return new GenPspGraphics(); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/app/unxpspgraphics.cxx b/vcl/unx/generic/app/unxpspgraphics.cxx new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/vcl/unx/generic/app/unxpspgraphics.cxx diff --git a/vcl/unx/generic/gdi/salgdi3.cxx b/vcl/unx/generic/gdi/salgdi3.cxx index e653aaf60e73..aa71c78f471d 100644 --- a/vcl/unx/generic/gdi/salgdi3.cxx +++ b/vcl/unx/generic/gdi/salgdi3.cxx @@ -68,7 +68,7 @@ #include "unx/saldata.hxx" #include "unx/saldisp.hxx" #include "unx/salgdi.h" -#include "generic/pspgraphics.h" +#include "generic/genpspgraphics.h" #include "unx/salvd.h" #include "gcach_xpeer.hxx" @@ -538,7 +538,7 @@ bool X11SalGraphics::AddTempDevFont( ImplDevFontList* pFontList, aInfo.m_aFamilyName = rFontName; // inform glyph cache of new font - ImplDevFontAttributes aDFA = PspGraphics::Info2DevFontAttributes( aInfo ); + ImplDevFontAttributes aDFA = GenPspGraphics::Info2DevFontAttributes( aInfo ); aDFA.mnQuality += 5800; int nFaceNum = rMgr.getFontFaceNumber( aInfo.m_nID ); @@ -588,7 +588,7 @@ void X11SalGraphics::GetDevFontList( ImplDevFontList *pList ) pExtraKernInfo = new PspKernInfo( *it ); // inform GlyphCache about this font provided by the PsPrint subsystem - ImplDevFontAttributes aDFA = PspGraphics::Info2DevFontAttributes( aInfo ); + ImplDevFontAttributes aDFA = GenPspGraphics::Info2DevFontAttributes( aInfo ); aDFA.mnQuality += 4096; const rtl::OString& rFileName = rMgr.getFontFileSysPath( aInfo.m_nID ); rGC.AddFontFile( rFileName, nFaceNum, aInfo.m_nID, aDFA, pExtraKernInfo ); @@ -798,14 +798,14 @@ const void* X11SalGraphics::GetEmbedFontData( const ImplFontData* pFont, const s // which this method was created). The correct way would // be to have the GlyphCache search for the ImplFontData pFont psp::fontID aFont = pFont->GetFontId(); - return PspGraphics::DoGetEmbedFontData( aFont, pUnicodes, pWidths, rInfo, pDataLen ); + return GenPspGraphics::DoGetEmbedFontData( aFont, pUnicodes, pWidths, rInfo, pDataLen ); } //-------------------------------------------------------------------------- void X11SalGraphics::FreeEmbedFontData( const void* pData, long nLen ) { - PspGraphics::DoFreeEmbedFontData( pData, nLen ); + GenPspGraphics::DoFreeEmbedFontData( pData, nLen ); } //-------------------------------------------------------------------------- @@ -818,7 +818,7 @@ const Ucs2SIntMap* X11SalGraphics::GetFontEncodingVector( const ImplFontData* pF // which this method was created). The correct way would // be to have the GlyphCache search for the ImplFontData pFont psp::fontID aFont = pFont->GetFontId(); - return PspGraphics::DoGetFontEncodingVector( aFont, pNonEncoded ); + return GenPspGraphics::DoGetFontEncodingVector( aFont, pNonEncoded ); } //-------------------------------------------------------------------------- @@ -834,7 +834,7 @@ void X11SalGraphics::GetGlyphWidths( const ImplFontData* pFont, // which this method was created). The correct way would // be to have the GlyphCache search for the ImplFontData pFont psp::fontID aFont = pFont->GetFontId(); - PspGraphics::DoGetGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc ); + GenPspGraphics::DoGetGlyphWidths( aFont, bVertical, rWidths, rUnicodeEnc ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/generic/printer/unxpspgraphics.cxx b/vcl/unx/generic/printer/unxpspgraphics.cxx new file mode 100644 index 000000000000..4998e44a6092 --- /dev/null +++ b/vcl/unx/generic/printer/unxpspgraphics.cxx @@ -0,0 +1,156 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_vcl.hxx" + +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/mman.h> +#include <sys/stat.h> +#include <sys/types.h> + +#include "generic/geninst.h" +#include "generic/pspgraphics.h" +#include "generic/glyphcache.hxx" + +#include "vcl/jobdata.hxx" +#include "vcl/printerinfomanager.hxx" +#include "vcl/bmpacc.hxx" +#include "vcl/svapp.hxx" +#include "vcl/sysdata.hxx" + +#include "generic/printergfx.hxx" +#include "salbmp.hxx" +#include "impfont.hxx" +#include "outfont.hxx" +#include "fontsubset.hxx" +#include "salprn.hxx" +#include "region.h" + +#ifdef ENABLE_GRAPHITE +#include <graphite_layout.hxx> +#include <graphite_serverfont.hxx> +#endif + +using ::rtl::OUString; +using ::rtl::OString; + +UnxPspGraphics::UnxPspGraphics() +{ +} + +UnxPspGraphics::~UnxPspGraphics() +{ +} + +} + +void UnxPspGraphics::FreeEmbedFontData( const void* pData, long nLen ) +{ + if( pData ) + munmap( (char*)pData, nLen ); +} + +const void* UnxPspGraphics::GetEmbedFontData( const ImplFontData* pFont, const sal_Ucs* pUnicodes, sal_Int32* pWidths, FontSubsetInfo& rInfo, long* pDataLen ) +{ + // in this context the pFont->GetFontId() is a valid PSP + // font since they are the only ones left after the PDF + // export has filtered its list of subsettable fonts (for + // which this method was created). The correct way would + // be to have the GlyphCache search for the ImplFontData pFont + psp::fontID aFont = pFont->GetFontId(); + + psp::PrintFontManager& rMgr = psp::PrintFontManager::get(); + + psp::PrintFontInfo aFontInfo; + if( ! rMgr.getFontInfo( aFont, aFontInfo ) ) + return NULL; + + // fill in font info + rInfo.m_nAscent = aFontInfo.m_nAscend; + rInfo.m_nDescent = aFontInfo.m_nDescend; + rInfo.m_aPSName = rMgr.getPSName( aFont ); + + int xMin, yMin, xMax, yMax; + rMgr.getFontBoundingBox( aFont, xMin, yMin, xMax, yMax ); + + psp::CharacterMetric aMetrics[256]; + sal_Ucs aUnicodes[256]; + if( aFontInfo.m_aEncoding == RTL_TEXTENCODING_SYMBOL && aFontInfo.m_eType == psp::fonttype::Type1 ) + { + for( int i = 0; i < 256; i++ ) + aUnicodes[i] = pUnicodes[i] < 0x0100 ? pUnicodes[i] + 0xf000 : pUnicodes[i]; + pUnicodes = aUnicodes; + } + if( ! rMgr.getMetrics( aFont, pUnicodes, 256, aMetrics ) ) + return NULL; + + OString aSysPath = rMgr.getFontFileSysPath( aFont ); + struct stat aStat; + if( stat( aSysPath.getStr(), &aStat ) ) + return NULL; + int fd = open( aSysPath.getStr(), O_RDONLY ); + if( fd < 0 ) + return NULL; + void* pFile = mmap( NULL, aStat.st_size, PROT_READ, MAP_SHARED, fd, 0 ); + close( fd ); + if( pFile == MAP_FAILED ) + return NULL; + + *pDataLen = aStat.st_size; + + rInfo.m_aFontBBox = Rectangle( Point( xMin, yMin ), Size( xMax-xMin, yMax-yMin ) ); + rInfo.m_nCapHeight = yMax; // Well ... + + for( int i = 0; i < 256; i++ ) + pWidths[i] = (aMetrics[i].width > 0 ? aMetrics[i].width : 0); + + switch( aFontInfo.m_eType ) + { + case psp::fonttype::TrueType: + rInfo.m_nFontType = FontSubsetInfo::SFNT_TTF; + break; + case psp::fonttype::Type1: { + const bool bPFA = ((*(unsigned char*)pFile) < 0x80); + rInfo.m_nFontType = bPFA ? FontSubsetInfo::TYPE1_PFA : FontSubsetInfo::TYPE1_PFB; + } + break; + default: + return NULL; + } + + return pFile; +} + +void UnxPspGraphics::DoFreeEmbedFontData( const void* pData, long nLen ) +{ +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/unx/gtk/app/gtkdata.cxx b/vcl/unx/gtk/app/gtkdata.cxx index 2a61dd742ccd..9508cbc03991 100644 --- a/vcl/unx/gtk/app/gtkdata.cxx +++ b/vcl/unx/gtk/app/gtkdata.cxx @@ -96,6 +96,7 @@ GtkSalDisplay::GtkSalDisplay( GdkDisplay* pDisplay ) : Init (); #endif + // FIXME: unify this with SalInst's filter too ? gdk_window_add_filter( NULL, call_filterGdkEvent, this ); if ( getenv( "SAL_IGNOREXERRORS" ) ) diff --git a/vcl/unx/gtk/app/gtkinst.cxx b/vcl/unx/gtk/app/gtkinst.cxx index 0a9edc7358f9..b50e38cc7904 100644 --- a/vcl/unx/gtk/app/gtkinst.cxx +++ b/vcl/unx/gtk/app/gtkinst.cxx @@ -39,8 +39,9 @@ #include <unx/gtk/atkbridge.hxx> #include <headless/svpvd.hxx> #include <headless/svpbmp.hxx> +#include <headless/svppspgraphics.hxx> #include <vcl/apptypes.hxx> - +#include <generic/genpspgraphics.h> #include <rtl/strbuf.hxx> #include <rtl/uri.hxx> @@ -617,6 +618,15 @@ bool GtkInstance::AnyInput( sal_uInt16 nType ) } } +GenPspGraphics *GtkInstance::CreatePrintGraphics() +{ +#if GTK_CHECK_VERSION(3,0,0) + return new SvpPspGraphics(); +#else + return new GenPspGraphics(); +#endif +} + #if GTK_CHECK_VERSION(3,0,0) #define GTK3_INCLUDED #include "../../headless/svpinst.cxx" diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx index 9774c76c2dca..45b21c7b7a99 100644 --- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx +++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx @@ -36,7 +36,6 @@ #include "unx/gtk/gtkinst.hxx" #include "unx/gtk/gtkgdi.hxx" -#include "generic/pspgraphics.h" #include "unx/saldata.hxx" #include "unx/saldisp.hxx" @@ -47,6 +46,7 @@ #include <boost/unordered_map.hpp> #include "vcl/vclenum.hxx" +#include "vcl/fontmanager.hxx" typedef struct _cairo_font_options cairo_font_options_t; // initialize statics diff --git a/vcl/unx/kde/salnativewidgets-kde.cxx b/vcl/unx/kde/salnativewidgets-kde.cxx index ce400b68b311..762b8a1a84f3 100644 --- a/vcl/unx/kde/salnativewidgets-kde.cxx +++ b/vcl/unx/kde/salnativewidgets-kde.cxx @@ -36,10 +36,10 @@ #include <unx/saldata.hxx> #include <unx/saldisp.hxx> #include <unx/salgdi.h> -#include <generic/pspgraphics.h> #include <unx/kde/kdedata.hxx> #include <vcl/settings.hxx> +#include <vcl/fontmanager.hxx> #include <vcl/vclenum.hxx> #include <rtl/ustrbuf.hxx> diff --git a/vcl/unx/kde4/KDESalFrame.cxx b/vcl/unx/kde4/KDESalFrame.cxx index 4661160dcdf0..a484ea28a701 100644 --- a/vcl/unx/kde4/KDESalFrame.cxx +++ b/vcl/unx/kde4/KDESalFrame.cxx @@ -49,13 +49,12 @@ #include <tools/color.hxx> -#include <vcl/settings.hxx> #include <vcl/font.hxx> +#include <vcl/settings.hxx> +#include <vcl/fontmanager.hxx> #include <svdata.hxx> -#include <generic/pspgraphics.h> - #if OSL_DEBUG_LEVEL > 1 #include <stdio.h> #endif |