summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorChristof Pintaske <cp@openoffice.org>2000-11-17 17:42:57 +0000
committerChristof Pintaske <cp@openoffice.org>2000-11-17 17:42:57 +0000
commit139300dea1cf1f8827a28e7ae7b8abb4062512ea (patch)
tree776ee30098664ce83b761e46694b71fce5c267f8 /vcl
parentd1cd67f3e72e08eb42bcaf20e88f5313f28de919 (diff)
psprint changes
Diffstat (limited to 'vcl')
-rw-r--r--vcl/unx/source/gdi/makefile.mk15
-rw-r--r--vcl/unx/source/gdi/salgdi.cxx391
-rw-r--r--vcl/unx/source/gdi/salgdi2.cxx339
-rw-r--r--vcl/unx/source/gdi/salgdi3.cxx247
-rw-r--r--vcl/unx/source/gdi/salprnpsp.cxx859
5 files changed, 1775 insertions, 76 deletions
diff --git a/vcl/unx/source/gdi/makefile.mk b/vcl/unx/source/gdi/makefile.mk
index 09c02879f62d..369c3dbdca3f 100644
--- a/vcl/unx/source/gdi/makefile.mk
+++ b/vcl/unx/source/gdi/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.2 $
+# $Revision: 1.3 $
#
-# last change: $Author: pl $ $Date: 2000-09-27 08:35:21 $
+# last change: $Author: cp $ $Date: 2000-11-17 18:42:12 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -87,13 +87,10 @@ SLOFILES= \
$(SLO)$/salbmp.obj \
$(SLO)$/salgdi.obj \
$(SLO)$/salvd.obj \
- $(SLO)$/salprn.obj \
$(SLO)$/salogl.obj \
- $(SLO)$/salpimpl.obj \
$(SLO)$/charnames.obj \
$(SLO)$/dtint.obj \
$(SLO)$/kdeint.obj \
- $(SLO)$/salconfig.obj \
$(SLO)$/salcvt.obj \
$(SLO)$/ansi1252.obj \
$(SLO)$/xfont.obj \
@@ -102,6 +99,14 @@ SLOFILES= \
$(SLO)$/xlfd_smpl.obj \
$(SLO)$/salgdi3.obj
+.IF "$(PSPRINT)" == ""
+SLOFILES+=\
+ $(SLO)$/salprn.obj \
+ $(SLO)$/salpimpl.obj \
+ $(SLO)$/salconfig.obj
+.ELSE
+SLOFILES+=$(SLO)$/salprnpsp.obj
+.ENDIF
.IF "$(OS)"=="SOLARIS"
SLOFILES+=$(SLO)$/cdeint.obj
ENVCFLAGS+=-DUSE_CDE
diff --git a/vcl/unx/source/gdi/salgdi.cxx b/vcl/unx/source/gdi/salgdi.cxx
index 38e3340ab439..1a6b37063cbb 100644
--- a/vcl/unx/source/gdi/salgdi.cxx
+++ b/vcl/unx/source/gdi/salgdi.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: salgdi.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: gh $ $Date: 2000-10-12 13:59:12 $
+ * last change: $Author: cp $ $Date: 2000-11-17 18:42:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -83,6 +83,7 @@
#include <tools/debug.hxx>
+#if !defined(USE_PSPRINT)
#ifndef PRINTER_DUMMY
#define Font XLIB_Font
#define Region XLIB_Region
@@ -90,6 +91,12 @@
#undef Font
#undef Region
#endif
+#endif
+
+#if defined(USE_PSPRINT)
+#include <psprint/printergfx.hxx>
+#include <psprint/jobdata.hxx>
+#endif
// -=-= SalPolyLine =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -130,6 +137,10 @@ inline SalPolyLine::~SalPolyLine()
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final SalGraphicsData::SalGraphicsData()
{
+ #if defined(USE_PSPRINT)
+ m_pJobData = NULL;
+ m_pPrinterGfx = NULL;
+ #endif
hDrawable_ = None;
pClipRegion_ = NULL;
@@ -177,22 +188,27 @@ final SalGraphicsData::SalGraphicsData()
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final SalGraphicsData::~SalGraphicsData()
{
- Display *pDisplay = GetXDisplay();
-
- DBG_ASSERT( !pPaintRegion_, "pPaintRegion_" )
- if( pClipRegion_ ) XDestroyRegion( pClipRegion_ );
-
- if( hBrush_ ) XFreePixmap( pDisplay, hBrush_ );
- if( pPenGC_ ) XFreeGC( pDisplay, pPenGC_ );
- if( pFontGC_ ) XFreeGC( pDisplay, pFontGC_ );
- if( pBrushGC_ ) XFreeGC( pDisplay, pBrushGC_ );
- if( pMonoGC_ ) XFreeGC( pDisplay, pMonoGC_ );
- if( pCopyGC_ ) XFreeGC( pDisplay, pCopyGC_ );
- if( pMaskGC_ ) XFreeGC( pDisplay, pMaskGC_ );
- if( pInvertGC_ ) XFreeGC( pDisplay, pInvertGC_ );
- if( pInvert50GC_ ) XFreeGC( pDisplay, pInvert50GC_ );
- if( pStippleGC_ ) XFreeGC( pDisplay, pStippleGC_ );
- if( pTrackingGC_ ) XFreeGC( pDisplay, pTrackingGC_ );
+#ifdef USE_PSPRINT
+ if( ! ( m_pJobData || m_pPrinterGfx ) )
+#endif
+ {
+ Display *pDisplay = GetXDisplay();
+
+ DBG_ASSERT( !pPaintRegion_, "pPaintRegion_" )
+ if( pClipRegion_ ) XDestroyRegion( pClipRegion_ );
+
+ if( hBrush_ ) XFreePixmap( pDisplay, hBrush_ );
+ if( pPenGC_ ) XFreeGC( pDisplay, pPenGC_ );
+ if( pFontGC_ ) XFreeGC( pDisplay, pFontGC_ );
+ if( pBrushGC_ ) XFreeGC( pDisplay, pBrushGC_ );
+ if( pMonoGC_ ) XFreeGC( pDisplay, pMonoGC_ );
+ if( pCopyGC_ ) XFreeGC( pDisplay, pCopyGC_ );
+ if( pMaskGC_ ) XFreeGC( pDisplay, pMaskGC_ );
+ if( pInvertGC_ ) XFreeGC( pDisplay, pInvertGC_ );
+ if( pInvert50GC_ ) XFreeGC( pDisplay, pInvert50GC_ );
+ if( pStippleGC_ ) XFreeGC( pDisplay, pStippleGC_ );
+ if( pTrackingGC_ ) XFreeGC( pDisplay, pTrackingGC_ );
+ }
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -460,6 +476,18 @@ final SalGraphics::~SalGraphics()
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final void SalGraphics::GetResolution( long &rDPIX, long &rDPIY ) // const
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pJobData != NULL)
+ {
+ int x, y;
+ maGraphicsData.m_pJobData->m_aContext.getResolution( x, y );
+ rDPIX = x;
+ rDPIY = y;
+ }
+ else
+ {
+ #endif
+
SalDisplay *pDisplay = _GetDisplay();
rDPIX = pDisplay->GetResolution().A();
@@ -469,11 +497,22 @@ final void SalGraphics::GetResolution( long &rDPIX, long &rDPIY ) // const
rDPIX = Divide( rDPIX * 96, rDPIY );
rDPIY = 96;
}
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final void SalGraphics::GetScreenFontResolution( long &rDPIX, long &rDPIY ) // const
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ maGraphicsData.m_pPrinterGfx->GetScreenFontResolution (rDPIX, rDPIY);
+ else
+ {
+ #endif
+
GetResolution ( rDPIX, rDPIY );
if( rDPIY < 108 )
@@ -481,15 +520,39 @@ final void SalGraphics::GetScreenFontResolution( long &rDPIX, long &rDPIY ) // c
rDPIX = Divide( rDPIX * 108, rDPIY );
rDPIY = 108;
}
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final USHORT SalGraphics::GetBitCount() // const
-{ return _GetVisual()->GetDepth(); }
+{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ return maGraphicsData.m_pPrinterGfx->GetBitCount ();
+ else
+ {
+ #endif
+
+ return _GetVisual()->GetDepth();
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
+}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final void SalGraphics::ResetClipRegion()
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ maGraphicsData.m_pPrinterGfx->ResetClipRegion ();
+ else
+ {
+ #endif
+
if( _GetClipRegion() )
{
_IsPenGC() = FALSE;
@@ -505,25 +568,41 @@ final void SalGraphics::ResetClipRegion()
XDestroyRegion( _GetClipRegion() );
_GetClipRegion() = NULL;
}
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-final void SalGraphics::BeginSetClipRegion( ULONG )
+final void SalGraphics::BeginSetClipRegion( ULONG n )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ maGraphicsData.m_pPrinterGfx->BeginSetClipRegion(n);
+ else
+ {
+ #endif
+
if( _GetClipRegion() )
XDestroyRegion( _GetClipRegion() );
_GetClipRegion() = XCreateRegion();
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
BOOL SalGraphics::UnionClipRegion( long nX, long nY, long nDX, long nDY )
{
-#ifdef DEBUG
- if( nDX <= 0 || nX + nDX > 32767 )
- fprintf( stderr, "CombineClipRegion %ld %ld\n", nX, nDX );
- if( nDY <= 0 || nX + nDY > 32767 )
- fprintf( stderr, "CombineClipRegion %ld %ld\n", nY, nDY );
-#endif
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ return maGraphicsData.m_pPrinterGfx->UnionClipRegion (nX, nY, nDX, nDY);
+ else
+ {
+ #endif
+
if (!nDX || !nDY)
return TRUE;
@@ -536,11 +615,22 @@ BOOL SalGraphics::UnionClipRegion( long nX, long nY, long nDX, long nDY )
XUnionRectWithRegion( &aRect, _GetClipRegion(), _GetClipRegion() );
return TRUE;
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final void SalGraphics::EndSetClipRegion()
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ maGraphicsData.m_pPrinterGfx->EndSetClipRegion ();
+ else
+ {
+ #endif
+
_IsPenGC() = FALSE;
_IsFontGC() = FALSE;
_IsBrushGC() = FALSE;
@@ -551,52 +641,102 @@ final void SalGraphics::EndSetClipRegion()
_IsStippleGC() = FALSE;
_IsTrackingGC() = FALSE;
-// if( _GetPaintRegion() )
-// XIntersectRegion( _GetClipRegion(), _GetPaintRegion(), _GetClipRegion() );
-// else
-
if( XEmptyRegion( _GetClipRegion() ) )
{
XDestroyRegion( _GetClipRegion() );
_GetClipRegion() = NULL;
}
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final void SalGraphics::SetLineColor()
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ maGraphicsData.m_pPrinterGfx->SetLineColor ();
+ else
+ {
+ #endif
+
if( _GetPenColor() != 0xFFFFFFFF )
{
_GetPenColor() = 0xFFFFFFFF;
_IsPenGC() = FALSE;
}
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final void SalGraphics::SetLineColor( SalColor nSalColor )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ psp::PrinterColor aColor (SALCOLOR_RED (nSalColor),
+ SALCOLOR_GREEN (nSalColor),
+ SALCOLOR_BLUE (nSalColor));
+ maGraphicsData.m_pPrinterGfx->SetLineColor (aColor);
+ }
+ else
+ {
+ #endif
+
if( _GetPenColor() != nSalColor )
{
_GetPenColor() = nSalColor;
_GetPenPixel() = _GetPixel( nSalColor );
_IsPenGC() = FALSE;
}
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final void SalGraphics::SetFillColor()
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ maGraphicsData.m_pPrinterGfx->SetFillColor ();
+ else
+ {
+ #endif
+
if( _GetBrushColor() != 0xFFFFFFFF )
{
_IsDitherBrush() = FALSE;
_GetBrushColor() = 0xFFFFFFFF;
_IsBrushGC() = FALSE;
}
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final void SalGraphics::SetFillColor( SalColor nSalColor )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ psp::PrinterColor aColor (SALCOLOR_RED (nSalColor),
+ SALCOLOR_GREEN (nSalColor),
+ SALCOLOR_BLUE (nSalColor));
+ maGraphicsData.m_pPrinterGfx->SetFillColor (aColor);
+ }
+ else
+ {
+ #endif
+
if( _GetBrushColor() != nSalColor )
{
_IsDitherBrush() = FALSE;
@@ -623,11 +763,24 @@ final void SalGraphics::SetFillColor( SalColor nSalColor )
_IsDitherBrush() = maGraphicsData.GetDitherPixmap(nSalColor);
_IsBrushGC() = FALSE;
}
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final void SalGraphics::SetROPLineColor( SalROPColor nROPColor )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ DBG_ASSERT( 0, "Error: PrinterGfx::SetROPLineColor() not implemented" );
+ }
+ else
+ {
+ #endif
+
switch( nROPColor )
{
case SAL_ROP_0 : // 0
@@ -642,11 +795,24 @@ final void SalGraphics::SetROPLineColor( SalROPColor nROPColor )
}
_GetPenColor() = _GetColor( _GetPenPixel() );
_IsPenGC() = FALSE;
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final void SalGraphics::SetROPFillColor( SalROPColor nROPColor )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ DBG_ASSERT( 0, "Error: PrinterGfx::SetROPFillColor() not implemented" );
+ }
+ else
+ {
+ #endif
+
switch( nROPColor )
{
case SAL_ROP_0 : // 0
@@ -662,11 +828,24 @@ final void SalGraphics::SetROPFillColor( SalROPColor nROPColor )
_IsDitherBrush() = FALSE;
_GetBrushColor() = _GetColor( _GetBrushPixel() );
_IsBrushGC() = FALSE;
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final void SalGraphics::SetXORMode( BOOL bSet )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ DBG_ASSERT( !bSet, "Error: PrinterGfx::SetXORMode() not implemented" );
+ }
+ else
+ {
+ #endif
+
if( !_IsXORMode() == bSet )
{
_IsXORMode() = bSet;
@@ -679,17 +858,44 @@ final void SalGraphics::SetXORMode( BOOL bSet )
_IsStippleGC() = FALSE;
_IsTrackingGC() = FALSE;
}
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final void SalGraphics::DrawPixel( long nX, long nY )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ maGraphicsData.m_pPrinterGfx->DrawPixel (Point(nX, nY));
+ else
+ {
+ #endif
+
if( _GetPenColor() != 0xFFFFFFFF )
XDrawPoint( _GetXDisplay(), _GetDrawable(), _SelectPen(), nX, nY );
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
final void SalGraphics::DrawPixel( long nX, long nY, SalColor nSalColor )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ psp::PrinterColor aColor (SALCOLOR_RED (nSalColor),
+ SALCOLOR_GREEN (nSalColor),
+ SALCOLOR_BLUE (nSalColor));
+ maGraphicsData.m_pPrinterGfx->DrawPixel (Point(nX, nY), aColor);
+ }
+ else
+ {
+ #endif
+
if( nSalColor != 0xFFFFFFFF )
{
Display *pDisplay = _GetXDisplay();
@@ -714,11 +920,22 @@ final void SalGraphics::DrawPixel( long nX, long nY, SalColor nSalColor )
XSetForeground( pDisplay, pGC, _GetPenPixel() );
}
}
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final void SalGraphics::DrawLine( long nX1, long nY1, long nX2, long nY2 )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ maGraphicsData.m_pPrinterGfx->DrawLine (Point(nX1, nY1), Point(nX2, nY2));
+ else
+ {
+ #endif
+
if( _GetPenColor() != 0xFFFFFFFF )
{
if ( _GetDisplay()->GetProperties() & PROPERTY_BUG_DrawLine )
@@ -732,11 +949,22 @@ final void SalGraphics::DrawLine( long nX1, long nY1, long nX2, long nY2 )
XDrawLine( _GetXDisplay(), _GetDrawable(),_SelectPen(),
nX1, nY1, nX2, nY2 );
}
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void SalGraphics::DrawRect( long nX, long nY, long nDX, long nDY )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ maGraphicsData.m_pPrinterGfx->DrawRect (Rectangle(Point(nX, nY), Size(nDX, nDY)));
+ else
+ {
+ #endif
+
if( _GetBrushColor() != 0xFFFFFFFF )
XFillRectangle( _GetXDisplay(),
_GetDrawable(),
@@ -749,40 +977,52 @@ void SalGraphics::DrawRect( long nX, long nY, long nDX, long nDY )
_GetDrawable(),
_SelectPen(),
nX, nY, nDX-1, nDY-1 );
-}
-
-// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#if 0
-// Ausgetauscht durch SalGraphics::Invert
-final void SalGraphics::InvertTracking( ULONG nPoints, const SalPoint *pPtAry )
-{
- SalPolyLine Points( nPoints, pPtAry );
- maGraphicsData.DrawLines( nPoints, Points, _GetTrackingGC() );
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
-#endif
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final void SalGraphics::DrawPolyLine( ULONG nPoints, const SalPoint *pPtAry )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ maGraphicsData.m_pPrinterGfx->DrawPolyLine (nPoints, (Point*)pPtAry);
+ else
+ {
+ #endif
+
if( _GetPenColor() != 0xFFFFFFFF )
{
SalPolyLine Points( nPoints, pPtAry );
maGraphicsData.DrawLines( nPoints, Points, _SelectPen() );
}
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final void SalGraphics::DrawPolygon( ULONG nPoints, const SalPoint* pPtAry )
{
+ #if defined(USE_PSPRINT)
+ // Point must be equal to SalPoint! see vcl/inc/salgtype.hxx
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ maGraphicsData.m_pPrinterGfx->DrawPolygon (nPoints, (Point*)pPtAry);
+ else
+ {
+ #endif
+
if( nPoints < 3 )
{
if( !nPoints )
{
-#ifdef DEBUG
+ #ifdef DEBUG
fprintf( stderr, "SalGraphics::DrawPolygon !nPoints\n" );
-#endif
+ #endif
}
else if( !_IsXORMode() )
{
@@ -808,6 +1048,10 @@ final void SalGraphics::DrawPolygon( ULONG nPoints, const SalPoint* pPtAry )
if( _GetPenColor() != 0xFFFFFFFF )
maGraphicsData.DrawLines( nPoints, Points, _SelectPen() );
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -815,6 +1059,13 @@ void SalGraphics::DrawPolyPolygon( ULONG nPoly,
const ULONG *pPoints,
PCONSTSALPOINT *pPtAry )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ maGraphicsData.m_pPrinterGfx->DrawPolyPolygon (nPoly, pPoints, (const Point**)pPtAry);
+ else
+ {
+ #endif
+
if( _GetBrushColor() != 0xFFFFFFFF )
{
ULONG i, n;
@@ -874,6 +1125,10 @@ void SalGraphics::DrawPolyPolygon( ULONG nPoly,
if( _GetPenColor() != 0xFFFFFFFF )
for( ULONG i = 0; i < nPoly; i++ )
DrawPolyLine( pPoints[i], pPtAry[i] );
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -882,6 +1137,15 @@ beta void SalGraphics::Invert( ULONG nPoints,
const SalPoint* pPtAry,
SalInvert nFlags )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ DBG_ASSERT( 0, "Error: PrinterGfx::Invert() not implemented" );
+ }
+ else
+ {
+ #endif
+
SalDisplay *pDisp = _GetDisplay();
SalPolyLine Points ( nPoints, pPtAry );
@@ -895,29 +1159,27 @@ beta void SalGraphics::Invert( ULONG nPoints,
pGC = maGraphicsData.GetInvertGC();
maGraphicsData.DrawLines ( nPoints, Points, pGC );
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-#if 0
- struct XpEPS_trf
- {
- double origin_x, origin_y;
- double scale_x, scale_y;
- double rotate;
- };
- struct XpBox
- {
- double llx,lly;
- double urx,ury;
- };
- extern "C" void* XpEPS_Put( Display*, FILE*, struct XpEPS_trf* );
- extern "C" struct XpBox* XpEPS_GetBoundingBox( Display*, FILE* );
-#endif
-
BOOL SalGraphics::DrawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, ULONG nSize )
{
-#ifndef PRINTER_DUMMY
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ DBG_WARNING ("Warning: PrinterGfx::DrawEPS() not implemented");
+ return FALSE;
+ }
+ else
+ {
+ #endif
+
+ #if !defined(PRINTER_DUMMY) && !defined(USE_PSPRINT)
if( _IsPrinter() )
{
// convert \r to \n (#60367#, EPS-files with mac format)
@@ -958,9 +1220,9 @@ BOOL SalGraphics::DrawEPS( long nX, long nY, long nWidth, long nHeight, void* pP
{
aTransfer.scale_x = 1;
aTransfer.scale_y = 1;
-#ifdef DEBUG
+ #ifdef DEBUG
fprintf( stderr, "Warning: XpEPS_GetBoundingBox returned NULL\n" );
-#endif
+ #endif
}
XpEPS_Put( _GetXDisplay(), fp, &aTransfer );
@@ -969,7 +1231,12 @@ BOOL SalGraphics::DrawEPS( long nX, long nY, long nWidth, long nHeight, void* pP
return TRUE;
}
-#endif
+ #endif
+
return FALSE;
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
diff --git a/vcl/unx/source/gdi/salgdi2.cxx b/vcl/unx/source/gdi/salgdi2.cxx
index 49d547533586..48c53844c83f 100644
--- a/vcl/unx/source/gdi/salgdi2.cxx
+++ b/vcl/unx/source/gdi/salgdi2.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: salgdi2.cxx,v $
*
- * $Revision: 1.1.1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: hr $ $Date: 2000-09-18 17:05:43 $
+ * last change: $Author: cp $ $Date: 2000-11-17 18:42:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -81,7 +81,8 @@
#ifndef _SV_SALGDI_HXX
#include <salgdi.hxx>
#endif
-#ifndef PRINTER_DUMMY
+
+#if !defined(USE_PSPRINT) && !defined(PRINTER_DUMMY)
#define Font XLIB_Font
#define Region XLIB_Region
#include <xprinter/xp.h>
@@ -89,6 +90,11 @@
#undef Region
#endif
+#if defined(USE_PSPRINT)
+#include <psprint/printergfx.hxx>
+#include <bmpacc.hxx>
+#endif
+
#undef SALGDI2_TESTTRANS
// -=-= debugging =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -397,11 +403,216 @@ final GC SalGraphicsData::SetMask( int &nX,
return pMaskGC_;
}
+// ----- Implementation of PrinterBmp by means of SalBitmap/BitmapBuffer ---------------
+
+class SalPrinterBmp : public psp::PrinterBmp
+{
+ private:
+
+ BitmapBuffer* mpBmpBuffer;
+
+ FncGetPixel mpFncGetPixel;
+ Scanline mpScanAccess;
+ sal_Int32 mnScanOffset;
+
+ sal_uInt32 ColorOf (BitmapColor& rColor) const;
+ sal_uInt8 GrayOf (BitmapColor& rColor) const;
+
+ SalPrinterBmp ();
+
+ public:
+
+ SalPrinterBmp (BitmapBuffer* pBitmap);
+ virtual ~SalPrinterBmp ();
+ virtual sal_uInt32 GetPaletteColor (sal_uInt32 nIdx) const;
+ virtual sal_uInt32 GetPaletteEntryCount () const;
+ virtual sal_uInt32 GetPixelRGB (sal_uInt32 nRow, sal_uInt32 nColumn) const;
+ virtual sal_uInt8 GetPixelGray (sal_uInt32 nRow, sal_uInt32 nColumn) const;
+ virtual sal_uInt8 GetPixelIdx (sal_uInt32 nRow, sal_uInt32 nColumn) const;
+ virtual sal_uInt32 GetWidth () const;
+ virtual sal_uInt32 GetHeight() const;
+ virtual sal_uInt32 GetDepth () const;
+};
+
+SalPrinterBmp::SalPrinterBmp (BitmapBuffer* pBuffer) :
+ mpBmpBuffer (pBuffer)
+{
+ DBG_ASSERT (mpBmpBuffer, "SalPrinterBmp::SalPrinterBmp () can't acquire Bitmap");
+
+ // calibrate scanline buffer
+ if( BMP_SCANLINE_ADJUSTMENT( mpBmpBuffer->mnFormat ) == BMP_FORMAT_TOP_DOWN )
+ {
+ mpScanAccess = mpBmpBuffer->mpBits;
+ mnScanOffset = mpBmpBuffer->mnScanlineSize;
+ }
+ else
+ {
+ mpScanAccess = mpBmpBuffer->mpBits
+ + (mpBmpBuffer->mnHeight - 1) * mpBmpBuffer->mnScanlineSize;
+ mnScanOffset = - mpBmpBuffer->mnScanlineSize;
+ }
+
+ // request read access to the pixels
+ switch( BMP_SCANLINE_FORMAT( mpBmpBuffer->mnFormat ) )
+ {
+ case BMP_FORMAT_1BIT_MSB_PAL:
+ mpFncGetPixel = BitmapReadAccess::GetPixelFor_1BIT_MSB_PAL; break;
+ case BMP_FORMAT_1BIT_LSB_PAL:
+ mpFncGetPixel = BitmapReadAccess::GetPixelFor_1BIT_LSB_PAL; break;
+ case BMP_FORMAT_4BIT_MSN_PAL:
+ mpFncGetPixel = BitmapReadAccess::GetPixelFor_4BIT_MSN_PAL; break;
+ case BMP_FORMAT_4BIT_LSN_PAL:
+ mpFncGetPixel = BitmapReadAccess::GetPixelFor_4BIT_LSN_PAL; break;
+ case BMP_FORMAT_8BIT_PAL:
+ mpFncGetPixel = BitmapReadAccess::GetPixelFor_8BIT_PAL; break;
+ case BMP_FORMAT_8BIT_TC_MASK:
+ mpFncGetPixel = BitmapReadAccess::GetPixelFor_8BIT_TC_MASK; break;
+ case BMP_FORMAT_16BIT_TC_MASK:
+ mpFncGetPixel = BitmapReadAccess::GetPixelFor_16BIT_TC_MASK; break;
+ case BMP_FORMAT_24BIT_TC_BGR:
+ mpFncGetPixel = BitmapReadAccess::GetPixelFor_24BIT_TC_BGR; break;
+ case BMP_FORMAT_24BIT_TC_RGB:
+ mpFncGetPixel = BitmapReadAccess::GetPixelFor_24BIT_TC_RGB; break;
+ case BMP_FORMAT_24BIT_TC_MASK:
+ mpFncGetPixel = BitmapReadAccess::GetPixelFor_24BIT_TC_MASK; break;
+ case BMP_FORMAT_32BIT_TC_ABGR:
+ mpFncGetPixel = BitmapReadAccess::GetPixelFor_32BIT_TC_ABGR; break;
+ case BMP_FORMAT_32BIT_TC_ARGB:
+ mpFncGetPixel = BitmapReadAccess::GetPixelFor_32BIT_TC_ARGB; break;
+ case BMP_FORMAT_32BIT_TC_BGRA:
+ mpFncGetPixel = BitmapReadAccess::GetPixelFor_32BIT_TC_BGRA; break;
+ case BMP_FORMAT_32BIT_TC_RGBA:
+ mpFncGetPixel = BitmapReadAccess::GetPixelFor_32BIT_TC_RGBA; break;
+ case BMP_FORMAT_32BIT_TC_MASK:
+ mpFncGetPixel = BitmapReadAccess::GetPixelFor_32BIT_TC_MASK; break;
+
+ default:
+ DBG_ERROR("Error: SalPrinterBmp::SalPrinterBmp() unknown bitmap format");
+ break;
+ }
+}
+
+SalPrinterBmp::~SalPrinterBmp ()
+{
+}
+
+sal_uInt32
+SalPrinterBmp::GetWidth () const
+{
+ return mpBmpBuffer->mnWidth;
+}
+
+sal_uInt32
+SalPrinterBmp::GetHeight () const
+{
+ return mpBmpBuffer->mnHeight;
+}
+
+sal_uInt32
+SalPrinterBmp::GetDepth () const
+{
+ sal_uInt32 nDepth;
+
+ switch (mpBmpBuffer->mnBitCount)
+ {
+ case 1:
+ case 4:
+ case 8:
+ nDepth = 8;
+ break;
+
+ case 16:
+ case 24:
+ case 32:
+ nDepth = 24;
+ break;
+
+ default:
+ DBG_ERROR ("Error: unsupported bitmap depth in SalPrinterBmp::GetDepth()");
+ break;
+ }
+
+ return nDepth;
+}
+
+sal_uInt32
+SalPrinterBmp::ColorOf (BitmapColor& rColor) const
+{
+ if (rColor.IsIndex())
+ return ColorOf (mpBmpBuffer->maPalette[rColor.GetIndex()]);
+ else
+ return ((rColor.GetBlue()) & 0x000000ff)
+ | ((rColor.GetGreen() << 8) & 0x0000ff00)
+ | ((rColor.GetRed() << 16) & 0x00ff0000);
+}
+
+sal_uInt8
+SalPrinterBmp::GrayOf (BitmapColor& rColor) const
+{
+ if (rColor.IsIndex())
+ return GrayOf (mpBmpBuffer->maPalette[rColor.GetIndex()]);
+ else
+ return ( rColor.GetBlue() * 28UL
+ + rColor.GetGreen() * 151UL
+ + rColor.GetRed() * 77UL ) >> 8;
+}
+
+sal_uInt32
+SalPrinterBmp::GetPaletteEntryCount () const
+{
+ return mpBmpBuffer->maPalette.GetEntryCount ();
+}
+
+sal_uInt32
+SalPrinterBmp::GetPaletteColor (sal_uInt32 nIdx) const
+{
+ return ColorOf (mpBmpBuffer->maPalette[nIdx]);
+}
+
+sal_uInt32
+SalPrinterBmp::GetPixelRGB (sal_uInt32 nRow, sal_uInt32 nColumn) const
+{
+ Scanline pScan = mpScanAccess + nRow * mnScanOffset;
+ BitmapColor& aColor = mpFncGetPixel (pScan, nColumn, mpBmpBuffer->maColorMask);
+
+ return ColorOf (aColor);
+}
+
+sal_uInt8
+SalPrinterBmp::GetPixelGray (sal_uInt32 nRow, sal_uInt32 nColumn) const
+{
+ Scanline pScan = mpScanAccess + nRow * mnScanOffset;
+ BitmapColor& aColor = mpFncGetPixel (pScan, nColumn, mpBmpBuffer->maColorMask);
+
+ return GrayOf (aColor);
+}
+
+sal_uInt8
+SalPrinterBmp::GetPixelIdx (sal_uInt32 nRow, sal_uInt32 nColumn) const
+{
+ Scanline pScan = mpScanAccess + nRow * mnScanOffset;
+ BitmapColor& aColor = mpFncGetPixel (pScan, nColumn, mpBmpBuffer->maColorMask);
+
+ if (aColor.IsIndex())
+ return aColor.GetIndex();
+ else
+ return 0;
+}
+
// -=-= SalGraphics =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final void SalGraphics::CopyBits( const SalTwoRect *pPosAry,
SalGraphics *pSrcGraphics )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ DBG_ERROR( "Error: PrinterGfx::CopyBits() not implemented" );
+ }
+ else
+ {
+ #endif
+
if( pPosAry->mnSrcWidth <= 0
|| pPosAry->mnSrcHeight <= 0
|| pPosAry->mnDestWidth <= 0
@@ -490,6 +701,10 @@ final void SalGraphics::CopyBits( const SalTwoRect *pPosAry,
}
else
stderr0( "SalGraphics::CopyBits from Printer not yet implemented\n" );
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// --------------------------------------------------------------------------
@@ -499,6 +714,15 @@ final void SalGraphics::CopyArea ( long nDestX, long nDestY,
long nSrcWidth, long nSrcHeight,
USHORT nFlags )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ DBG_ERROR( "Error: PrinterGfx::CopyArea() not implemented" );
+ }
+ else
+ {
+ #endif
+
SalTwoRect aPosAry;
aPosAry.mnDestX = nDestX;
@@ -512,11 +736,34 @@ final void SalGraphics::CopyArea ( long nDestX, long nDestY,
aPosAry.mnSrcHeight = nSrcHeight;
CopyBits ( &aPosAry, 0 );
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ Rectangle aSrc (Point(pPosAry->mnSrcX, pPosAry->mnSrcY),
+ Size(pPosAry->mnSrcWidth, pPosAry->mnSrcHeight));
+ Rectangle aDst (Point(pPosAry->mnDestX, pPosAry->mnDestY),
+ Size(pPosAry->mnDestWidth, pPosAry->mnDestHeight));
+
+ BitmapBuffer* pBuffer= const_cast<SalBitmap&>(rSalBitmap).AcquireBuffer(sal_True);
+
+ SalPrinterBmp aBmp (pBuffer);
+ maGraphicsData.m_pPrinterGfx->DrawBitmap (aDst, aSrc, aBmp);
+
+ const_cast<SalBitmap&>(rSalBitmap).ReleaseBuffer (pBuffer, sal_True);
+ }
+ else
+ {
+ #endif
+
SalDisplay* pSalDisp = maGraphicsData.GetDisplay();
Display* pXDisp = pSalDisp->GetDisplay();
const Drawable aDrawable( maGraphicsData.GetDrawable() );
@@ -531,6 +778,7 @@ final void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, const SalBitmap&
aNewVal.foreground = rColMap.GetWhitePixel(), aNewVal.background = rColMap.GetBlackPixel();
XChangeGC( pXDisp, aGC, nValues, &aNewVal );
+ #if !defined(USE_PSPRINT)
if( _IsPrinter() )
{
SalTwoRect aTwoRect = { pPosAry->mnSrcX, pPosAry->mnSrcY, pPosAry->mnSrcWidth, pPosAry->mnSrcHeight,
@@ -548,10 +796,15 @@ final void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, const SalBitmap&
}
}
else
+ #endif
rSalBitmap.ImplDraw( aDrawable, nDepth, *pPosAry, aGC );
XChangeGC( pXDisp, aGC, nValues, &aOldVal );
XFlush( pXDisp );
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -559,6 +812,15 @@ final void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, const SalBitmap&
final void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap,
const SalBitmap& rTransBitmap )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ DBG_ERROR("Error: no PrinterGfx::DrawBitmap() for transparent bitmap");
+ }
+ else
+ {
+ #endif
+
DBG_ASSERT( !_IsPrinter(), "Drawing of transparent bitmaps on printer devices is strictly forbidden" );
SalDisplay* pSalDisp = maGraphicsData.GetDisplay();
@@ -631,19 +893,45 @@ final void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, const SalBitmap&
if( aBG )
XFreePixmap( pXDisp, aBG );
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, const SalBitmap& rSalBitmap,
SalColor nTransparentColor )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ DBG_ERROR("Error: no PrinterGfx::DrawBitmap() for transparent color");
+ }
+ else
+ {
+ #endif
+
DBG_ERROR( "::DrawBitmap with transparent color not supported" );
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final void SalGraphics::DrawMask( const SalTwoRect* pPosAry, const SalBitmap &rSalBitmap,
SalColor nMaskColor )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ DBG_ERROR("Error: PrinterGfx::DrawMask() not implemented");
+ }
+ else
+ {
+ #endif
+
SalDisplay* pSalDisp = maGraphicsData.GetDisplay();
Display* pXDisp = pSalDisp->GetDisplay();
Drawable aDrawable( maGraphicsData.GetDrawable() );
@@ -679,11 +967,25 @@ final void SalGraphics::DrawMask( const SalTwoRect* pPosAry, const SalBitmap &rS
}
else
DrawBitmap( pPosAry, rSalBitmap );
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final SalBitmap *SalGraphics::GetBitmap( long nX, long nY, long nDX, long nDY )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ DBG_WARNING ("Warning: PrinterGfx::GetBitmap() not implemented");
+ return NULL;
+ }
+ else
+ {
+ #endif
+
if( _IsPrinter() && !_IsVirtualDevice() )
return NULL;
@@ -743,11 +1045,25 @@ final SalBitmap *SalGraphics::GetBitmap( long nX, long nY, long nDX, long nDY )
pSalBitmap->ImplCreateFromDrawable( _GetDrawable(), nBitCount, nX, nY, nDX, nDY );
return pSalBitmap;
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
final SalColor SalGraphics::GetPixel( long nX, long nY )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ DBG_ERROR ("Warning: PrinterGfx::GetPixel() not implemented");
+ return 0;
+ }
+ else
+ {
+ #endif
+
if( _IsWindow() && !_IsVirtualDevice() )
{
XWindowAttributes aAttrib;
@@ -778,6 +1094,10 @@ final SalColor SalGraphics::GetPixel( long nX, long nY )
XDestroyImage( pXImage );
return _GetColormap().GetColor( aXColor.pixel );
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
@@ -787,6 +1107,15 @@ final void SalGraphics::Invert( long nX,
long nDY,
SalInvert nFlags )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ DBG_ERROR ("Warning: PrinterGfx::Invert() not implemented");
+ }
+ else
+ {
+ #endif
+
SalDisplay *pDisp = _GetDisplay();
GC pGC;
@@ -806,5 +1135,9 @@ final void SalGraphics::Invert( long nX,
pGC = maGraphicsData.GetInvertGC();
XFillRectangle( _GetXDisplay(), _GetDrawable(), pGC, nX, nY, nDX, nDY );
}
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
diff --git a/vcl/unx/source/gdi/salgdi3.cxx b/vcl/unx/source/gdi/salgdi3.cxx
index 43f0fc96e08d..cbfa0da94b7e 100644
--- a/vcl/unx/source/gdi/salgdi3.cxx
+++ b/vcl/unx/source/gdi/salgdi3.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: salgdi3.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: pl $ $Date: 2000-11-14 12:09:32 $
+ * last change: $Author: cp $ $Date: 2000-11-17 18:42:12 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -97,14 +97,18 @@
#include <tools/debug.hxx>
#include <tools/stream.hxx>
-#ifndef USE_PSPRINT
-#ifndef PRINTER_DUMMY
+#if !defined(USE_PSPRINT) && !defined(PRINTER_DUMMY)
#define Font XLIB_Font
#define Region XLIB_Region
#include <xprinter/xp.h>
#undef Font
#undef Region
#endif
+
+#if defined(USE_PSPRINT)
+#include <psprint/printergfx.hxx>
+#include <psprint/fontmanager.hxx>
+#include <psprint/jobdata.hxx>
#endif
#ifndef ANSI1252_HXX_
@@ -897,7 +901,18 @@ SalGraphicsData::DrawText( long nX, long nY,
void
SalGraphics::DrawText( long nX, long nY, const xub_Unicode* pStr, USHORT nLen )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ maGraphicsData.m_pPrinterGfx->DrawText (Point(nX, nY), pStr, nLen);
+ else
+ {
+ #endif
+
maGraphicsData.DrawText( nX, nY, pStr, nLen );
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
//--------------------------------------------------------------------------
@@ -986,8 +1001,25 @@ SalGraphicsData::DrawText(
USHORT
SalGraphics::SetFont( ImplFontSelectData *pEntry )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ sal_Bool bVertical = pEntry->mbVertical;
+ sal_Int32 nID = pEntry->mpFontData ? (sal_Int32)pEntry->mpFontData->mpSysData : 0;
+
+ return maGraphicsData.m_pPrinterGfx->SetFont(nID, pEntry->mnHeight,
+ pEntry->mnOrientation);
+ }
+ else
+ {
+ #endif
+
maGraphicsData.SetFont( pEntry );
return _IsPrinter() ? SAL_SETFONT_USEDRAWTEXTARRAY : 0;
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// ----------------------------------------------------------------------------
@@ -996,7 +1028,18 @@ void
SalGraphics::DrawTextArray( long nX, long nY,
const xub_Unicode *pStr, USHORT nLen, const long *pDXAry )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ maGraphicsData.m_pPrinterGfx->DrawText (Point(nX, nY), pStr, nLen, pDXAry);
+ else
+ {
+ #endif
+
maGraphicsData.DrawText( nX, nY, pStr, nLen, pDXAry );
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// ----------------------------------------------------------------------------
@@ -1004,19 +1047,153 @@ SalGraphics::DrawTextArray( long nX, long nY,
void
SalGraphics::SetTextColor( SalColor nSalColor )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ psp::PrinterColor aColor (SALCOLOR_RED (nSalColor),
+ SALCOLOR_GREEN (nSalColor),
+ SALCOLOR_BLUE (nSalColor));
+ maGraphicsData.m_pPrinterGfx->SetTextColor (aColor);
+ }
+ else
+ {
+ #endif
+
if( _GetTextColor() != nSalColor )
{
_GetTextColor() = nSalColor;
_GetTextPixel() = _GetPixel( nSalColor );
_IsFontGC() = FALSE;
}
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// ----------------------------------------------------------------------------
+#if defined(USE_PSPRINT)
+
+static FontWidth
+ToFontWidth (psp::width::type eWidth)
+{
+ switch (eWidth)
+ {
+ case psp::width::UltraCondensed: return WIDTH_ULTRA_CONDENSED;
+ case psp::width::ExtraCondensed: return WIDTH_EXTRA_CONDENSED;
+ case psp::width::Condensed: return WIDTH_CONDENSED;
+ case psp::width::SemiCondensed: return WIDTH_SEMI_CONDENSED;
+ case psp::width::Normal: return WIDTH_NORMAL;
+ case psp::width::SemiExpanded: return WIDTH_SEMI_EXPANDED;
+ case psp::width::Expanded: return WIDTH_EXPANDED;
+ case psp::width::ExtraExpanded: return WIDTH_EXTRA_EXPANDED;
+ case psp::width::UltraExpanded: return WIDTH_ULTRA_EXPANDED;
+ }
+ return WIDTH_DONTKNOW;
+}
+
+static FontWeight
+ToFontWeight (psp::weight::type eWeight)
+{
+ switch (eWeight)
+ {
+ case psp::weight::Thin: return WEIGHT_THIN;
+ case psp::weight::UltraLight: return WEIGHT_ULTRALIGHT;
+ case psp::weight::Light: return WEIGHT_LIGHT;
+ case psp::weight::SemiLight: return WEIGHT_SEMILIGHT;
+ case psp::weight::Normal: return WEIGHT_NORMAL;
+ case psp::weight::Medium: return WEIGHT_MEDIUM;
+ case psp::weight::SemiBold: return WEIGHT_SEMIBOLD;
+ case psp::weight::Bold: return WEIGHT_BOLD;
+ case psp::weight::UltraBold: return WEIGHT_ULTRABOLD;
+ case psp::weight::Black: return WEIGHT_BLACK;
+ }
+ return WEIGHT_DONTKNOW;
+}
+
+static FontPitch
+ToFontPitch (psp::pitch::type ePitch)
+{
+ switch (ePitch)
+ {
+ case psp::pitch::Fixed: return PITCH_FIXED;
+ case psp::pitch::Variable: return PITCH_VARIABLE;
+ }
+ return PITCH_DONTKNOW;
+}
+
+static FontItalic
+ToFontItalic (psp::italic::type eItalic)
+{
+ switch (eItalic)
+ {
+ case psp::italic::Upright: return ITALIC_NONE;
+ case psp::italic::Oblique: return ITALIC_OBLIQUE;
+ case psp::italic::Italic: return ITALIC_NORMAL;
+ }
+ return ITALIC_DONTKNOW;
+}
+
+static FontFamily
+ToFontFamily (psp::family::type eFamily)
+{
+ switch (eFamily)
+ {
+ case psp::family::Decorative: return FAMILY_DECORATIVE;
+ case psp::family::Modern: return FAMILY_MODERN;
+ case psp::family::Roman: return FAMILY_ROMAN;
+ case psp::family::Script: return FAMILY_SCRIPT;
+ case psp::family::Swiss: return FAMILY_SWISS;
+ case psp::family::System: return FAMILY_SYSTEM;
+ }
+ return FAMILY_DONTKNOW;
+}
+
+#endif /* USE_PSPRINT */
+
+// ----------------------------------------------------------------------------
+
void
SalGraphics::GetDevFontList( ImplDevFontList *pList )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pJobData != NULL)
+ {
+ ::std::list< psp::fontID > aList;
+
+ const psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
+ rMgr.getFontList( aList, maGraphicsData.m_pJobData->m_pParser );
+
+ ::std::list< psp::fontID >::iterator it;
+ for (it = aList.begin(); it != aList.end(); ++it)
+ {
+ psp::FastPrintFontInfo aInfo;
+ if (rMgr.getFontFastInfo (*it, aInfo))
+ {
+ ImplFontData *pFontData = new ImplFontData;
+ pFontData->mpSysData = (void*)*it;
+
+ pFontData->meFamily = ToFontFamily (aInfo.m_eFamilyStyle);
+ pFontData->meWeight = ToFontWeight (aInfo.m_eWeight);
+ pFontData->meItalic = ToFontItalic (aInfo.m_eItalic);
+ pFontData->meWidthType = ToFontWidth (aInfo.m_eWidth);
+ pFontData->mePitch = ToFontPitch (aInfo.m_ePitch);
+ pFontData->meCharSet = aInfo.m_aEncoding;
+ pFontData->maName = aInfo.m_aFamilyName;
+ /* pFontData->maStyleName = XXX */
+
+ pFontData->mbOrientation = TRUE;
+ pFontData->mbDevice = aInfo.m_eType == psp::fonttype::Builtin;
+
+ pList->Add( pFontData );
+ }
+ }
+ }
+ else
+ {
+ #endif
+
XlfdStorage* pFonts = _GetDisplay()->GetXlfdList();
for ( int nIdx = 0; nIdx < pFonts->GetCount(); nIdx++ )
@@ -1025,6 +1202,10 @@ SalGraphics::GetDevFontList( ImplDevFontList *pList )
pFonts->Get(nIdx)->ToImplFontData( pFontData );
pList->Add( pFontData );
}
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// ----------------------------------------------------------------------------
@@ -1035,19 +1216,56 @@ sal_DivideNeg( long n1, long n2 )
return ( n1 < 0 ) ? (n1 - n2 / 2) / n2 : (n1 + n2 / 2) / n2;
}
+// ----------------------------------------------------------------------------
+
void
SalGraphics::GetFontMetric( ImplFontMetricData *pMetric )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ {
+ const psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
+ psp::PrintFontInfo aInfo;
+
+ if (rMgr.getFontInfo (maGraphicsData.m_pPrinterGfx->GetFontID(), aInfo))
+ {
+ sal_Int32 nTextSize = maGraphicsData.m_pPrinterGfx->GetFontSize();
+
+ pMetric->mnOrientation = maGraphicsData.m_pPrinterGfx->GetFontAngle();
+ pMetric->mnSlant = 0;
+ pMetric->mbDevice = sal_True;
+
+ pMetric->meCharSet = aInfo.m_aEncoding;
+
+ pMetric->meFamily = ToFontFamily (aInfo.m_eFamilyStyle);
+ pMetric->meWeight = ToFontWeight (aInfo.m_eWeight);
+ pMetric->mePitch = ToFontPitch (aInfo.m_ePitch);
+ pMetric->meItalic = ToFontItalic (aInfo.m_eItalic);
+ pMetric->meType = TYPE_SCALABLE;
+
+ pMetric->mnFirstChar = 0;
+ pMetric->mnLastChar = 255;
+
+ pMetric->mnWidth = aInfo.m_nWidth * nTextSize / 1000;
+ pMetric->mnAscent = aInfo.m_nAscend * nTextSize / 1000;
+ pMetric->mnDescent = aInfo.m_nDescend * nTextSize / 1000;
+ pMetric->mnLeading = aInfo.m_nLeading * nTextSize / 1000;
+ }
+ }
+ else
+ {
+ #endif
+
ExtendedFontStruct* pFont = maGraphicsData.xFont_;
if ( pFont != NULL )
{
pFont->ToImplFontMetricData( pMetric );
-#ifndef USE_PSPRINT
+ #ifndef USE_PSPRINT
if( XSalCanDrawRotString( maGraphicsData.GetXDisplay(), None ) )
pMetric->mnOrientation = maGraphicsData.nFontOrientation_;
-#endif
+ #endif
if ( maGraphicsData.bFontVertical_ )
pMetric->mnOrientation = 2700;
@@ -1073,6 +1291,10 @@ SalGraphics::GetFontMetric( ImplFontMetricData *pMetric )
pMetric->mnSlant = sal_DivideNeg( pMetric->mnSlant, n );
}
}
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// ---------------------------------------------------------------------------
@@ -1088,9 +1310,18 @@ InitializeWidthArray( long *pWidthArray, sal_Size nItems, int nValue = 0 )
return nPrecision;
}
+// ---------------------------------------------------------------------------
+
long
SalGraphics::GetCharWidth( USHORT nChar1, USHORT nChar2, long *pWidthAry )
{
+ #if defined(USE_PSPRINT)
+ if (maGraphicsData.m_pPrinterGfx != NULL)
+ return maGraphicsData.m_pPrinterGfx->GetCharWidth(nChar1, nChar2, pWidthAry);
+ else
+ {
+ #endif
+
// return the precision of the calculated charwidth, e.g. 1000 = 3 digits
// defaultet to 1 for now
const long nPrecision = 1;
@@ -1129,6 +1360,10 @@ SalGraphics::GetCharWidth( USHORT nChar1, USHORT nChar2, long *pWidthAry )
// return
return nPrecision;
+
+ #if defined(USE_PSPRINT)
+ }
+ #endif
}
// ---------------------------------------------------------------------------
diff --git a/vcl/unx/source/gdi/salprnpsp.cxx b/vcl/unx/source/gdi/salprnpsp.cxx
new file mode 100644
index 000000000000..9aef7b03a7a5
--- /dev/null
+++ b/vcl/unx/source/gdi/salprnpsp.cxx
@@ -0,0 +1,859 @@
+/*************************************************************************
+ *
+ * $RCSfile: salprnpsp.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: cp $ $Date: 2000-11-17 18:42:57 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library 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 for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+/**
+ this file implements the sal printer interface ( SalPrinter, SalInfoPrinter
+ and some printer relevant methods of SalInstance and SalGraphicsData )
+
+ as aunderlying library the printer features of psprint are used.
+
+ The query methods of a SalInfoPrinter are implemented by querying psprint
+
+ The job methods of a SalPrinter are implemented by calling psprint
+ printer job functions.
+ */
+
+#include <salunx.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+#ifndef _SV_JOBSET_H
+#include <jobset.h>
+#endif
+#ifndef _SV_SALINST_HXX
+#include <salinst.hxx>
+#endif
+#ifndef _SV_SALPRN_HXX
+#include <salprn.hxx>
+#endif
+#ifndef _SV_SALGDI_HXX
+#include <salgdi.hxx>
+#endif
+#ifndef _SV_PRINT_H
+#include <print.h>
+#endif
+#ifndef _SV_SALPTYPE_HXX
+#include <salptype.hxx>
+#endif
+
+#ifndef _PSPRINT_PRINTERINFOMANAGER_HXX_
+#include <psprint/printerinfomanager.hxx>
+#endif
+
+using namespace psp;
+using namespace rtl;
+
+/*
+ * static helpers
+ */
+
+// NETBSD has no RTLD_GLOBAL
+#ifndef RTLD_GLOBAL
+#define DLOPEN_MODE (RTLD_LAZY)
+#else
+#define DLOPEN_MODE (RTLD_GLOBAL | RTLD_LAZY)
+#endif
+#include <dlfcn.h>
+#include <rtsname.hxx>
+
+static void* driverLib = NULL;
+static int(*pSetupFunction)(PrinterInfo&) = NULL;
+static int(*pFaxNrFunction)(String&) = NULL;
+
+static void getPaLib()
+{
+ const char* pErr = NULL;
+
+ if( ! driverLib )
+ {
+ driverLib = dlopen( _XSALSET_LIBNAME, DLOPEN_MODE );
+ pErr = dlerror();
+ if ( !driverLib )
+ {
+ fprintf( stderr, "%s: when opening %s\n", pErr, _XSALSET_LIBNAME );
+ return;
+ }
+
+ pSetupFunction = (int(*)(PrinterInfo&))dlsym( driverLib, "Sal_SetupPrinterDriver" );
+ pErr = dlerror();
+ if ( !pSetupFunction )
+ fprintf( stderr, "%s: when getting Sal_SetupPrinterDriver\n", pErr );
+
+ pFaxNrFunction = (int(*)(String&))dlsym( driverLib, "Sal_queryFaxNumber" );
+ pErr = dlerror();
+ if ( !pFaxNrFunction )
+ fprintf( stderr, "%s: when getting Sal_queryFaxNumber\n", pErr );
+ }
+}
+
+inline PtTo10Mu( int nPoints ) { return (int)(((double)nPoints)*35.27777778); }
+
+inline TenMuToPt( int nUnits ) { return (int)(((double)nUnits)/35.27777778); }
+
+static struct
+{
+ int width;
+ int height;
+ const char* name;
+ int namelength;
+ Paper paper;
+} aPaperTab[] =
+{
+ { 29700, 42000, "A3", 2, PAPER_A3 },
+ { 21000, 29700, "A4", 2, PAPER_A4 },
+ { 14800, 21000, "A5", 2, PAPER_A5 },
+ { 25000, 35300, "B4", 2, PAPER_B4 },
+ { 17600, 25000, "B5", 2, PAPER_B5 },
+ { 21600, 27900, "Letter", 6, PAPER_LETTER },
+ { 21600, 35600, "Legal", 5, PAPER_LEGAL },
+ { 27900, 43100, "Tabloid", 7, PAPER_TABLOID },
+ { 0, 0, "USER", 4, PAPER_USER }
+};
+
+static Paper getPaperType( const String& rPaperName )
+{
+ ByteString aPaper( rPaperName, RTL_TEXTENCODING_ISO_8859_1 );
+ for( int i = 0; i < sizeof( aPaperTab )/sizeof( aPaperTab[0] ); i++ )
+ {
+ if( ! strcmp( aPaper.GetBuffer(), aPaperTab[i].name ) )
+ return aPaperTab[i].paper;
+ }
+ return PAPER_USER;
+}
+
+static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
+{
+ pJobSetup->meOrientation = (Orientation)(rData.m_eOrientation == orientation::Landscape ? ORIENTATION_LANDSCAPE : ORIENTATION_PORTRAIT);
+
+ // copy page size
+ String aPaper;
+ int width, height;
+
+ rData.m_aContext.getPageSize( aPaper, width, height );
+ pJobSetup->mePaperFormat = getPaperType( aPaper );
+ pJobSetup->mnPaperWidth = 0;
+ pJobSetup->mnPaperHeight = 0;
+ if( pJobSetup->mePaperFormat == PAPER_USER )
+ {
+ // transform to 100dth mm
+ width = PtTo10Mu( width );
+ height = PtTo10Mu( height );
+
+ pJobSetup->mnPaperWidth = width;
+ pJobSetup->mnPaperHeight= height;
+ }
+
+
+ // copy input slot
+ const PPDKey* pKey;
+ const PPDValue* pValue;
+ ::std::list< const PPDValue* > aValues;
+ ::std::list< const PPDValue* >::iterator it;
+
+ pKey = rData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "InputSlot" ) ) );
+ pValue = rData.m_aContext.getValue( pKey );
+ rData.m_aContext.getUnconstrainedValues( pKey, aValues );
+ pJobSetup->mnPaperBin = 0;
+ for( it = aValues.begin(); it != aValues.end(); ++it, pJobSetup->mnPaperBin++ )
+ if( *it == pValue )
+ break;
+ if( it == aValues.end() )
+ pJobSetup->mnPaperBin = 0xffff;
+
+
+ // copy the whole context
+ if( pJobSetup->mpDriverData )
+ delete pJobSetup->mpDriverData;
+
+ int nBytes;
+ void* pBuffer = NULL;
+ if( rData.getStreamBuffer( pBuffer, nBytes ) )
+ {
+ pJobSetup->mnDriverDataLen = nBytes;
+ pJobSetup->mpDriverData = (BYTE*)pBuffer;
+ }
+ else
+ {
+ pJobSetup->mnDriverDataLen = 0;
+ pJobSetup->mpDriverData = NULL;
+ }
+}
+
+static bool sendAFax( const String& rFaxNumber, const String& rFileName, const String& rCommand )
+{
+ bool bSuccess = false;
+
+ rtl_TextEncoding aEncoding = gsl_getSystemTextEncoding();
+ ByteString aFaxNumber( rFaxNumber, aEncoding );
+ ByteString aFileName( rFileName, aEncoding );
+ ByteString aCmdLine( rCommand, aEncoding );
+ // some filters may depend on the extension
+ ByteString aPSFileName( aFileName );
+ aPSFileName.Append( ".ps" );
+ BOOL bPS = link( aFileName.GetBuffer(), aPSFileName.GetBuffer() ) ? FALSE : TRUE;
+
+ ByteString aUseFileName( bPS ? aPSFileName : aFileName );
+
+ bool bPipe = aCmdLine.Search( "(TMP)" ) != STRING_NOTFOUND ? false : true;
+ if( ! aFaxNumber.Len() )
+ // then the number must be embedded in the document
+ {
+ SvFileStream aStream( rFileName, STREAM_READ );
+ ByteString aLine;
+ while( aStream.IsEof() )
+ {
+ aStream.ReadLine( aLine );
+ if( aLine.GetChar( 0 ) == '%' &&
+ aLine.Search( "PhoneNumber(" ) != STRING_NOTFOUND )
+ {
+ aFaxNumber = aLine.GetToken( 1, '(' ).GetToken( 0, ')' );
+ break;
+ }
+ }
+ }
+
+ if( ! aFaxNumber.Len() )
+ {
+ getPaLib();
+ if( pFaxNrFunction )
+ {
+ String aNewNr;
+ if( pFaxNrFunction( aNewNr ) )
+ aFaxNumber = ByteString( aNewNr, aEncoding );
+ }
+ }
+
+ if( aFaxNumber.Len() )
+ {
+ // setup command line for exec
+ while( aCmdLine.SearchAndReplace( "(TMP)", aUseFileName ) != STRING_NOTFOUND )
+ ;
+ while( aCmdLine.SearchAndReplace( "(PHONE)", aFaxNumber ) != STRING_NOTFOUND )
+ ;
+#ifdef DEBUG
+ fprintf( stderr, "fax commandline: \"%s\"\n", aCmdLine.GetBuffer() );
+#endif
+
+ const char* argv[4];
+ if( ! ( argv[ 0 ] = getenv( "SHELL" ) ) )
+ argv[ 0 ] = "/bin/sh";
+ argv[ 1 ] = "-c";
+ argv[ 2 ] = aCmdLine.GetBuffer();
+ argv[ 3 ] = 0;
+
+ bool bHavePipes = false;
+ int pid, fd[2];
+
+ if( bPipe )
+ bHavePipes = pipe( fd ) ? false : true;
+ if( ( pid = fork() ) > 0 )
+ {
+ if( bPipe && bHavePipes )
+ {
+ close( fd[0] );
+ char aBuffer[ 2048 ];
+ FILE* fp = fopen( aFileName.GetBuffer(), "r" );
+ while( fp && ! feof( fp ) )
+ {
+ int nBytes = fread( aBuffer, 1, sizeof( aBuffer ), fp );
+ if( nBytes )
+ write( fd[ 1 ], aBuffer, nBytes );
+ }
+ fclose( fp );
+ close( fd[ 1 ] );
+ }
+ int status = 0;
+ waitpid( pid, &status, 0 );
+ if( ! status )
+ bSuccess = true;
+ }
+ else if( ! pid )
+ {
+ if( bPipe && bHavePipes )
+ {
+ close( fd[1] );
+ if( fd[0] != STDIN_FILENO ) // not probable, but who knows :)
+ dup2( fd[0], STDIN_FILENO );
+ }
+ execv( argv[0], const_cast<char**>(argv) );
+ fprintf( stderr, "failed to execute \"%s\"\n", aCmdLine.GetBuffer() );
+ _exit( 1 );
+ }
+ else
+ fprintf( stderr, "failed to fork\n" );
+ }
+
+ // clean up the mess
+ unlink( aFileName.GetBuffer() );
+ if( bPipe )
+ unlink( aPSFileName.GetBuffer() );
+ return bSuccess;
+}
+
+/*
+ * SalInstance
+ */
+
+// -----------------------------------------------------------------------
+
+SalInfoPrinter* SalInstance::CreateInfoPrinter(
+ SalPrinterQueueInfo* pQueueInfo,
+ ImplJobSetup* pJobSetup )
+{
+ // create and initialize SalInfoPrinter
+ SalInfoPrinter* pPrinter = new SalInfoPrinter;
+
+ if( pJobSetup )
+ {
+ PrinterInfoManager& rManager( PrinterInfoManager::get() );
+ PrinterInfo aInfo( rManager.getPrinterInfo( pQueueInfo->maPrinterName ) );
+ pPrinter->maPrinterData.m_aJobData = aInfo;
+ pPrinter->maPrinterData.m_aPrinterGfx.Init( pPrinter->maPrinterData.m_aJobData );
+
+ if( pJobSetup->mpDriverData )
+ JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aInfo );
+
+ pJobSetup->mnSystem = JOBSETUP_SYSTEM_UNIX;
+ pJobSetup->maPrinterName = pQueueInfo->maPrinterName;
+ pJobSetup->maDriver = aInfo.m_aDriverName;
+ copyJobDataToJobSetup( pJobSetup, aInfo );
+ }
+
+
+ return pPrinter;
+}
+
+// -----------------------------------------------------------------------
+
+void SalInstance::DestroyInfoPrinter( SalInfoPrinter* pPrinter )
+{
+ delete pPrinter;
+}
+
+// -----------------------------------------------------------------------
+
+SalPrinter* SalInstance::CreatePrinter( SalInfoPrinter* pInfoPrinter )
+{
+ // create and initialize SalPrinter
+ SalPrinter* pPrinter = new SalPrinter;
+ pPrinter->maPrinterData.m_aJobData = pInfoPrinter->maPrinterData.m_aJobData;
+
+ return pPrinter;
+}
+
+// -----------------------------------------------------------------------
+
+void SalInstance::DestroyPrinter( SalPrinter* pPrinter )
+{
+ delete pPrinter;
+}
+
+// -----------------------------------------------------------------------
+
+void SalInstance::GetPrinterQueueInfo( ImplPrnQueueList* pList )
+{
+ PrinterInfoManager& rManager( PrinterInfoManager::get() );
+ ::std::list< OUString > aPrinters;
+ rManager.listPrinters( aPrinters );
+
+ for( ::std::list< OUString >::iterator it = aPrinters.begin(); it != aPrinters.end(); ++it )
+ {
+ const PrinterInfo& rInfo( rManager.getPrinterInfo( *it ) );
+ // Neuen Eintrag anlegen
+ SalPrinterQueueInfo* pInfo = new SalPrinterQueueInfo;
+ pInfo->maPrinterName = *it;
+ pInfo->maDriver = rInfo.m_aDriverName;
+ pInfo->maLocation = rInfo.m_aLocation;
+ pInfo->maComment = rInfo.m_aComment;
+ pInfo->mpSysData = NULL;
+ pList->Add( pInfo );
+ }
+}
+
+// -----------------------------------------------------------------------
+
+void SalInstance::DeletePrinterQueueInfo( SalPrinterQueueInfo* pInfo )
+{
+ delete pInfo;
+}
+
+// -----------------------------------------------------------------------
+
+void SalInstance::GetPrinterQueueState( SalPrinterQueueInfo* pInfo )
+{
+}
+
+// -----------------------------------------------------------------------
+
+String SalInstance::GetDefaultPrinter()
+{
+ PrinterInfoManager& rManager( PrinterInfoManager::get() );
+ return rManager.getDefaultPrinter();
+}
+
+// =======================================================================
+
+SalInfoPrinter::SalInfoPrinter()
+{
+ maPrinterData.m_pGraphics = NULL;
+}
+
+// -----------------------------------------------------------------------
+
+SalInfoPrinter::~SalInfoPrinter()
+{
+ if( maPrinterData.m_pGraphics )
+ {
+ delete maPrinterData.m_pGraphics;
+ maPrinterData.m_pGraphics = NULL;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+SalGraphics* SalInfoPrinter::GetGraphics()
+{
+ // return a valid pointer only once
+ // the reasoning behind this is that we could have different
+ // SalGraphics that can run in multiple threads
+ // (future plans)
+ SalGraphics* pRet = NULL;
+ if( ! maPrinterData.m_pGraphics )
+ {
+ maPrinterData.m_pGraphics = new SalGraphics;
+ maPrinterData.m_pGraphics->maGraphicsData.m_pJobData = &maPrinterData.m_aJobData;
+ maPrinterData.m_pGraphics->maGraphicsData.m_pPrinterGfx = &maPrinterData.m_aPrinterGfx;
+ pRet = maPrinterData.m_pGraphics;
+ }
+ return pRet;;
+}
+
+// -----------------------------------------------------------------------
+
+void SalInfoPrinter::ReleaseGraphics( SalGraphics* pGraphics )
+{
+ if( pGraphics == maPrinterData.m_pGraphics )
+ {
+ delete pGraphics;
+ maPrinterData.m_pGraphics = NULL;
+ }
+ return;
+}
+
+// -----------------------------------------------------------------------
+
+BOOL SalInfoPrinter::Setup( SalFrame* pFrame, ImplJobSetup* pJobSetup )
+{
+ if( ! pFrame || ! pJobSetup )
+ return FALSE;
+
+ getPaLib();
+
+ if( ! pSetupFunction )
+ return FALSE;
+
+ PrinterInfoManager& rManager = PrinterInfoManager::get();
+
+ PrinterInfo aInfo( rManager.getPrinterInfo( pJobSetup->maPrinterName ) );
+ if ( pJobSetup->mpDriverData )
+ JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aInfo );
+
+ if( pSetupFunction( aInfo ) )
+ {
+ delete pJobSetup->mpDriverData;
+ pJobSetup->mpDriverData = NULL;
+
+ int nBytes;
+ void* pBuffer = NULL;
+ aInfo.getStreamBuffer( pBuffer, nBytes );
+ pJobSetup->mnDriverDataLen = nBytes;
+ pJobSetup->mpDriverData = (BYTE*)pBuffer;
+
+ // copy everything to job setup
+ copyJobDataToJobSetup( pJobSetup, aInfo );
+ }
+
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+// This function gets the driver data and puts it into pJobSetup
+// If pJobSetup->mpDriverData is NOT NULL, then the independend
+// data should be merged into the driver data
+// If pJobSetup->mpDriverData IS NULL, then the driver defaults
+// should be merged into the independent data
+BOOL SalInfoPrinter::SetPrinterData( ImplJobSetup* pJobSetup )
+{
+ if( pJobSetup->mpDriverData )
+ return SetData( ~0, pJobSetup );
+
+ copyJobDataToJobSetup( pJobSetup, maPrinterData.m_aJobData );
+ return TRUE;
+}
+
+// -----------------------------------------------------------------------
+
+// This function merges the independ driver data
+// and sets the new independ data in pJobSetup
+// Only the data must be changed, where the bit
+// in nGetDataFlags is set
+BOOL SalInfoPrinter::SetData(
+ ULONG nSetDataFlags,
+ ImplJobSetup* pJobSetup )
+{
+ JobData aData;
+ JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData );
+
+ if( aData.m_pParser )
+ {
+ const PPDKey* pKey;
+ const PPDValue* pValue;
+
+ // merge papersize if necessary
+ if( nSetDataFlags & SAL_JOBSET_PAPERSIZE )
+ {
+ String aPaper;
+ if( pJobSetup->mePaperFormat == PAPER_USER )
+ aPaper = aData.m_pParser->matchPaper(
+ TenMuToPt( pJobSetup->mnPaperWidth ),
+ TenMuToPt( pJobSetup->mnPaperHeight ) );
+ else
+ aPaper = String( ByteString( aPaperTab[ pJobSetup->mePaperFormat ].name ), RTL_TEXTENCODING_ISO_8859_1 );
+ pKey = aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "PageSize" ) ) );
+ pValue = pKey ? pKey->getValue( aPaper ) : NULL;
+ if( ! ( pKey && pValue && aData.m_aContext.setValue( pKey, pValue, false ) == pValue ) )
+ return FALSE;
+ }
+
+ // merge paperbin if necessary
+ if( nSetDataFlags & SAL_JOBSET_PAPERBIN )
+ {
+ pKey = aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "InputSlot" ) ) );
+ if( pKey )
+ {
+ int nPaperBin = pJobSetup->mnPaperBin;
+ if( nPaperBin == 0xffff )
+ pValue = pKey->getDefaultValue();
+ else
+ {
+ ::std::list< const PPDValue* > aSlots;
+ aData.m_aContext.getUnconstrainedValues( pKey, aSlots );
+ ::std::list< const PPDValue* >::iterator it;
+ for( it = aSlots.begin(); it != aSlots.end() && nPaperBin; ++it, --nPaperBin )
+ ;
+ if( it == aSlots.end() )
+ return FALSE;
+ pValue = *it;
+ }
+ aData.m_aContext.setValue( pKey, pValue );
+ }
+ else
+ return FALSE;
+ }
+
+ // merge orientation if necessary
+ if( nSetDataFlags & SAL_JOBSET_ORIENTATION )
+ aData.m_eOrientation = pJobSetup->meOrientation == ORIENTATION_LANDSCAPE ? orientation::Landscape : orientation::Portrait;
+
+ maPrinterData.m_aJobData = aData;
+ copyJobDataToJobSetup( pJobSetup, aData );
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+// -----------------------------------------------------------------------
+
+void SalInfoPrinter::GetPageInfo(
+ const ImplJobSetup* pJobSetup,
+ long& rOutWidth, long& rOutHeight,
+ long& rPageOffX, long& rPageOffY,
+ long& rPageWidth, long& rPageHeight )
+{
+ if( ! pJobSetup )
+ return;
+
+ JobData aData;
+ JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData );
+
+ // get the selected page size
+ if( aData.m_pParser )
+ {
+
+ String aPaper;
+ int width, height;
+
+ aData.m_aContext.getPageSize( aPaper, width, height );
+
+ int left = 0, top = 0, right = 0, bottom = 0;
+ int nDPIx, nDPIy;
+ aData.m_aContext.getResolution( nDPIx, nDPIy );
+ aData.m_pParser->getMargins( aPaper, left, right, top, bottom );
+ rPageWidth = width * nDPIx / 72;
+ rPageHeight = height * nDPIy / 72;
+ rPageOffX = left * nDPIx / 72;
+ rPageOffY = top * nDPIy / 72;
+ rOutWidth = ( width - left - right ) * nDPIx / 72;
+ rOutHeight = ( height - top - bottom ) * nDPIy / 72;
+ }
+}
+
+// -----------------------------------------------------------------------
+
+ULONG SalInfoPrinter::GetPaperBinCount( const ImplJobSetup* pJobSetup )
+{
+ if( ! pJobSetup )
+ return 0;
+
+ JobData aData;
+ JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData );
+
+ ::std::list< const PPDValue* > aValues;
+ const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "InputSlot" ) ) ): NULL;
+ aData.m_aContext.getUnconstrainedValues( pKey, aValues );
+
+ return aValues.size();
+}
+
+// -----------------------------------------------------------------------
+
+String SalInfoPrinter::GetPaperBinName( const ImplJobSetup* pJobSetup, ULONG nPaperBin )
+{
+ JobData aData;
+ JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, aData );
+
+ String aRet;
+ if( aData.m_pParser )
+ {
+ ::std::list< const PPDValue* > aValues;
+ const PPDKey* pKey = aData.m_pParser ? aData.m_pParser->getKey( String( RTL_CONSTASCII_USTRINGPARAM( "InputSlot" ) ) ): NULL;
+ aData.m_aContext.getUnconstrainedValues( pKey, aValues );
+ if( nPaperBin == 0xffff )
+ aRet = aData.m_pParser->getDefaultInputSlot();
+ else
+ {
+ ::std::list< const PPDValue* >::iterator it;
+ for( it = aValues.begin(); it != aValues.end(); ++it )
+ {
+ if( ! nPaperBin-- )
+ {
+ aRet = String( (*it)->m_aOption );
+ break;
+ }
+ }
+ }
+ }
+
+ return aRet;
+}
+
+// -----------------------------------------------------------------------
+
+ULONG SalInfoPrinter::GetCapabilities( const ImplJobSetup* pJobSetup, USHORT nType )
+{
+ switch( nType )
+ {
+ case PRINTER_CAPABILITIES_SUPPORTDIALOG:
+ return 1;
+ case PRINTER_CAPABILITIES_COPIES:
+ return 0xffff;
+ case PRINTER_CAPABILITIES_COLLATECOPIES:
+ return 0;
+ case PRINTER_CAPABILITIES_SETORIENTATION:
+ return 1;
+ case PRINTER_CAPABILITIES_SETPAPERBIN:
+ return 1;
+ case PRINTER_CAPABILITIES_SETPAPERSIZE:
+ return 1;
+ case PRINTER_CAPABILITIES_SETPAPER:
+ return 0;
+ case PRINTER_CAPABILITIES_FAX:
+ {
+ PrinterInfoManager& rManager = PrinterInfoManager::get();
+ PrinterInfo aInfo( rManager.getPrinterInfo( pJobSetup->maPrinterName ) );
+ String aFeatures( aInfo.m_aFeatures );
+ int nTokenCount = aFeatures.GetTokenCount( ',' );
+ for( int i = 0; i < nTokenCount; i++ )
+ {
+ if( aFeatures.GetToken( i ).EqualsAscii( "fax" ) )
+ return 1;
+ }
+ return 0;
+ }
+ default: break;
+ };
+ return 0;
+}
+
+// =======================================================================
+
+/*
+ * SalPrinter
+ */
+
+SalPrinter::SalPrinter()
+{
+}
+
+// -----------------------------------------------------------------------
+
+SalPrinter::~SalPrinter()
+{
+}
+
+// -----------------------------------------------------------------------
+
+BOOL SalPrinter::StartJob(
+ const XubString* pFileName,
+ const XubString& rJobName,
+ const XubString& rAppName,
+ ULONG nCopies, BOOL bCollate,
+ ImplJobSetup* pJobSetup )
+{
+ maPrinterData.m_bFax = false;
+ maPrinterData.m_aFileName = pFileName ? *pFileName : String();
+
+ // get the job data
+ JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, maPrinterData.m_aJobData );
+
+ // check wether this printer is configured as fax
+ const PrinterInfo& rInfo( PrinterInfoManager::get().getPrinterInfo( maPrinterData.m_aJobData.m_aPrinterName ) );
+ int nTokens = rInfo.m_aFeatures.getTokenCount( ',' );
+ for( int i = 0; i < nTokens; i++ )
+ {
+ if( rInfo.m_aFeatures.getToken( i, ',' ).equalsAsciiL( "fax", 3 ) )
+ {
+ maPrinterData.m_bFax = true;
+ char tmpNam[ L_tmpnam ];
+ tmpnam_r( tmpNam );
+ maPrinterData.m_aFileName = String( ByteString( tmpNam ), gsl_getSystemTextEncoding() );
+
+ ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash >::const_iterator it;
+ it = pJobSetup->maValueMap.find( ::rtl::OUString::createFromAscii( "FAX#" ) );
+ if( it != pJobSetup->maValueMap.end() )
+ maPrinterData.m_aFaxNr = it->second;
+ break;
+ }
+ }
+
+ return maPrinterData.m_aPrintJob.StartJob( maPrinterData.m_aFileName, rJobName, rAppName, maPrinterData.m_aJobData ) ? TRUE : FALSE;
+}
+
+// -----------------------------------------------------------------------
+
+BOOL SalPrinter::EndJob()
+{
+ BOOL bSuccess = maPrinterData.m_aPrintJob.EndJob();
+
+ if( bSuccess )
+ {
+ // check for fax
+ if( maPrinterData.m_bFax )
+ {
+
+ const PrinterInfo& rInfo( PrinterInfoManager::get().getPrinterInfo( maPrinterData.m_aJobData.m_aPrinterName ) );
+ // sendAFax removes the file after use
+ bSuccess = sendAFax( maPrinterData.m_aFaxNr, maPrinterData.m_aFileName, rInfo.m_aCommand );
+ }
+ }
+ return bSuccess;
+}
+
+// -----------------------------------------------------------------------
+
+BOOL SalPrinter::AbortJob()
+{
+ return maPrinterData.m_aPrintJob.AbortJob() ? TRUE : FALSE;
+}
+
+// -----------------------------------------------------------------------
+
+SalGraphics* SalPrinter::StartPage( ImplJobSetup* pJobSetup, BOOL bNewJobData )
+{
+ JobData::constructFromStreamBuffer( pJobSetup->mpDriverData, pJobSetup->mnDriverDataLen, maPrinterData.m_aJobData );
+ maPrinterData.m_pGraphics = new SalGraphics();
+ maPrinterData.m_pGraphics->maGraphicsData.m_pJobData = &maPrinterData.m_aJobData;
+ maPrinterData.m_pGraphics->maGraphicsData.m_pPrinterGfx = &maPrinterData.m_aPrinterGfx;
+
+ maPrinterData.m_aPrintJob.StartPage( maPrinterData.m_aJobData, bNewJobData ? sal_True : sal_False );
+ maPrinterData.m_aPrinterGfx.Init( maPrinterData.m_aPrintJob );
+
+ return maPrinterData.m_pGraphics;
+}
+
+// -----------------------------------------------------------------------
+
+BOOL SalPrinter::EndPage()
+{
+ maPrinterData.m_aPrinterGfx.OnEndPage();
+ sal_Bool bResult = maPrinterData.m_aPrintJob.EndPage();
+ maPrinterData.m_aPrinterGfx.Clear();
+ return bResult ? TRUE : FALSE;
+}
+
+// -----------------------------------------------------------------------
+
+ULONG SalPrinter::GetErrorCode()
+{
+ return 0;
+}