1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir #include <string.h> 29*cdf0e10cSrcweir #include <svpm.h> 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #define _SV_SALGDI_CXX 32*cdf0e10cSrcweir #include <tools/debug.hxx> 33*cdf0e10cSrcweir #include <saldata.hxx> 34*cdf0e10cSrcweir #include <salgdi.h> 35*cdf0e10cSrcweir #include <tools/debug.hxx> 36*cdf0e10cSrcweir #include <salframe.h> 37*cdf0e10cSrcweir #include <tools/poly.hxx> 38*cdf0e10cSrcweir #ifndef _RTL_STRINGBUF_HXX 39*cdf0e10cSrcweir #include <rtl/strbuf.hxx> 40*cdf0e10cSrcweir #endif 41*cdf0e10cSrcweir #include "vcl/region.h" 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir #ifndef __H_FT2LIB 44*cdf0e10cSrcweir #include <wingdi.h> 45*cdf0e10cSrcweir #include <ft2lib.h> 46*cdf0e10cSrcweir #endif 47*cdf0e10cSrcweir 48*cdf0e10cSrcweir // ----------- 49*cdf0e10cSrcweir // - Defines - 50*cdf0e10cSrcweir // ----------- 51*cdf0e10cSrcweir 52*cdf0e10cSrcweir // ClipRegions funktionieren immer noch nicht auf allen getesteten Druckern 53*cdf0e10cSrcweir #define SAL_PRINTER_CLIPPATH 1 54*cdf0e10cSrcweir // #define SAL_PRINTER_POLYPATH 1 55*cdf0e10cSrcweir 56*cdf0e10cSrcweir // ======================================================================= 57*cdf0e10cSrcweir 58*cdf0e10cSrcweir void ImplInitSalGDI() 59*cdf0e10cSrcweir { 60*cdf0e10cSrcweir } 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir // ----------------------------------------------------------------------- 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir void ImplFreeSalGDI() 65*cdf0e10cSrcweir { 66*cdf0e10cSrcweir SalData* pSalData = GetSalData(); 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir // delete icon cache 69*cdf0e10cSrcweir SalIcon* pIcon = pSalData->mpFirstIcon; 70*cdf0e10cSrcweir while( pIcon ) 71*cdf0e10cSrcweir { 72*cdf0e10cSrcweir SalIcon* pTmp = pIcon->pNext; 73*cdf0e10cSrcweir WinDestroyPointer( pIcon->hIcon ); 74*cdf0e10cSrcweir delete pIcon; 75*cdf0e10cSrcweir pIcon = pTmp; 76*cdf0e10cSrcweir } 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir } 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir // ======================================================================= 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir void ImplSalInitGraphics( Os2SalGraphics* pData ) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir GpiCreateLogColorTable( pData->mhPS, LCOL_RESET, LCOLF_RGB, 0, 0, NULL ); 85*cdf0e10cSrcweir } 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir // ----------------------------------------------------------------------- 88*cdf0e10cSrcweir 89*cdf0e10cSrcweir void ImplSalDeInitGraphics( Os2SalGraphics* pData ) 90*cdf0e10cSrcweir { 91*cdf0e10cSrcweir } 92*cdf0e10cSrcweir 93*cdf0e10cSrcweir // ======================================================================= 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir Os2SalGraphics::Os2SalGraphics() 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir for( int i = 0; i < MAX_FALLBACK; ++i ) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir mhFonts[ i ] = 0; 100*cdf0e10cSrcweir mpOs2FontData[ i ] = NULL; 101*cdf0e10cSrcweir mpOs2FontEntry[ i ] = NULL; 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir mfFontScale = 1.0; 105*cdf0e10cSrcweir 106*cdf0e10cSrcweir mhPS = 0; 107*cdf0e10cSrcweir mhDC = 0; 108*cdf0e10cSrcweir mbLine = FALSE; 109*cdf0e10cSrcweir mbFill = FALSE; 110*cdf0e10cSrcweir mbXORMode = FALSE; 111*cdf0e10cSrcweir mnFontMetricCount = 0; 112*cdf0e10cSrcweir mpFontMetrics = NULL; 113*cdf0e10cSrcweir mpClipRectlAry = NULL; 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir mhDefFont = 0; 116*cdf0e10cSrcweir mpFontKernPairs = NULL; 117*cdf0e10cSrcweir mnFontKernPairCount = 0; 118*cdf0e10cSrcweir mbFontKernInit = FALSE; 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir // ----------------------------------------------------------------------- 123*cdf0e10cSrcweir 124*cdf0e10cSrcweir Os2SalGraphics::~Os2SalGraphics() 125*cdf0e10cSrcweir { 126*cdf0e10cSrcweir Ft2DeleteSetId( mhPS, LCID_BASE); 127*cdf0e10cSrcweir 128*cdf0e10cSrcweir if ( mpFontMetrics ) 129*cdf0e10cSrcweir delete mpFontMetrics; 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir if ( mpFontKernPairs ) 132*cdf0e10cSrcweir delete mpFontKernPairs; 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir } 135*cdf0e10cSrcweir 136*cdf0e10cSrcweir // ----------------------------------------------------------------------- 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir static SalColor ImplGetROPSalColor( SalROPColor nROPColor ) 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir SalColor nSalColor; 141*cdf0e10cSrcweir 142*cdf0e10cSrcweir switch( nROPColor ) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir case SAL_ROP_0: 145*cdf0e10cSrcweir nSalColor = MAKE_SALCOLOR( 0, 0, 0 ); 146*cdf0e10cSrcweir break; 147*cdf0e10cSrcweir 148*cdf0e10cSrcweir case SAL_ROP_1: 149*cdf0e10cSrcweir case SAL_ROP_INVERT: 150*cdf0e10cSrcweir nSalColor = MAKE_SALCOLOR( 255, 255, 255 ); 151*cdf0e10cSrcweir break; 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir return nSalColor; 155*cdf0e10cSrcweir } 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir // ----------------------------------------------------------------------- 158*cdf0e10cSrcweir 159*cdf0e10cSrcweir void Os2SalGraphics::GetResolution( long& rDPIX, long& rDPIY ) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir // since OOo asks for DPI, I will query FONT_RES, which seems to be 162*cdf0e10cSrcweir // more correct than _RESOLUTION fields (on my wide screen lcd) 163*cdf0e10cSrcweir // and does not require conversion 164*cdf0e10cSrcweir DevQueryCaps( mhDC, CAPS_HORIZONTAL_FONT_RES, 1, &rDPIX ); 165*cdf0e10cSrcweir DevQueryCaps( mhDC, CAPS_VERTICAL_FONT_RES, 1, &rDPIY ); 166*cdf0e10cSrcweir } 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir // ----------------------------------------------------------------------- 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir USHORT Os2SalGraphics::GetBitCount() 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir LONG nBitCount; 173*cdf0e10cSrcweir DevQueryCaps( mhDC, CAPS_COLOR_BITCOUNT, 1, &nBitCount ); 174*cdf0e10cSrcweir return (USHORT)nBitCount; 175*cdf0e10cSrcweir } 176*cdf0e10cSrcweir 177*cdf0e10cSrcweir // ----------------------------------------------------------------------- 178*cdf0e10cSrcweir 179*cdf0e10cSrcweir long Os2SalGraphics::GetGraphicsWidth() const 180*cdf0e10cSrcweir { 181*cdf0e10cSrcweir if( mhWnd ) 182*cdf0e10cSrcweir { 183*cdf0e10cSrcweir Os2SalFrame* pFrame = (Os2SalFrame*)GetWindowPtr( mhWnd ); 184*cdf0e10cSrcweir if( pFrame ) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir if( pFrame->maGeometry.nWidth ) 187*cdf0e10cSrcweir return pFrame->maGeometry.nWidth; 188*cdf0e10cSrcweir else 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir // TODO: perhaps not needed, maGeometry should always be up-to-date 191*cdf0e10cSrcweir RECTL aRect; 192*cdf0e10cSrcweir WinQueryWindowRect( mhWnd, &aRect ); 193*cdf0e10cSrcweir return aRect.xRight; 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir } 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir return 0; 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir // ----------------------------------------------------------------------- 202*cdf0e10cSrcweir 203*cdf0e10cSrcweir void Os2SalGraphics::ResetClipRegion() 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir #ifdef SAL_PRINTER_CLIPPATH 206*cdf0e10cSrcweir if ( mbPrinter ) 207*cdf0e10cSrcweir GpiSetClipPath( mhPS, 0, SCP_RESET ); 208*cdf0e10cSrcweir else 209*cdf0e10cSrcweir #endif 210*cdf0e10cSrcweir { 211*cdf0e10cSrcweir HRGN hOldRegion; 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir GpiSetClipRegion( mhPS, NULL, &hOldRegion ); 214*cdf0e10cSrcweir if ( hOldRegion ) 215*cdf0e10cSrcweir GpiDestroyRegion( mhPS, hOldRegion ); 216*cdf0e10cSrcweir } 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir // ----------------------------------------------------------------------- 220*cdf0e10cSrcweir 221*cdf0e10cSrcweir bool Os2SalGraphics::setClipRegion( const Region& i_rClip ) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir ULONG nCount = i_rClip.GetRectCount(); 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir mpClipRectlAry = new RECTL[ nCount ]; 226*cdf0e10cSrcweir mnClipElementCount = 0; 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir ImplRegionInfo aInfo; 229*cdf0e10cSrcweir long nX, nY, nW, nH; 230*cdf0e10cSrcweir bool bRegionRect = i_rClip.ImplGetFirstRect(aInfo, nX, nY, nW, nH ); 231*cdf0e10cSrcweir while( bRegionRect ) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir if ( nW && nH ) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir RECTL* pClipRect = &mpClipRectlAry[ mnClipElementCount ]; 236*cdf0e10cSrcweir pClipRect->xLeft = nX; 237*cdf0e10cSrcweir pClipRect->yTop = mnHeight - nY; 238*cdf0e10cSrcweir pClipRect->xRight = nX + nW; 239*cdf0e10cSrcweir pClipRect->yBottom = mnHeight - (nY + nH); 240*cdf0e10cSrcweir mnClipElementCount++; 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir bRegionRect = i_rClip.ImplGetNextRect( aInfo, nX, nY, nW, nH ); 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir #ifdef SAL_PRINTER_CLIPPATH 245*cdf0e10cSrcweir if ( mbPrinter ) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir GpiSetClipPath( mhPS, 0, SCP_RESET ); 248*cdf0e10cSrcweir GpiBeginPath( mhPS, 1L ); 249*cdf0e10cSrcweir 250*cdf0e10cSrcweir for( int i = 0; i < mnClipElementCount; i++ ) 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir POINTL aPt; 253*cdf0e10cSrcweir RECTL* pClipRect = &mpClipRectlAry[ i ]; 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir aPt.x = pClipRect->xLeft; 256*cdf0e10cSrcweir aPt.y = pClipRect->yTop-1; 257*cdf0e10cSrcweir Ft2Move( mhPS, &aPt ); 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir aPt.x = pClipRect->xRight-1; 260*cdf0e10cSrcweir aPt.y = pClipRect->yBottom; 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir Ft2Box( mhPS, DRO_OUTLINE, &aPt, 0, 0 ); 263*cdf0e10cSrcweir } 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir GpiEndPath( mhPS ); 266*cdf0e10cSrcweir GpiSetClipPath( mhPS, 1L, SCP_ALTERNATE | SCP_AND ); 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir else 269*cdf0e10cSrcweir #endif 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir HRGN hClipRegion = GpiCreateRegion( mhPS, 272*cdf0e10cSrcweir mnClipElementCount, 273*cdf0e10cSrcweir mpClipRectlAry ); 274*cdf0e10cSrcweir HRGN hOldRegion; 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir GpiSetClipRegion( mhPS, hClipRegion, &hOldRegion ); 277*cdf0e10cSrcweir if( hOldRegion ) 278*cdf0e10cSrcweir GpiDestroyRegion( mhPS, hOldRegion ); 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir 281*cdf0e10cSrcweir delete [] mpClipRectlAry; 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir return true; 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir // ----------------------------------------------------------------------- 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir void Os2SalGraphics::SetLineColor() 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir // don't draw line! 291*cdf0e10cSrcweir mbLine = FALSE; 292*cdf0e10cSrcweir } 293*cdf0e10cSrcweir 294*cdf0e10cSrcweir // ----------------------------------------------------------------------- 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir void Os2SalGraphics::SetLineColor( SalColor nSalColor ) 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir LINEBUNDLE lb; 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir // set color 301*cdf0e10cSrcweir lb.lColor = RGBCOLOR( SALCOLOR_RED( nSalColor ), 302*cdf0e10cSrcweir SALCOLOR_GREEN( nSalColor ), 303*cdf0e10cSrcweir SALCOLOR_BLUE( nSalColor ) ); 304*cdf0e10cSrcweir 305*cdf0e10cSrcweir Ft2SetAttrs( mhPS, 306*cdf0e10cSrcweir PRIM_LINE, 307*cdf0e10cSrcweir LBB_COLOR, 308*cdf0e10cSrcweir 0, 309*cdf0e10cSrcweir &lb ); 310*cdf0e10cSrcweir 311*cdf0e10cSrcweir // draw line! 312*cdf0e10cSrcweir mbLine = TRUE; 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir 315*cdf0e10cSrcweir // ----------------------------------------------------------------------- 316*cdf0e10cSrcweir 317*cdf0e10cSrcweir void Os2SalGraphics::SetFillColor() 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir // don't fill area! 320*cdf0e10cSrcweir mbFill = FALSE; 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir // ----------------------------------------------------------------------- 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir void Os2SalGraphics::SetFillColor( SalColor nSalColor ) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir AREABUNDLE ab; 328*cdf0e10cSrcweir 329*cdf0e10cSrcweir // set color 330*cdf0e10cSrcweir ab.lColor = RGBCOLOR( SALCOLOR_RED( nSalColor ), 331*cdf0e10cSrcweir SALCOLOR_GREEN( nSalColor ), 332*cdf0e10cSrcweir SALCOLOR_BLUE( nSalColor ) ); 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir Ft2SetAttrs( mhPS, 335*cdf0e10cSrcweir PRIM_AREA, 336*cdf0e10cSrcweir ABB_COLOR, 337*cdf0e10cSrcweir 0, 338*cdf0e10cSrcweir &ab ); 339*cdf0e10cSrcweir 340*cdf0e10cSrcweir // fill area! 341*cdf0e10cSrcweir mbFill = TRUE; 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir 344*cdf0e10cSrcweir // ----------------------------------------------------------------------- 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir void Os2SalGraphics::SetXORMode( bool bSet, bool ) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir mbXORMode = bSet; 349*cdf0e10cSrcweir LONG nMixMode = bSet ? FM_XOR : FM_OVERPAINT; 350*cdf0e10cSrcweir 351*cdf0e10cSrcweir // set mix mode for lines 352*cdf0e10cSrcweir LINEBUNDLE lb; 353*cdf0e10cSrcweir lb.usMixMode = nMixMode; 354*cdf0e10cSrcweir Ft2SetAttrs( mhPS, 355*cdf0e10cSrcweir PRIM_LINE, 356*cdf0e10cSrcweir LBB_MIX_MODE, 357*cdf0e10cSrcweir 0, 358*cdf0e10cSrcweir &lb ); 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir // set mix mode for areas 361*cdf0e10cSrcweir AREABUNDLE ab; 362*cdf0e10cSrcweir ab.usMixMode = nMixMode; 363*cdf0e10cSrcweir Ft2SetAttrs( mhPS, 364*cdf0e10cSrcweir PRIM_AREA, 365*cdf0e10cSrcweir ABB_MIX_MODE, 366*cdf0e10cSrcweir 0, 367*cdf0e10cSrcweir &ab ); 368*cdf0e10cSrcweir 369*cdf0e10cSrcweir // set mix mode for text 370*cdf0e10cSrcweir CHARBUNDLE cb; 371*cdf0e10cSrcweir cb.usMixMode = nMixMode; 372*cdf0e10cSrcweir Ft2SetAttrs( mhPS, 373*cdf0e10cSrcweir PRIM_CHAR, 374*cdf0e10cSrcweir CBB_MIX_MODE, 375*cdf0e10cSrcweir 0, 376*cdf0e10cSrcweir &cb ); 377*cdf0e10cSrcweir } 378*cdf0e10cSrcweir 379*cdf0e10cSrcweir // ----------------------------------------------------------------------- 380*cdf0e10cSrcweir 381*cdf0e10cSrcweir void Os2SalGraphics::SetROPLineColor( SalROPColor nROPColor ) 382*cdf0e10cSrcweir { 383*cdf0e10cSrcweir SetLineColor( ImplGetROPSalColor( nROPColor ) ); 384*cdf0e10cSrcweir } 385*cdf0e10cSrcweir 386*cdf0e10cSrcweir // ----------------------------------------------------------------------- 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir void Os2SalGraphics::SetROPFillColor( SalROPColor nROPColor ) 389*cdf0e10cSrcweir { 390*cdf0e10cSrcweir SetFillColor( ImplGetROPSalColor( nROPColor ) ); 391*cdf0e10cSrcweir } 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir // ----------------------------------------------------------------------- 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir void Os2SalGraphics::drawPixel( long nX, long nY ) 396*cdf0e10cSrcweir { 397*cdf0e10cSrcweir POINTL aPt; 398*cdf0e10cSrcweir 399*cdf0e10cSrcweir aPt.x = nX; 400*cdf0e10cSrcweir aPt.y = TY( nY ); 401*cdf0e10cSrcweir 402*cdf0e10cSrcweir // set color 403*cdf0e10cSrcweir Ft2SetPel( mhPS, &aPt ); 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir // ----------------------------------------------------------------------- 407*cdf0e10cSrcweir 408*cdf0e10cSrcweir void Os2SalGraphics::drawPixel( long nX, long nY, SalColor nSalColor ) 409*cdf0e10cSrcweir { 410*cdf0e10cSrcweir // save old color 411*cdf0e10cSrcweir LINEBUNDLE oldLb; 412*cdf0e10cSrcweir GpiQueryAttrs( mhPS, 413*cdf0e10cSrcweir PRIM_LINE, 414*cdf0e10cSrcweir LBB_COLOR, 415*cdf0e10cSrcweir &oldLb ); 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir // set new color 418*cdf0e10cSrcweir LINEBUNDLE lb; 419*cdf0e10cSrcweir lb.lColor = RGBCOLOR( SALCOLOR_RED( nSalColor ), 420*cdf0e10cSrcweir SALCOLOR_GREEN( nSalColor ), 421*cdf0e10cSrcweir SALCOLOR_BLUE( nSalColor ) ); 422*cdf0e10cSrcweir Ft2SetAttrs( mhPS, 423*cdf0e10cSrcweir PRIM_LINE, 424*cdf0e10cSrcweir LBB_COLOR, 425*cdf0e10cSrcweir 0, 426*cdf0e10cSrcweir &lb ); 427*cdf0e10cSrcweir 428*cdf0e10cSrcweir // set color of pixel 429*cdf0e10cSrcweir POINTL aPt; 430*cdf0e10cSrcweir aPt.x = nX; 431*cdf0e10cSrcweir aPt.y = TY( nY ); 432*cdf0e10cSrcweir Ft2SetPel( mhPS, &aPt ); 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir // restore old color 435*cdf0e10cSrcweir Ft2SetAttrs( mhPS, 436*cdf0e10cSrcweir PRIM_LINE, 437*cdf0e10cSrcweir LBB_COLOR, 438*cdf0e10cSrcweir 0, 439*cdf0e10cSrcweir &oldLb ); 440*cdf0e10cSrcweir } 441*cdf0e10cSrcweir 442*cdf0e10cSrcweir // ----------------------------------------------------------------------- 443*cdf0e10cSrcweir 444*cdf0e10cSrcweir void Os2SalGraphics::drawLine( long nX1, long nY1, long nX2, long nY2 ) 445*cdf0e10cSrcweir { 446*cdf0e10cSrcweir // OS2 zeichnet den Endpunkt mit 447*cdf0e10cSrcweir POINTL aPt; 448*cdf0e10cSrcweir aPt.x = nX1; 449*cdf0e10cSrcweir aPt.y = TY( nY1 ); 450*cdf0e10cSrcweir Ft2Move( mhPS, &aPt ); 451*cdf0e10cSrcweir aPt.x = nX2; 452*cdf0e10cSrcweir aPt.y = TY( nY2 ); 453*cdf0e10cSrcweir GpiLine( mhPS, &aPt ); 454*cdf0e10cSrcweir } 455*cdf0e10cSrcweir 456*cdf0e10cSrcweir // ----------------------------------------------------------------------- 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir void Os2SalGraphics::drawRect( long nX, long nY, long nWidth, long nHeight ) 459*cdf0e10cSrcweir { 460*cdf0e10cSrcweir POINTL aPt; 461*cdf0e10cSrcweir long lControl; 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir if ( mbFill ) 464*cdf0e10cSrcweir { 465*cdf0e10cSrcweir if ( mbLine ) 466*cdf0e10cSrcweir lControl = DRO_OUTLINEFILL; 467*cdf0e10cSrcweir else 468*cdf0e10cSrcweir lControl = DRO_FILL; 469*cdf0e10cSrcweir } 470*cdf0e10cSrcweir else 471*cdf0e10cSrcweir { 472*cdf0e10cSrcweir if ( mbLine ) 473*cdf0e10cSrcweir lControl = DRO_OUTLINE; 474*cdf0e10cSrcweir else 475*cdf0e10cSrcweir return; 476*cdf0e10cSrcweir } 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir aPt.x = nX; 479*cdf0e10cSrcweir aPt.y = TY( nY ); 480*cdf0e10cSrcweir Ft2Move( mhPS, &aPt ); 481*cdf0e10cSrcweir aPt.x = nX + nWidth - 1; 482*cdf0e10cSrcweir aPt.y = TY( nY + nHeight - 1 ); 483*cdf0e10cSrcweir Ft2Box( mhPS, lControl, &aPt, 0, 0 ); 484*cdf0e10cSrcweir } 485*cdf0e10cSrcweir 486*cdf0e10cSrcweir // ----------------------------------------------------------------------- 487*cdf0e10cSrcweir 488*cdf0e10cSrcweir void Os2SalGraphics::drawPolyLine( ULONG nPoints, const SalPoint* pPtAry ) 489*cdf0e10cSrcweir { 490*cdf0e10cSrcweir // convert all points to sys orientation 491*cdf0e10cSrcweir POINTL* pOS2PtAry = new POINTL[ nPoints ]; 492*cdf0e10cSrcweir POINTL* pTempOS2PtAry = pOS2PtAry; 493*cdf0e10cSrcweir const SalPoint* pTempPtAry = pPtAry; 494*cdf0e10cSrcweir ULONG nTempPoints = nPoints; 495*cdf0e10cSrcweir long nHeight = mnHeight - 1; 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir while( nTempPoints-- ) 498*cdf0e10cSrcweir { 499*cdf0e10cSrcweir (*pTempOS2PtAry).x = (*pTempPtAry).mnX; 500*cdf0e10cSrcweir (*pTempOS2PtAry).y = nHeight - (*pTempPtAry).mnY; 501*cdf0e10cSrcweir pTempOS2PtAry++; 502*cdf0e10cSrcweir pTempPtAry++; 503*cdf0e10cSrcweir } 504*cdf0e10cSrcweir 505*cdf0e10cSrcweir Ft2Move( mhPS, pOS2PtAry ); 506*cdf0e10cSrcweir GpiPolyLine( mhPS, nPoints, pOS2PtAry ); 507*cdf0e10cSrcweir delete [] pOS2PtAry; 508*cdf0e10cSrcweir } 509*cdf0e10cSrcweir 510*cdf0e10cSrcweir // ----------------------------------------------------------------------- 511*cdf0e10cSrcweir 512*cdf0e10cSrcweir void Os2SalGraphics::drawPolygon( ULONG nPoints, const SalPoint* pPtAry ) 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir PM_POLYGON aPolygon; 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir // create polygon 517*cdf0e10cSrcweir aPolygon.aPointl = new POINTL[ nPoints ]; 518*cdf0e10cSrcweir aPolygon.ulPoints = nPoints; 519*cdf0e10cSrcweir 520*cdf0e10cSrcweir // convert all points to sys orientation 521*cdf0e10cSrcweir POINTL* pTempOS2PtAry = aPolygon.aPointl; 522*cdf0e10cSrcweir const SalPoint* pTempPtAry = pPtAry; 523*cdf0e10cSrcweir ULONG nTempPoints = nPoints; 524*cdf0e10cSrcweir long nHeight = mnHeight - 1; 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir while( nTempPoints-- ) 527*cdf0e10cSrcweir { 528*cdf0e10cSrcweir (*pTempOS2PtAry).x = (*pTempPtAry).mnX; 529*cdf0e10cSrcweir (*pTempOS2PtAry).y = nHeight - (*pTempPtAry).mnY; 530*cdf0e10cSrcweir pTempOS2PtAry++; 531*cdf0e10cSrcweir pTempPtAry++; 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir // Innenleben zeichnen 535*cdf0e10cSrcweir if ( mbFill ) 536*cdf0e10cSrcweir { 537*cdf0e10cSrcweir #ifdef SAL_PRINTER_POLYPATH 538*cdf0e10cSrcweir if ( mbPrinter ) 539*cdf0e10cSrcweir { 540*cdf0e10cSrcweir Ft2BeginPath( mhPS, 1 ); 541*cdf0e10cSrcweir Ft2Move( mhPS, aPolygon.aPointl ); 542*cdf0e10cSrcweir Ft2PolyLine( mhPS, aPolygon.ulPoints, aPolygon.aPointl ); 543*cdf0e10cSrcweir Ft2EndPath( mhPS ); 544*cdf0e10cSrcweir Ft2FillPath( mhPS, 1, 0 ); 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir if ( mbLine ) 547*cdf0e10cSrcweir { 548*cdf0e10cSrcweir Ft2Move( mhPS, aPolygon.aPointl ); 549*cdf0e10cSrcweir Ft2PolyLine( mhPS, aPolygon.ulPoints, aPolygon.aPointl ); 550*cdf0e10cSrcweir } 551*cdf0e10cSrcweir } 552*cdf0e10cSrcweir else 553*cdf0e10cSrcweir #endif 554*cdf0e10cSrcweir { 555*cdf0e10cSrcweir ULONG nOptions = POLYGON_ALTERNATE; 556*cdf0e10cSrcweir 557*cdf0e10cSrcweir if ( mbLine ) 558*cdf0e10cSrcweir nOptions |= POLYGON_BOUNDARY; 559*cdf0e10cSrcweir else 560*cdf0e10cSrcweir nOptions |= POLYGON_NOBOUNDARY; 561*cdf0e10cSrcweir 562*cdf0e10cSrcweir Ft2Move( mhPS, aPolygon.aPointl ); 563*cdf0e10cSrcweir GpiPolygons( mhPS, 1, &aPolygon, nOptions, POLYGON_EXCL ); 564*cdf0e10cSrcweir } 565*cdf0e10cSrcweir } 566*cdf0e10cSrcweir else 567*cdf0e10cSrcweir { 568*cdf0e10cSrcweir if ( mbLine ) 569*cdf0e10cSrcweir { 570*cdf0e10cSrcweir Ft2Move( mhPS, aPolygon.aPointl ); 571*cdf0e10cSrcweir GpiPolyLine( mhPS, nPoints, aPolygon.aPointl ); 572*cdf0e10cSrcweir } 573*cdf0e10cSrcweir } 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir delete [] aPolygon.aPointl; 576*cdf0e10cSrcweir } 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir // ----------------------------------------------------------------------- 579*cdf0e10cSrcweir 580*cdf0e10cSrcweir void Os2SalGraphics::drawPolyPolygon( ULONG nPoly, const ULONG* pPoints, 581*cdf0e10cSrcweir PCONSTSALPOINT* pPtAry ) 582*cdf0e10cSrcweir { 583*cdf0e10cSrcweir ULONG i; 584*cdf0e10cSrcweir long nHeight = mnHeight - 1; 585*cdf0e10cSrcweir PM_POLYGON* aPolygonAry = new PM_POLYGON[ nPoly ]; 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir for( i = 0; i < nPoly; i++ ) 588*cdf0e10cSrcweir { 589*cdf0e10cSrcweir const SalPoint * pTempPtAry = (const SalPoint*)pPtAry[ i ]; 590*cdf0e10cSrcweir 591*cdf0e10cSrcweir // create polygon 592*cdf0e10cSrcweir ULONG nTempPoints = pPoints[ i ]; 593*cdf0e10cSrcweir POINTL * pTempOS2PtAry = new POINTL[ nTempPoints ]; 594*cdf0e10cSrcweir 595*cdf0e10cSrcweir // convert all points to sys orientation 596*cdf0e10cSrcweir aPolygonAry[ i ].ulPoints = nTempPoints; 597*cdf0e10cSrcweir aPolygonAry[ i ].aPointl = pTempOS2PtAry; 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir while( nTempPoints-- ) 600*cdf0e10cSrcweir { 601*cdf0e10cSrcweir (*pTempOS2PtAry).x = (*pTempPtAry).mnX; 602*cdf0e10cSrcweir (*pTempOS2PtAry).y = nHeight - (*pTempPtAry).mnY; 603*cdf0e10cSrcweir pTempOS2PtAry++; 604*cdf0e10cSrcweir pTempPtAry++; 605*cdf0e10cSrcweir } 606*cdf0e10cSrcweir } 607*cdf0e10cSrcweir 608*cdf0e10cSrcweir // Innenleben zeichnen 609*cdf0e10cSrcweir if ( mbFill ) 610*cdf0e10cSrcweir { 611*cdf0e10cSrcweir #ifdef SAL_PRINTER_POLYPATH 612*cdf0e10cSrcweir if ( mbPrinter ) 613*cdf0e10cSrcweir { 614*cdf0e10cSrcweir Ft2BeginPath( mhPS, 1 ); 615*cdf0e10cSrcweir for ( i = 0; i < nPoly; i++ ) 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir Ft2Move( mhPS, aPolygonAry[i].aPointl ); 618*cdf0e10cSrcweir Ft2PolyLine( mhPS, aPolygonAry[i].ulPoints, aPolygonAry[i].aPointl ); 619*cdf0e10cSrcweir } 620*cdf0e10cSrcweir Ft2EndPath( mhPS ); 621*cdf0e10cSrcweir Ft2FillPath( mhPS, 1, 0 ); 622*cdf0e10cSrcweir } 623*cdf0e10cSrcweir else 624*cdf0e10cSrcweir #endif 625*cdf0e10cSrcweir { 626*cdf0e10cSrcweir ULONG nOptions = POLYGON_ALTERNATE; 627*cdf0e10cSrcweir 628*cdf0e10cSrcweir if ( mbLine ) 629*cdf0e10cSrcweir nOptions |= POLYGON_BOUNDARY; 630*cdf0e10cSrcweir else 631*cdf0e10cSrcweir nOptions |= POLYGON_NOBOUNDARY; 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir Ft2Move( mhPS, aPolygonAry[ 0 ].aPointl ); 634*cdf0e10cSrcweir GpiPolygons( mhPS, nPoly, aPolygonAry, nOptions, POLYGON_EXCL ); 635*cdf0e10cSrcweir } 636*cdf0e10cSrcweir } 637*cdf0e10cSrcweir else 638*cdf0e10cSrcweir { 639*cdf0e10cSrcweir if ( mbLine ) 640*cdf0e10cSrcweir { 641*cdf0e10cSrcweir for( i = 0; i < nPoly; i++ ) 642*cdf0e10cSrcweir { 643*cdf0e10cSrcweir Ft2Move( mhPS, aPolygonAry[ i ].aPointl ); 644*cdf0e10cSrcweir GpiPolyLine( mhPS, aPolygonAry[ i ].ulPoints, aPolygonAry[ i ].aPointl ); 645*cdf0e10cSrcweir } 646*cdf0e10cSrcweir } 647*cdf0e10cSrcweir } 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir // cleanup 650*cdf0e10cSrcweir for( i = 0; i < nPoly; i++ ) 651*cdf0e10cSrcweir delete [] aPolygonAry[ i ].aPointl; 652*cdf0e10cSrcweir delete [] aPolygonAry; 653*cdf0e10cSrcweir } 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir // ----------------------------------------------------------------------- 656*cdf0e10cSrcweir 657*cdf0e10cSrcweir bool Os2SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double /*fTransparency*/ ) 658*cdf0e10cSrcweir { 659*cdf0e10cSrcweir // TODO: implement and advertise OutDevSupport_B2DDraw support 660*cdf0e10cSrcweir return false; 661*cdf0e10cSrcweir } 662*cdf0e10cSrcweir 663*cdf0e10cSrcweir // ----------------------------------------------------------------------- 664*cdf0e10cSrcweir 665*cdf0e10cSrcweir bool Os2SalGraphics::drawPolyLine( 666*cdf0e10cSrcweir const basegfx::B2DPolygon& /*rPolygon*/, 667*cdf0e10cSrcweir double /*fTransparency*/, 668*cdf0e10cSrcweir const basegfx::B2DVector& /*rLineWidths*/, 669*cdf0e10cSrcweir basegfx::B2DLineJoin /*eLineJoin*/) 670*cdf0e10cSrcweir { 671*cdf0e10cSrcweir // TODO: implement 672*cdf0e10cSrcweir return false; 673*cdf0e10cSrcweir } 674*cdf0e10cSrcweir 675*cdf0e10cSrcweir // ----------------------------------------------------------------------- 676*cdf0e10cSrcweir 677*cdf0e10cSrcweir sal_Bool Os2SalGraphics::drawPolyLineBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry ) 678*cdf0e10cSrcweir { 679*cdf0e10cSrcweir return sal_False; 680*cdf0e10cSrcweir } 681*cdf0e10cSrcweir 682*cdf0e10cSrcweir // ----------------------------------------------------------------------- 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir sal_Bool Os2SalGraphics::drawPolygonBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry ) 685*cdf0e10cSrcweir { 686*cdf0e10cSrcweir return sal_False; 687*cdf0e10cSrcweir } 688*cdf0e10cSrcweir 689*cdf0e10cSrcweir // ----------------------------------------------------------------------- 690*cdf0e10cSrcweir 691*cdf0e10cSrcweir sal_Bool Os2SalGraphics::drawPolyPolygonBezier( ULONG nPoly, const ULONG* pPoints, 692*cdf0e10cSrcweir const SalPoint* const* pPtAry, const BYTE* const* pFlgAry ) 693*cdf0e10cSrcweir { 694*cdf0e10cSrcweir return sal_False; 695*cdf0e10cSrcweir } 696*cdf0e10cSrcweir 697*cdf0e10cSrcweir // ======================================================================= 698*cdf0e10cSrcweir 699*cdf0e10cSrcweir // MAXIMUM BUFSIZE EQ 0xFFFF 700*cdf0e10cSrcweir #define POSTSCRIPT_BUFSIZE 0x4000 701*cdf0e10cSrcweir // we only try to get the BoundingBox in the first 4096 bytes 702*cdf0e10cSrcweir #define POSTSCRIPT_BOUNDINGSEARCH 0x1000 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir static BYTE* ImplSearchEntry( BYTE* pSource, BYTE* pDest, ULONG nComp, ULONG nSize ) 705*cdf0e10cSrcweir { 706*cdf0e10cSrcweir while ( nComp-- >= nSize ) 707*cdf0e10cSrcweir { 708*cdf0e10cSrcweir ULONG i; 709*cdf0e10cSrcweir for ( i = 0; i < nSize; i++ ) 710*cdf0e10cSrcweir { 711*cdf0e10cSrcweir if ( ( pSource[i]&~0x20 ) != ( pDest[i]&~0x20 ) ) 712*cdf0e10cSrcweir break; 713*cdf0e10cSrcweir } 714*cdf0e10cSrcweir if ( i == nSize ) 715*cdf0e10cSrcweir return pSource; 716*cdf0e10cSrcweir pSource++; 717*cdf0e10cSrcweir } 718*cdf0e10cSrcweir return NULL; 719*cdf0e10cSrcweir } 720*cdf0e10cSrcweir 721*cdf0e10cSrcweir 722*cdf0e10cSrcweir static BOOL ImplGetBoundingBox( double* nNumb, BYTE* pSource, ULONG nSize ) 723*cdf0e10cSrcweir { 724*cdf0e10cSrcweir BOOL bRetValue = FALSE; 725*cdf0e10cSrcweir BYTE* pDest = ImplSearchEntry( pSource, (BYTE*)"%%BoundingBox:", nSize, 14 ); 726*cdf0e10cSrcweir if ( pDest ) 727*cdf0e10cSrcweir { 728*cdf0e10cSrcweir nNumb[0] = nNumb[1] = nNumb[2] = nNumb[3] = 0; 729*cdf0e10cSrcweir pDest += 14; 730*cdf0e10cSrcweir 731*cdf0e10cSrcweir int nSizeLeft = nSize - ( pDest - pSource ); 732*cdf0e10cSrcweir if ( nSizeLeft > 100 ) 733*cdf0e10cSrcweir nSizeLeft = 100; // only 100 bytes following the bounding box will be checked 734*cdf0e10cSrcweir 735*cdf0e10cSrcweir int i; 736*cdf0e10cSrcweir for ( i = 0; ( i < 4 ) && nSizeLeft; i++ ) 737*cdf0e10cSrcweir { 738*cdf0e10cSrcweir int nDivision = 1; 739*cdf0e10cSrcweir BOOL bDivision = FALSE; 740*cdf0e10cSrcweir BOOL bNegative = FALSE; 741*cdf0e10cSrcweir BOOL bValid = TRUE; 742*cdf0e10cSrcweir 743*cdf0e10cSrcweir while ( ( --nSizeLeft ) && ( *pDest == ' ' ) || ( *pDest == 0x9 ) ) pDest++; 744*cdf0e10cSrcweir BYTE nByte = *pDest; 745*cdf0e10cSrcweir while ( nSizeLeft && ( nByte != ' ' ) && ( nByte != 0x9 ) && ( nByte != 0xd ) && ( nByte != 0xa ) ) 746*cdf0e10cSrcweir { 747*cdf0e10cSrcweir switch ( nByte ) 748*cdf0e10cSrcweir { 749*cdf0e10cSrcweir case '.' : 750*cdf0e10cSrcweir if ( bDivision ) 751*cdf0e10cSrcweir bValid = FALSE; 752*cdf0e10cSrcweir else 753*cdf0e10cSrcweir bDivision = TRUE; 754*cdf0e10cSrcweir break; 755*cdf0e10cSrcweir case '-' : 756*cdf0e10cSrcweir bNegative = TRUE; 757*cdf0e10cSrcweir break; 758*cdf0e10cSrcweir default : 759*cdf0e10cSrcweir if ( ( nByte < '0' ) || ( nByte > '9' ) ) 760*cdf0e10cSrcweir nSizeLeft = 1; // error parsing the bounding box values 761*cdf0e10cSrcweir else if ( bValid ) 762*cdf0e10cSrcweir { 763*cdf0e10cSrcweir if ( bDivision ) 764*cdf0e10cSrcweir nDivision*=10; 765*cdf0e10cSrcweir nNumb[i] *= 10; 766*cdf0e10cSrcweir nNumb[i] += nByte - '0'; 767*cdf0e10cSrcweir } 768*cdf0e10cSrcweir break; 769*cdf0e10cSrcweir } 770*cdf0e10cSrcweir nSizeLeft--; 771*cdf0e10cSrcweir nByte = *(++pDest); 772*cdf0e10cSrcweir } 773*cdf0e10cSrcweir if ( bNegative ) 774*cdf0e10cSrcweir nNumb[i] = -nNumb[i]; 775*cdf0e10cSrcweir if ( bDivision && ( nDivision != 1 ) ) 776*cdf0e10cSrcweir nNumb[i] /= nDivision; 777*cdf0e10cSrcweir } 778*cdf0e10cSrcweir if ( i == 4 ) 779*cdf0e10cSrcweir bRetValue = TRUE; 780*cdf0e10cSrcweir } 781*cdf0e10cSrcweir return bRetValue; 782*cdf0e10cSrcweir } 783*cdf0e10cSrcweir 784*cdf0e10cSrcweir #if 0 785*cdf0e10cSrcweir static void ImplWriteDouble( BYTE** pBuf, double nNumber ) 786*cdf0e10cSrcweir { 787*cdf0e10cSrcweir // *pBuf += sprintf( (char*)*pBuf, "%f", nNumber ); 788*cdf0e10cSrcweir 789*cdf0e10cSrcweir if ( nNumber < 0 ) 790*cdf0e10cSrcweir { 791*cdf0e10cSrcweir *(*pBuf)++ = (BYTE)'-'; 792*cdf0e10cSrcweir nNumber = -nNumber; 793*cdf0e10cSrcweir } 794*cdf0e10cSrcweir ULONG nTemp = (ULONG)nNumber; 795*cdf0e10cSrcweir const String aNumber1( nTemp ); 796*cdf0e10cSrcweir ULONG nLen = aNumber1.Len(); 797*cdf0e10cSrcweir 798*cdf0e10cSrcweir for ( USHORT n = 0; n < nLen; n++ ) 799*cdf0e10cSrcweir *(*pBuf)++ = aNumber1[ n ]; 800*cdf0e10cSrcweir 801*cdf0e10cSrcweir nTemp = (ULONG)( ( nNumber - nTemp ) * 100000 ); 802*cdf0e10cSrcweir if ( nTemp ) 803*cdf0e10cSrcweir { 804*cdf0e10cSrcweir *(*pBuf)++ = (BYTE)'.'; 805*cdf0e10cSrcweir const String aNumber2( nTemp ); 806*cdf0e10cSrcweir 807*cdf0e10cSrcweir ULONG nLen = aNumber2.Len(); 808*cdf0e10cSrcweir if ( nLen < 8 ) 809*cdf0e10cSrcweir { 810*cdf0e10cSrcweir for ( n = 0; n < ( 5 - nLen ); n++ ) 811*cdf0e10cSrcweir { 812*cdf0e10cSrcweir *(*pBuf)++ = (BYTE)'0'; 813*cdf0e10cSrcweir } 814*cdf0e10cSrcweir } 815*cdf0e10cSrcweir for ( USHORT n = 0; n < nLen; n++ ) 816*cdf0e10cSrcweir { 817*cdf0e10cSrcweir *(*pBuf)++ = aNumber2[ n ]; 818*cdf0e10cSrcweir } 819*cdf0e10cSrcweir } 820*cdf0e10cSrcweir *(*pBuf)++ = ' '; 821*cdf0e10cSrcweir } 822*cdf0e10cSrcweir #endif 823*cdf0e10cSrcweir 824*cdf0e10cSrcweir inline void ImplWriteString( BYTE** pBuf, const char* sString ) 825*cdf0e10cSrcweir { 826*cdf0e10cSrcweir strcpy( (char*)*pBuf, sString ); 827*cdf0e10cSrcweir *pBuf += strlen( sString ); 828*cdf0e10cSrcweir } 829*cdf0e10cSrcweir 830*cdf0e10cSrcweir BOOL Os2SalGraphics::drawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, ULONG nSize ) 831*cdf0e10cSrcweir { 832*cdf0e10cSrcweir if ( !mbPrinter ) 833*cdf0e10cSrcweir return FALSE; 834*cdf0e10cSrcweir 835*cdf0e10cSrcweir BOOL bRet = FALSE; 836*cdf0e10cSrcweir LONG nLong = 0; 837*cdf0e10cSrcweir if ( !(DevQueryCaps( mhDC, CAPS_TECHNOLOGY, 1, &nLong ) && 838*cdf0e10cSrcweir (CAPS_TECH_POSTSCRIPT == nLong)) ) 839*cdf0e10cSrcweir return FALSE; 840*cdf0e10cSrcweir 841*cdf0e10cSrcweir BYTE* pBuf = new BYTE[ POSTSCRIPT_BUFSIZE ]; 842*cdf0e10cSrcweir double nBoundingBox[4]; 843*cdf0e10cSrcweir 844*cdf0e10cSrcweir if ( pBuf && ImplGetBoundingBox( nBoundingBox, (BYTE*)pPtr, nSize ) ) 845*cdf0e10cSrcweir { 846*cdf0e10cSrcweir LONG pOS2DXAry[4]; // hack -> print always 2 white space 847*cdf0e10cSrcweir POINTL aPt; 848*cdf0e10cSrcweir aPt.x = 0; 849*cdf0e10cSrcweir aPt.y = 0; 850*cdf0e10cSrcweir PCH pStr = (PCH) " "; 851*cdf0e10cSrcweir for( long i = 0; i < 4; i++ ) 852*cdf0e10cSrcweir pOS2DXAry[i] = i; 853*cdf0e10cSrcweir Ft2CharStringPosAt( mhPS, &aPt, NULL, 0, 2, (PCH)pStr,(PLONG)&pOS2DXAry[0] ); 854*cdf0e10cSrcweir 855*cdf0e10cSrcweir OStringBuffer aBuf( POSTSCRIPT_BUFSIZE ); 856*cdf0e10cSrcweir 857*cdf0e10cSrcweir // reserve place for a USHORT 858*cdf0e10cSrcweir aBuf.append( "aa" ); 859*cdf0e10cSrcweir 860*cdf0e10cSrcweir // #107797# Write out EPS encapsulation header 861*cdf0e10cSrcweir // ---------------------------------------------------------------------------------- 862*cdf0e10cSrcweir 863*cdf0e10cSrcweir // directly taken from the PLRM 3.0, p. 726. Note: 864*cdf0e10cSrcweir // this will definitely cause problems when 865*cdf0e10cSrcweir // recursively creating and embedding PostScript files 866*cdf0e10cSrcweir // in OOo, since we use statically-named variables 867*cdf0e10cSrcweir // here (namely, b4_Inc_state_salWin, dict_count_salWin and 868*cdf0e10cSrcweir // op_count_salWin). Currently, I have no idea on how to 869*cdf0e10cSrcweir // work around that, except from scanning and 870*cdf0e10cSrcweir // interpreting the EPS for unused identifiers. 871*cdf0e10cSrcweir 872*cdf0e10cSrcweir // append the real text 873*cdf0e10cSrcweir aBuf.append( "\n\n/b4_Inc_state_salWin save def\n" 874*cdf0e10cSrcweir "/dict_count_salWin countdictstack def\n" 875*cdf0e10cSrcweir "/op_count_salWin count 1 sub def\n" 876*cdf0e10cSrcweir "userdict begin\n" 877*cdf0e10cSrcweir "/showpage {} def\n" 878*cdf0e10cSrcweir "0 setgray 0 setlinecap\n" 879*cdf0e10cSrcweir "1 setlinewidth 0 setlinejoin\n" 880*cdf0e10cSrcweir "10 setmiterlimit [] 0 setdash newpath\n" 881*cdf0e10cSrcweir "/languagelevel where\n" 882*cdf0e10cSrcweir "{\n" 883*cdf0e10cSrcweir " pop languagelevel\n" 884*cdf0e10cSrcweir " 1 ne\n" 885*cdf0e10cSrcweir " {\n" 886*cdf0e10cSrcweir " false setstrokeadjust false setoverprint\n" 887*cdf0e10cSrcweir " } if\n" 888*cdf0e10cSrcweir "} if\n\n" ); 889*cdf0e10cSrcweir 890*cdf0e10cSrcweir #if 0 891*cdf0e10cSrcweir // #i10737# Apply clipping manually 892*cdf0e10cSrcweir // ---------------------------------------------------------------------------------- 893*cdf0e10cSrcweir 894*cdf0e10cSrcweir // Windows seems to ignore any clipping at the HDC, 895*cdf0e10cSrcweir // when followed by a POSTSCRIPT_PASSTHROUGH 896*cdf0e10cSrcweir 897*cdf0e10cSrcweir // Check whether we've got a clipping, consisting of 898*cdf0e10cSrcweir // exactly one rect (other cases should be, but aren't 899*cdf0e10cSrcweir // handled currently) 900*cdf0e10cSrcweir 901*cdf0e10cSrcweir // TODO: Handle more than one rectangle here (take 902*cdf0e10cSrcweir // care, the buffer can handle only POSTSCRIPT_BUFSIZE 903*cdf0e10cSrcweir // characters!) 904*cdf0e10cSrcweir if ( mhRegion != 0 && 905*cdf0e10cSrcweir mpStdClipRgnData != NULL && 906*cdf0e10cSrcweir mpClipRgnData == mpStdClipRgnData && 907*cdf0e10cSrcweir mpClipRgnData->rdh.nCount == 1 ) 908*cdf0e10cSrcweir { 909*cdf0e10cSrcweir RECT* pRect = &(mpClipRgnData->rdh.rcBound); 910*cdf0e10cSrcweir 911*cdf0e10cSrcweir aBuf.append( "\nnewpath\n" ); 912*cdf0e10cSrcweir aBuf.append( pRect->left ); 913*cdf0e10cSrcweir aBuf.append( " " ); 914*cdf0e10cSrcweir aBuf.append( pRect->top ); 915*cdf0e10cSrcweir aBuf.append( " moveto\n" ); 916*cdf0e10cSrcweir aBuf.append( pRect->right ); 917*cdf0e10cSrcweir aBuf.append( " " ); 918*cdf0e10cSrcweir aBuf.append( pRect->top ); 919*cdf0e10cSrcweir aBuf.append( " lineto\n" ); 920*cdf0e10cSrcweir aBuf.append( pRect->right ); 921*cdf0e10cSrcweir aBuf.append( " " ); 922*cdf0e10cSrcweir aBuf.append( pRect->bottom ); 923*cdf0e10cSrcweir aBuf.append( " lineto\n" ); 924*cdf0e10cSrcweir aBuf.append( pRect->left ); 925*cdf0e10cSrcweir aBuf.append( " " ); 926*cdf0e10cSrcweir aBuf.append( pRect->bottom ); 927*cdf0e10cSrcweir aBuf.append( " lineto\n" 928*cdf0e10cSrcweir "closepath\n" 929*cdf0e10cSrcweir "clip\n" 930*cdf0e10cSrcweir "newpath\n" ); 931*cdf0e10cSrcweir } 932*cdf0e10cSrcweir #endif 933*cdf0e10cSrcweir 934*cdf0e10cSrcweir // #107797# Write out buffer 935*cdf0e10cSrcweir // ---------------------------------------------------------------------------------- 936*cdf0e10cSrcweir *((USHORT*)aBuf.getStr()) = (USHORT)( aBuf.getLength() - 2 ); 937*cdf0e10cSrcweir //Escape ( mhDC, nEscape, aBuf.getLength(), (LPTSTR)aBuf.getStr(), 0 ); 938*cdf0e10cSrcweir DevEscape( mhDC, DEVESC_RAWDATA, aBuf.getLength(), 939*cdf0e10cSrcweir (PBYTE)aBuf.getStr(), 0, NULL ); 940*cdf0e10cSrcweir 941*cdf0e10cSrcweir double dM11 = nWidth / ( nBoundingBox[2] - nBoundingBox[0] ); 942*cdf0e10cSrcweir double dM22 = - ( nHeight / (nBoundingBox[1] - nBoundingBox[3] ) ); 943*cdf0e10cSrcweir 944*cdf0e10cSrcweir // reserve a USHORT again 945*cdf0e10cSrcweir aBuf.setLength( 2 ); 946*cdf0e10cSrcweir aBuf.append( "\n\n[" ); 947*cdf0e10cSrcweir aBuf.append( dM11 ); 948*cdf0e10cSrcweir aBuf.append( " 0 0 " ); 949*cdf0e10cSrcweir aBuf.append( dM22 ); 950*cdf0e10cSrcweir aBuf.append( ' ' ); 951*cdf0e10cSrcweir aBuf.append( nX - ( dM11 * nBoundingBox[0] ) ); 952*cdf0e10cSrcweir aBuf.append( ' ' ); 953*cdf0e10cSrcweir aBuf.append( nY - ( dM22 * nBoundingBox[3] ) ); 954*cdf0e10cSrcweir aBuf.append( "] concat\n" 955*cdf0e10cSrcweir "%%BeginDocument:\n" ); 956*cdf0e10cSrcweir *((USHORT*)aBuf.getStr()) = (USHORT)( aBuf.getLength() - 2 ); 957*cdf0e10cSrcweir DevEscape( mhDC, DEVESC_RAWDATA, aBuf.getLength(), 958*cdf0e10cSrcweir (PBYTE)aBuf.getStr(), 0, NULL ); 959*cdf0e10cSrcweir #if 0 960*cdf0e10cSrcweir BYTE* pTemp = pBuf; 961*cdf0e10cSrcweir ImplWriteString( &pTemp, "save\n[ " ); 962*cdf0e10cSrcweir ImplWriteDouble( &pTemp, dM11 ); 963*cdf0e10cSrcweir ImplWriteDouble( &pTemp, 0 ); 964*cdf0e10cSrcweir ImplWriteDouble( &pTemp, 0 ); 965*cdf0e10cSrcweir ImplWriteDouble( &pTemp, dM22 ); 966*cdf0e10cSrcweir ImplWriteDouble( &pTemp, nX - ( dM11 * nBoundingBox[0] ) ); 967*cdf0e10cSrcweir ImplWriteDouble( &pTemp, mnHeight - nY - ( dM22 * nBoundingBox[3] ) ); 968*cdf0e10cSrcweir ImplWriteString( &pTemp, "] concat /showpage {} def\n" ); 969*cdf0e10cSrcweir 970*cdf0e10cSrcweir if ( DevEscape( mhDC, DEVESC_RAWDATA, pTemp - pBuf, 971*cdf0e10cSrcweir (PBYTE)pBuf, 0, NULL ) == DEV_OK ) 972*cdf0e10cSrcweir #endif // 973*cdf0e10cSrcweir { 974*cdf0e10cSrcweir UINT32 nToDo = nSize; 975*cdf0e10cSrcweir UINT32 nDoNow; 976*cdf0e10cSrcweir bRet = TRUE; 977*cdf0e10cSrcweir while( nToDo && bRet ) 978*cdf0e10cSrcweir { 979*cdf0e10cSrcweir nDoNow = 0x4000; 980*cdf0e10cSrcweir if ( nToDo < nDoNow ) 981*cdf0e10cSrcweir nDoNow = nToDo; 982*cdf0e10cSrcweir 983*cdf0e10cSrcweir if ( DevEscape( mhDC, DEVESC_RAWDATA, nDoNow, (PBYTE)pPtr + nSize - nToDo, 984*cdf0e10cSrcweir 0, NULL ) == -1 ) 985*cdf0e10cSrcweir bRet = FALSE; 986*cdf0e10cSrcweir nToDo -= nDoNow; 987*cdf0e10cSrcweir } 988*cdf0e10cSrcweir 989*cdf0e10cSrcweir if ( bRet ) 990*cdf0e10cSrcweir { 991*cdf0e10cSrcweir strcpy ( (char*)pBuf, "\nrestore\n" ); 992*cdf0e10cSrcweir if ( DevEscape( mhDC, DEVESC_RAWDATA, 9, (PBYTE)pBuf, 993*cdf0e10cSrcweir 0, NULL ) == DEV_OK ) bRet = TRUE; 994*cdf0e10cSrcweir } 995*cdf0e10cSrcweir 996*cdf0e10cSrcweir // #107797# Write out EPS encapsulation footer 997*cdf0e10cSrcweir // ---------------------------------------------------------------------------------- 998*cdf0e10cSrcweir // reserve a USHORT again 999*cdf0e10cSrcweir aBuf.setLength( 2 ); 1000*cdf0e10cSrcweir aBuf.append( "%%EndDocument\n" 1001*cdf0e10cSrcweir "count op_count_salWin sub {pop} repeat\n" 1002*cdf0e10cSrcweir "countdictstack dict_count_salWin sub {end} repeat\n" 1003*cdf0e10cSrcweir "b4_Inc_state_salWin restore\n\n" ); 1004*cdf0e10cSrcweir *((USHORT*)aBuf.getStr()) = (USHORT)( aBuf.getLength() - 2 ); 1005*cdf0e10cSrcweir DevEscape( mhDC, DEVESC_RAWDATA, aBuf.getLength(), 1006*cdf0e10cSrcweir (PBYTE)aBuf.getStr(), 0, NULL ); 1007*cdf0e10cSrcweir bRet = TRUE; 1008*cdf0e10cSrcweir 1009*cdf0e10cSrcweir } 1010*cdf0e10cSrcweir } 1011*cdf0e10cSrcweir delete [] pBuf; 1012*cdf0e10cSrcweir return bRet; 1013*cdf0e10cSrcweir } 1014*cdf0e10cSrcweir 1015*cdf0e10cSrcweir /* 1016*cdf0e10cSrcweir * IsNativeControlSupported() 1017*cdf0e10cSrcweir * 1018*cdf0e10cSrcweir * Returns TRUE if the platform supports native 1019*cdf0e10cSrcweir * drawing of the control defined by nPart 1020*cdf0e10cSrcweir */ 1021*cdf0e10cSrcweir BOOL Os2SalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nPart ) 1022*cdf0e10cSrcweir { 1023*cdf0e10cSrcweir return( FALSE ); 1024*cdf0e10cSrcweir } 1025*cdf0e10cSrcweir 1026*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1027*cdf0e10cSrcweir 1028*cdf0e10cSrcweir SystemGraphicsData Os2SalGraphics::GetGraphicsData() const 1029*cdf0e10cSrcweir { 1030*cdf0e10cSrcweir SystemGraphicsData aRes; 1031*cdf0e10cSrcweir aRes.nSize = sizeof(aRes); 1032*cdf0e10cSrcweir #if 0 1033*cdf0e10cSrcweir aRes.hDC = mhDC; 1034*cdf0e10cSrcweir #endif 1035*cdf0e10cSrcweir return aRes; 1036*cdf0e10cSrcweir } 1037*cdf0e10cSrcweir 1038*cdf0e10cSrcweir // ----------------------------------------------------------------------- 1039