1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_vcl.hxx"
31 #include "svppspgraphics.hxx"
34 #include "vcl/jobdata.hxx"
35 #include "vcl/printergfx.hxx"
36 #include "vcl/printerinfomanager.hxx"
37 #include "vcl/bmpacc.hxx"
38 #include "vcl/salbmp.hxx"
39 #include "vcl/glyphcache.hxx"
40 #include "vcl/impfont.hxx"
41 #include "vcl/outfont.hxx"
42 #include "vcl/fontsubset.hxx"
43 #include "vcl/svapp.hxx"
44 #include "vcl/salprn.hxx"
45 #include "vcl/sysdata.hxx"
47 #include "basegfx/vector/b2ivector.hxx"
48 #include "basegfx/point/b2ipoint.hxx"
49 #include "basebmp/color.hxx"
56 #include <sys/types.h>
60 using namespace basebmp
;
61 using namespace basegfx
;
63 // ----- Implementation of PrinterBmp by means of SalBitmap/BitmapBuffer ---------------
65 class SalPrinterBmp
: public psp::PrinterBmp
70 BitmapDeviceSharedPtr m_aBitmap
;
73 SalPrinterBmp (const BitmapDeviceSharedPtr
& rDevice
);
74 virtual ~SalPrinterBmp ();
75 virtual sal_uInt32
GetPaletteColor (sal_uInt32 nIdx
) const;
76 virtual sal_uInt32
GetPaletteEntryCount () const;
77 virtual sal_uInt32
GetPixelRGB (sal_uInt32 nRow
, sal_uInt32 nColumn
) const;
78 virtual sal_uInt8
GetPixelGray (sal_uInt32 nRow
, sal_uInt32 nColumn
) const;
79 virtual sal_uInt8
GetPixelIdx (sal_uInt32 nRow
, sal_uInt32 nColumn
) const;
80 virtual sal_uInt32
GetWidth () const;
81 virtual sal_uInt32
GetHeight() const;
82 virtual sal_uInt32
GetDepth () const;
84 static sal_uInt32
getRGBFromColor( const basebmp::Color
& rCol
)
86 return ((rCol
.getBlue()) & 0x000000ff)
87 | ((rCol
.getGreen() << 8) & 0x0000ff00)
88 | ((rCol
.getRed() << 16) & 0x00ff0000);
92 SalPrinterBmp::SalPrinterBmp(const BitmapDeviceSharedPtr
& rDevice
) :
97 SalPrinterBmp::~SalPrinterBmp ()
102 SalPrinterBmp::GetWidth () const
104 return m_aBitmap
.get() ? m_aBitmap
->getSize().getX() : 0;
108 SalPrinterBmp::GetHeight () const
110 return m_aBitmap
.get() ? m_aBitmap
->getSize().getY() : 0;
114 SalPrinterBmp::GetDepth () const
116 return m_aBitmap
.get() ?
117 SvpElement::getBitCountFromScanlineFormat( m_aBitmap
->getScanlineFormat() )
123 SalPrinterBmp::GetPaletteEntryCount () const
125 return m_aBitmap
.get() ? m_aBitmap
->getPaletteEntryCount() : 0;
129 SalPrinterBmp::GetPaletteColor (sal_uInt32 nIdx
) const
132 if( m_aBitmap
.get() && nIdx
< static_cast<sal_uInt32
>(m_aBitmap
->getPaletteEntryCount()) )
134 const basebmp::Color
& rColor
= (*m_aBitmap
->getPalette().get())[ nIdx
];
135 nCol
= getRGBFromColor( rColor
);
141 SalPrinterBmp::GetPixelRGB (sal_uInt32 nRow
, sal_uInt32 nColumn
) const
144 if( m_aBitmap
.get() )
145 nCol
= getRGBFromColor( m_aBitmap
->getPixel( B2IPoint( nColumn
, nRow
) ) );
150 SalPrinterBmp::GetPixelGray (sal_uInt32 nRow
, sal_uInt32 nColumn
) const
153 if( m_aBitmap
.get() )
155 // TODO: don't use tools color
156 basebmp::Color aCol
= m_aBitmap
->getPixel( B2IPoint( nColumn
, nRow
) );
157 ::Color
aColor( aCol
.getRed(), aCol
.getGreen(), aCol
.getBlue() );
158 nGray
= aColor
.GetLuminance();
164 SalPrinterBmp::GetPixelIdx (sal_uInt32 nRow
, sal_uInt32 nColumn
) const
167 if( m_aBitmap
.get() )
168 nIdx
= static_cast<sal_uInt8
>(m_aBitmap
->getPixelData( B2IPoint( nColumn
, nRow
) ));
172 /*******************************************************
174 *******************************************************/
176 bool PspGraphics::drawAlphaBitmap( const SalTwoRect
&, const SalBitmap
& /*rSourceBitmap*/, const SalBitmap
& /*rAlphaBitmap*/ )
181 bool PspGraphics::drawAlphaRect( long /*nX*/, long /*nY*/, long /*nWidth*/, long /*nHeight*/, sal_uInt8
/*nTransparency*/ )
186 bool PspGraphics::supportsOperation( OutDevSupportType
) const
191 PspGraphics::~PspGraphics()
196 void PspGraphics::GetResolution( sal_Int32
&rDPIX
, sal_Int32
&rDPIY
)
198 if (m_pJobData
!= NULL
)
200 int x
= m_pJobData
->m_aContext
.getRenderResolution();
207 USHORT
PspGraphics::GetBitCount()
209 return m_pPrinterGfx
->GetBitCount();
212 long PspGraphics::GetGraphicsWidth() const
217 void PspGraphics::ResetClipRegion()
219 m_pPrinterGfx
->ResetClipRegion ();
222 void PspGraphics::BeginSetClipRegion( ULONG n
)
224 m_pPrinterGfx
->BeginSetClipRegion(n
);
227 BOOL
PspGraphics::unionClipRegion( long nX
, long nY
, long nDX
, long nDY
)
229 return (BOOL
)m_pPrinterGfx
->UnionClipRegion (nX
, nY
, nDX
, nDY
);
232 bool PspGraphics::unionClipRegion( const ::basegfx::B2DPolyPolygon
& )
234 // TODO: implement and advertise OutDevSupport_B2DClip support
238 void PspGraphics::EndSetClipRegion()
240 m_pPrinterGfx
->EndSetClipRegion ();
243 void PspGraphics::SetLineColor()
245 m_pPrinterGfx
->SetLineColor ();
248 void PspGraphics::SetLineColor( SalColor nSalColor
)
250 psp::PrinterColor
aColor (SALCOLOR_RED (nSalColor
),
251 SALCOLOR_GREEN (nSalColor
),
252 SALCOLOR_BLUE (nSalColor
));
253 m_pPrinterGfx
->SetLineColor (aColor
);
256 void PspGraphics::SetFillColor()
258 m_pPrinterGfx
->SetFillColor ();
261 void PspGraphics::SetFillColor( SalColor nSalColor
)
263 psp::PrinterColor
aColor (SALCOLOR_RED (nSalColor
),
264 SALCOLOR_GREEN (nSalColor
),
265 SALCOLOR_BLUE (nSalColor
));
266 m_pPrinterGfx
->SetFillColor (aColor
);
269 void PspGraphics::SetROPLineColor( SalROPColor
)
271 DBG_ASSERT( 0, "Error: PrinterGfx::SetROPLineColor() not implemented" );
274 void PspGraphics::SetROPFillColor( SalROPColor
)
276 DBG_ASSERT( 0, "Error: PrinterGfx::SetROPFillColor() not implemented" );
279 void PspGraphics::SetXORMode( bool bSet
, bool )
282 DBG_ASSERT( !bSet
, "Error: PrinterGfx::SetXORMode() not implemented" );
285 void PspGraphics::drawPixel( long nX
, long nY
)
287 m_pPrinterGfx
->DrawPixel (Point(nX
, nY
));
290 void PspGraphics::drawPixel( long nX
, long nY
, SalColor nSalColor
)
292 psp::PrinterColor
aColor (SALCOLOR_RED (nSalColor
),
293 SALCOLOR_GREEN (nSalColor
),
294 SALCOLOR_BLUE (nSalColor
));
295 m_pPrinterGfx
->DrawPixel (Point(nX
, nY
), aColor
);
298 void PspGraphics::drawLine( long nX1
, long nY1
, long nX2
, long nY2
)
300 m_pPrinterGfx
->DrawLine (Point(nX1
, nY1
), Point(nX2
, nY2
));
303 void PspGraphics::drawRect( long nX
, long nY
, long nDX
, long nDY
)
305 m_pPrinterGfx
->DrawRect (Rectangle(Point(nX
, nY
), Size(nDX
, nDY
)));
308 void PspGraphics::drawPolyLine( ULONG nPoints
, const SalPoint
*pPtAry
)
310 m_pPrinterGfx
->DrawPolyLine (nPoints
, (Point
*)pPtAry
);
313 void PspGraphics::drawPolygon( ULONG nPoints
, const SalPoint
* pPtAry
)
315 // Point must be equal to SalPoint! see vcl/inc/salgtype.hxx
316 m_pPrinterGfx
->DrawPolygon (nPoints
, (Point
*)pPtAry
);
319 void PspGraphics::drawPolyPolygon( sal_uInt32 nPoly
,
320 const sal_uInt32
*pPoints
,
321 PCONSTSALPOINT
*pPtAry
)
323 m_pPrinterGfx
->DrawPolyPolygon (nPoly
, pPoints
, (const Point
**)pPtAry
);
326 bool PspGraphics::drawPolyLine( const ::basegfx::B2DPolygon
&, const ::basegfx::B2DVector
& /*rLineWidths*/, basegfx::B2DLineJoin
/*eJoin*/ )
328 // TODO: implement and advertise OutDevSupport_B2DDraw support
332 sal_Bool
PspGraphics::drawPolyLineBezier( ULONG nPoints
, const SalPoint
* pPtAry
, const BYTE
* pFlgAry
)
334 m_pPrinterGfx
->DrawPolyLineBezier (nPoints
, (Point
*)pPtAry
, pFlgAry
);
338 sal_Bool
PspGraphics::drawPolygonBezier( ULONG nPoints
, const SalPoint
* pPtAry
, const BYTE
* pFlgAry
)
340 m_pPrinterGfx
->DrawPolygonBezier (nPoints
, (Point
*)pPtAry
, pFlgAry
);
344 sal_Bool
PspGraphics::drawPolyPolygonBezier( sal_uInt32 nPoly
,
345 const sal_uInt32
* pPoints
,
346 const SalPoint
* const* pPtAry
,
347 const BYTE
* const* pFlgAry
)
349 // Point must be equal to SalPoint! see vcl/inc/salgtype.hxx
350 m_pPrinterGfx
->DrawPolyPolygonBezier (nPoly
, pPoints
, (Point
**)pPtAry
, (BYTE
**)pFlgAry
);
354 bool PspGraphics::drawPolyPolygon( const basegfx::B2DPolyPolygon
&, double /*fTransparency*/ )
356 // TODO: implement and advertise OutDevSupport_B2DDraw support
360 void PspGraphics::invert( ULONG
/*nPoints*/,
361 const SalPoint
* /*pPtAry*/,
362 SalInvert
/*nFlags*/ )
364 DBG_ASSERT( 0, "Error: PrinterGfx::Invert() not implemented" );
366 BOOL
PspGraphics::drawEPS( long nX
, long nY
, long nWidth
, long nHeight
, void* pPtr
, ULONG nSize
)
368 return m_pPrinterGfx
->DrawEPS( Rectangle( Point( nX
, nY
), Size( nWidth
, nHeight
) ), pPtr
, nSize
);
371 void PspGraphics::copyBits( const SalTwoRect
* /*pPosAry*/,
372 SalGraphics
* /*pSSrcGraphics*/ )
374 DBG_ERROR( "Error: PrinterGfx::CopyBits() not implemented" );
377 void PspGraphics::copyArea ( long /*nDestX*/, long /*nDestY*/,
378 long /*nSrcX*/, long /*nSrcY*/,
379 long /*nSrcWidth*/, long /*nSrcHeight*/,
382 DBG_ERROR( "Error: PrinterGfx::CopyArea() not implemented" );
385 void PspGraphics::drawBitmap( const SalTwoRect
* pPosAry
, const SalBitmap
& rSalBitmap
)
387 Rectangle
aSrc (Point(pPosAry
->mnSrcX
, pPosAry
->mnSrcY
),
388 Size(pPosAry
->mnSrcWidth
, pPosAry
->mnSrcHeight
));
389 Rectangle
aDst (Point(pPosAry
->mnDestX
, pPosAry
->mnDestY
),
390 Size(pPosAry
->mnDestWidth
, pPosAry
->mnDestHeight
));
392 const SvpSalBitmap
* pBmp
= dynamic_cast<const SvpSalBitmap
*>(&rSalBitmap
);
395 SalPrinterBmp
aBmp(pBmp
->getBitmap());
396 m_pPrinterGfx
->DrawBitmap(aDst
, aSrc
, aBmp
);
400 void PspGraphics::drawBitmap( const SalTwoRect
* /*pPosAry*/,
401 const SalBitmap
& /*rSalBitmap*/,
402 const SalBitmap
& /*rTransBitmap*/ )
404 DBG_ERROR("Error: no PrinterGfx::DrawBitmap() for transparent bitmap");
407 void PspGraphics::drawBitmap( const SalTwoRect
* /*pPosAry*/,
408 const SalBitmap
& /*rSalBitmap*/,
409 SalColor
/*nTransparentColor*/ )
411 DBG_ERROR("Error: no PrinterGfx::DrawBitmap() for transparent color");
414 void PspGraphics::drawMask( const SalTwoRect
* /*pPosAry*/,
415 const SalBitmap
& /*rSalBitmap*/,
416 SalColor
/*nMaskColor*/ )
418 DBG_ERROR("Error: PrinterGfx::DrawMask() not implemented");
421 SalBitmap
* PspGraphics::getBitmap( long /*nX*/, long /*nY*/, long /*nDX*/, long /*nDY*/ )
423 DBG_WARNING ("Warning: PrinterGfx::GetBitmap() not implemented");
427 SalColor
PspGraphics::getPixel( long /*nX*/, long /*nY*/ )
429 DBG_ERROR ("Warning: PrinterGfx::GetPixel() not implemented");
433 void PspGraphics::invert(
438 SalInvert
/*nFlags*/ )
440 DBG_ERROR ("Warning: PrinterGfx::Invert() not implemented");
443 //==========================================================================
445 class ImplPspFontData
: public ImplFontData
448 enum { PSPFD_MAGIC
= 0xb5bf01f0 };
452 ImplPspFontData( const psp::FastPrintFontInfo
& );
453 virtual sal_IntPtr
GetFontId() const { return mnFontId
; }
454 virtual ImplFontData
* Clone() const { return new ImplPspFontData( *this ); }
455 virtual ImplFontEntry
* CreateFontInstance( ImplFontSelectData
& ) const;
456 static bool CheckFontData( const ImplFontData
& r
) { return r
.CheckMagic( PSPFD_MAGIC
); }
459 //--------------------------------------------------------------------------
461 ImplPspFontData::ImplPspFontData( const psp::FastPrintFontInfo
& rInfo
)
462 : ImplFontData( PspGraphics::Info2DevFontAttributes(rInfo
), PSPFD_MAGIC
),
463 mnFontId( rInfo
.m_nID
)
466 //--------------------------------------------------------------------------
468 ImplFontEntry
* ImplPspFontData::CreateFontInstance( ImplFontSelectData
& rFSD
) const
470 ImplServerFontEntry
* pEntry
= new ImplServerFontEntry( rFSD
);
474 //==========================================================================
476 class PspFontLayout
: public GenericSalLayout
479 PspFontLayout( ::psp::PrinterGfx
& );
480 virtual bool LayoutText( ImplLayoutArgs
& );
481 virtual void InitFont() const;
482 virtual void DrawText( SalGraphics
& ) const;
484 ::psp::PrinterGfx
& mrPrinterGfx
;
493 //--------------------------------------------------------------------------
495 PspFontLayout::PspFontLayout( ::psp::PrinterGfx
& rGfx
)
496 : mrPrinterGfx( rGfx
)
498 mnFontID
= mrPrinterGfx
.GetFontID();
499 mnFontHeight
= mrPrinterGfx
.GetFontHeight();
500 mnFontWidth
= mrPrinterGfx
.GetFontWidth();
501 mbVertical
= mrPrinterGfx
.GetFontVertical();
502 mbArtItalic
= mrPrinterGfx
.GetArtificialItalic();
503 mbArtBold
= mrPrinterGfx
.GetArtificialBold();
506 //--------------------------------------------------------------------------
508 bool PspFontLayout::LayoutText( ImplLayoutArgs
& rArgs
)
510 mbVertical
= ((rArgs
.mnFlags
& SAL_LAYOUT_VERTICAL
) != 0);
512 long nUnitsPerPixel
= 1;
513 int nOldGlyphId
= -1;
514 long nGlyphWidth
= 0;
516 Point
aNewPos( 0, 0 );
518 rtl_TextEncoding aFontEnc
= mrPrinterGfx
.GetFontMgr().getFontEncoding( mnFontID
);
522 if( !rArgs
.GetNextPos( &nCharPos
, &bRightToLeft
) )
525 sal_UCS4 cChar
= rArgs
.mpStr
[ nCharPos
];
527 cChar
= GetMirroredChar( cChar
);
528 // symbol font aliasing: 0x0020-0x00ff -> 0xf020 -> 0xf0ff
529 if( aFontEnc
== RTL_TEXTENCODING_SYMBOL
)
532 int nGlyphIndex
= cChar
; // printer glyphs = unicode
534 // update fallback_runs if needed
535 psp::CharacterMetric aMetric
;
536 mrPrinterGfx
.GetFontMgr().getMetrics( mnFontID
, cChar
, cChar
, &aMetric
, mbVertical
);
537 if( aMetric
.width
== -1 && aMetric
.height
== -1 )
538 rArgs
.NeedFallback( nCharPos
, bRightToLeft
);
540 // apply pair kerning to prev glyph if requested
541 if( SAL_LAYOUT_KERNING_PAIRS
& rArgs
.mnFlags
)
543 if( nOldGlyphId
> 0 )
545 const std::list
< KernPair
>& rKernPairs
= mrPrinterGfx
.getKernPairs(mbVertical
);
546 for( std::list
< KernPair
>::const_iterator it
= rKernPairs
.begin();
547 it
!= rKernPairs
.end(); ++it
)
549 if( it
->first
== nOldGlyphId
&& it
->second
== nGlyphIndex
)
551 int nTextScale
= mrPrinterGfx
.GetFontWidth();
553 nTextScale
= mrPrinterGfx
.GetFontHeight();
554 int nKern
= (mbVertical
? it
->kern_y
: it
->kern_x
) * nTextScale
;
555 nGlyphWidth
+= nKern
;
556 aPrevItem
.mnNewWidth
= nGlyphWidth
;
563 // finish previous glyph
564 if( nOldGlyphId
>= 0 )
565 AppendGlyph( aPrevItem
);
566 nOldGlyphId
= nGlyphIndex
;
567 aNewPos
.X() += nGlyphWidth
;
569 // prepare GlyphItem for appending it in next round
570 nUnitsPerPixel
= mrPrinterGfx
.GetCharWidth( cChar
, cChar
, &nGlyphWidth
);
571 int nGlyphFlags
= bRightToLeft
? GlyphItem::IS_RTL_GLYPH
: 0;
572 nGlyphIndex
|= GF_ISCHAR
;
573 aPrevItem
= GlyphItem( nCharPos
, nGlyphIndex
, aNewPos
, nGlyphFlags
, nGlyphWidth
);
576 // append last glyph item if any
577 if( nOldGlyphId
>= 0 )
578 AppendGlyph( aPrevItem
);
580 SetOrientation( mrPrinterGfx
.GetFontAngle() );
581 SetUnitsPerPixel( nUnitsPerPixel
);
582 return (nOldGlyphId
>= 0);
585 class PspServerFontLayout
: public ServerFontLayout
588 PspServerFontLayout( psp::PrinterGfx
&, ServerFont
& rFont
, const ImplLayoutArgs
& rArgs
);
590 virtual void InitFont() const;
591 const sal_Unicode
* getTextPtr() const { return maText
.getStr() - mnMinCharPos
; }
592 int getMinCharPos() const { return mnMinCharPos
; }
593 int getMaxCharPos() const { return mnMinCharPos
+maText
.getLength()-1; }
595 ::psp::PrinterGfx
& mrPrinterGfx
;
602 rtl::OUString maText
;
606 PspServerFontLayout::PspServerFontLayout( ::psp::PrinterGfx
& rGfx
, ServerFont
& rFont
, const ImplLayoutArgs
& rArgs
)
607 : ServerFontLayout( rFont
),
610 mnFontID
= mrPrinterGfx
.GetFontID();
611 mnFontHeight
= mrPrinterGfx
.GetFontHeight();
612 mnFontWidth
= mrPrinterGfx
.GetFontWidth();
613 mbVertical
= mrPrinterGfx
.GetFontVertical();
614 mbArtItalic
= mrPrinterGfx
.GetArtificialItalic();
615 mbArtBold
= mrPrinterGfx
.GetArtificialBold();
616 maText
= OUString( rArgs
.mpStr
+ rArgs
.mnMinCharPos
, rArgs
.mnEndCharPos
- rArgs
.mnMinCharPos
+1 );
617 mnMinCharPos
= rArgs
.mnMinCharPos
;
620 void PspServerFontLayout::InitFont() const
622 mrPrinterGfx
.SetFont( mnFontID
, mnFontHeight
, mnFontWidth
,
623 mnOrientation
, mbVertical
, mbArtItalic
, mbArtBold
);
626 //--------------------------------------------------------------------------
628 static void DrawPrinterLayout( const SalLayout
& rLayout
, ::psp::PrinterGfx
& rGfx
, bool bIsPspServerFontLayout
)
630 const int nMaxGlyphs
= 200;
631 sal_GlyphId aGlyphAry
[ nMaxGlyphs
];
632 sal_Int32 aWidthAry
[ nMaxGlyphs
];
633 sal_Int32 aIdxAry
[ nMaxGlyphs
];
634 sal_Ucs aUnicodes
[ nMaxGlyphs
];
635 int aCharPosAry
[ nMaxGlyphs
];
638 long nUnitsPerPixel
= rLayout
.GetUnitsPerPixel();
639 const sal_Unicode
* pText
= bIsPspServerFontLayout
? static_cast<const PspServerFontLayout
&>(rLayout
).getTextPtr() : NULL
;
640 int nMinCharPos
= bIsPspServerFontLayout
? static_cast<const PspServerFontLayout
&>(rLayout
).getMinCharPos() : 0;
641 int nMaxCharPos
= bIsPspServerFontLayout
? static_cast<const PspServerFontLayout
&>(rLayout
).getMaxCharPos() : 0;
642 for( int nStart
= 0;; )
644 int nGlyphCount
= rLayout
.GetNextGlyphs( nMaxGlyphs
, aGlyphAry
, aPos
, nStart
, aWidthAry
, bIsPspServerFontLayout
? aCharPosAry
: NULL
);
648 sal_Int32 nXOffset
= 0;
649 for( int i
= 0; i
< nGlyphCount
; ++i
)
651 nXOffset
+= aWidthAry
[ i
];
652 aIdxAry
[ i
] = nXOffset
/ nUnitsPerPixel
;
653 sal_Int32 nGlyphIdx
= aGlyphAry
[i
] & (GF_IDXMASK
| GF_ROTMASK
);
654 if( bIsPspServerFontLayout
)
655 aUnicodes
[i
] = (aCharPosAry
[i
] >= nMinCharPos
&& aCharPosAry
[i
] <= nMaxCharPos
) ? pText
[ aCharPosAry
[i
] ] : 0;
657 aUnicodes
[i
] = (aGlyphAry
[i
] & GF_ISCHAR
) ? nGlyphIdx
: 0;
658 aGlyphAry
[i
] = nGlyphIdx
;
661 rGfx
.DrawGlyphs( aPos
, (sal_uInt32
*)aGlyphAry
, aUnicodes
, nGlyphCount
, aIdxAry
);
665 //--------------------------------------------------------------------------
667 void PspFontLayout::InitFont() const
669 mrPrinterGfx
.SetFont( mnFontID
, mnFontHeight
, mnFontWidth
,
670 mnOrientation
, mbVertical
, mbArtItalic
, mbArtBold
);
673 //--------------------------------------------------------------------------
675 void PspFontLayout::DrawText( SalGraphics
& ) const
677 DrawPrinterLayout( *this, mrPrinterGfx
, false );
680 void PspGraphics::DrawServerFontLayout( const ServerFontLayout
& rLayout
)
682 // print complex text
683 DrawPrinterLayout( rLayout
, *m_pPrinterGfx
, true );
686 ImplFontCharMap
* PspGraphics::GetImplFontCharMap() const
688 // TODO: get ImplFontCharMap directly from fonts
689 if( !m_pServerFont
[0] )
692 CmapResult aCmapResult
;
693 if( !m_pServerFont
[0]->GetFontCodeRanges( aCmapResult
) )
695 return new ImplFontCharMap( aCmapResult
);
698 USHORT
PspGraphics::SetFont( ImplFontSelectData
*pEntry
, int nFallbackLevel
)
700 // release all fonts that are to be overridden
701 for( int i
= nFallbackLevel
; i
< MAX_FALLBACK
; ++i
)
703 if( m_pServerFont
[i
] != NULL
)
705 // old server side font is no longer referenced
706 GlyphCache::GetInstance().UncacheFont( *m_pServerFont
[i
] );
707 m_pServerFont
[i
] = NULL
;
711 // return early if there is no new font
715 sal_IntPtr nID
= pEntry
->mpFontData
? pEntry
->mpFontData
->GetFontId() : 0;
717 // determine which font attributes need to be emulated
718 bool bArtItalic
= false;
719 bool bArtBold
= false;
720 if( pEntry
->meItalic
== ITALIC_OBLIQUE
|| pEntry
->meItalic
== ITALIC_NORMAL
)
722 psp::italic::type eItalic
= m_pPrinterGfx
->GetFontMgr().getFontItalic( nID
);
723 if( eItalic
!= psp::italic::Italic
&& eItalic
!= psp::italic::Oblique
)
726 int nWeight
= (int)pEntry
->meWeight
;
727 int nRealWeight
= (int)m_pPrinterGfx
->GetFontMgr().getFontWeight( nID
);
728 if( nRealWeight
<= (int)psp::weight::Medium
&& nWeight
> (int)WEIGHT_MEDIUM
)
733 // also set the serverside font for layouting
734 m_bFontVertical
= pEntry
->mbVertical
;
735 if( pEntry
->mpFontData
)
737 // requesting a font provided by builtin rasterizer
738 ServerFont
* pServerFont
= GlyphCache::GetInstance().CacheFont( *pEntry
);
739 if( pServerFont
!= NULL
)
741 if( pServerFont
->TestFont() )
742 m_pServerFont
[ nFallbackLevel
] = pServerFont
;
744 GlyphCache::GetInstance().UncacheFont( *pServerFont
);
748 // set the printer font
749 return m_pPrinterGfx
->SetFont( nID
,
752 pEntry
->mnOrientation
,
759 void PspGraphics::SetTextColor( SalColor nSalColor
)
761 psp::PrinterColor
aColor (SALCOLOR_RED (nSalColor
),
762 SALCOLOR_GREEN (nSalColor
),
763 SALCOLOR_BLUE (nSalColor
));
764 m_pPrinterGfx
->SetTextColor (aColor
);
767 bool PspGraphics::AddTempDevFont( ImplDevFontList
*, const String
&, const String
& )
772 void PspGraphics::GetDevFontList( ImplDevFontList
*pList
)
774 ::std::list
< psp::fontID
> aList
;
775 psp::PrintFontManager
& rMgr
= psp::PrintFontManager::get();
776 rMgr
.getFontList( aList
, m_pJobData
->m_pParser
, m_pInfoPrinter
->m_bCompatMetrics
);
778 ::std::list
< psp::fontID
>::iterator it
;
779 psp::FastPrintFontInfo aInfo
;
780 for (it
= aList
.begin(); it
!= aList
.end(); ++it
)
781 if (rMgr
.getFontFastInfo (*it
, aInfo
))
782 AnnounceFonts( pList
, aInfo
);
785 void PspGraphics::GetDevFontSubstList( OutputDevice
* pOutDev
)
787 const psp::PrinterInfo
& rInfo
= psp::PrinterInfoManager::get().getPrinterInfo( m_pJobData
->m_aPrinterName
);
788 if( rInfo
.m_bPerformFontSubstitution
)
790 for( std::hash_map
< rtl::OUString
, rtl::OUString
, rtl::OUStringHash
>::const_iterator it
= rInfo
.m_aFontSubstitutes
.begin(); it
!= rInfo
.m_aFontSubstitutes
.end(); ++it
)
791 AddDevFontSubstitute( pOutDev
, it
->first
, it
->second
, FONT_SUBSTITUTE_ALWAYS
);
795 void PspGraphics::GetFontMetric( ImplFontMetricData
*pMetric
)
797 const psp::PrintFontManager
& rMgr
= psp::PrintFontManager::get();
798 psp::PrintFontInfo aInfo
;
800 if (rMgr
.getFontInfo (m_pPrinterGfx
->GetFontID(), aInfo
))
802 ImplDevFontAttributes aDFA
= Info2DevFontAttributes( aInfo
);
803 static_cast<ImplFontAttributes
&>(*pMetric
) = aDFA
;
804 pMetric
->mbDevice
= aDFA
.mbDevice
;
805 pMetric
->mbScalableFont
= true;
807 pMetric
->mnOrientation
= m_pPrinterGfx
->GetFontAngle();
808 pMetric
->mnSlant
= 0;
810 sal_Int32 nTextHeight
= m_pPrinterGfx
->GetFontHeight();
811 sal_Int32 nTextWidth
= m_pPrinterGfx
->GetFontWidth();
813 nTextWidth
= nTextHeight
;
815 pMetric
->mnWidth
= nTextWidth
;
816 pMetric
->mnAscent
= ( aInfo
.m_nAscend
* nTextHeight
+ 500 ) / 1000;
817 pMetric
->mnDescent
= ( aInfo
.m_nDescend
* nTextHeight
+ 500 ) / 1000;
818 pMetric
->mnIntLeading
= ( aInfo
.m_nLeading
* nTextHeight
+ 500 ) / 1000;
819 pMetric
->mnExtLeading
= 0;
823 ULONG
PspGraphics::GetKernPairs( ULONG nPairs
, ImplKernPairData
*pKernPairs
)
825 const ::std::list
< ::psp::KernPair
>& rPairs( m_pPrinterGfx
->getKernPairs() );
826 ULONG nHavePairs
= rPairs
.size();
827 if( pKernPairs
&& nPairs
)
829 ::std::list
< ::psp::KernPair
>::const_iterator it
;
831 int nTextScale
= m_pPrinterGfx
->GetFontWidth();
833 nTextScale
= m_pPrinterGfx
->GetFontHeight();
834 for( i
= 0, it
= rPairs
.begin(); i
< nPairs
&& i
< nHavePairs
; i
++, ++it
)
836 pKernPairs
[i
].mnChar1
= it
->first
;
837 pKernPairs
[i
].mnChar2
= it
->second
;
838 pKernPairs
[i
].mnKern
= it
->kern_x
* nTextScale
/ 1000;
845 BOOL
PspGraphics::GetGlyphBoundRect( long nGlyphIndex
, Rectangle
& rRect
)
847 int nLevel
= nGlyphIndex
>> GF_FONTSHIFT
;
848 if( nLevel
>= MAX_FALLBACK
)
851 ServerFont
* pSF
= m_pServerFont
[ nLevel
];
855 nGlyphIndex
&= ~GF_FONTMASK
;
856 const GlyphMetric
& rGM
= pSF
->GetGlyphMetric( nGlyphIndex
);
857 rRect
= Rectangle( rGM
.GetOffset(), rGM
.GetSize() );
861 BOOL
PspGraphics::GetGlyphOutline( long nGlyphIndex
,
862 ::basegfx::B2DPolyPolygon
& rB2DPolyPoly
)
864 int nLevel
= nGlyphIndex
>> GF_FONTSHIFT
;
865 if( nLevel
>= MAX_FALLBACK
)
868 ServerFont
* pSF
= m_pServerFont
[ nLevel
];
872 nGlyphIndex
&= ~GF_FONTMASK
;
873 if( pSF
->GetGlyphOutline( nGlyphIndex
, rB2DPolyPoly
) )
879 SalLayout
* PspGraphics::GetTextLayout( ImplLayoutArgs
& rArgs
, int nFallbackLevel
)
881 // workaround for printers not handling glyph indexing for non-TT fonts
882 int nFontId
= m_pPrinterGfx
->GetFontID();
883 if( psp::fonttype::TrueType
!= psp::PrintFontManager::get().getFontType( nFontId
) )
884 rArgs
.mnFlags
|= SAL_LAYOUT_DISABLE_GLYPH_PROCESSING
;
885 else if( nFallbackLevel
> 0 )
886 rArgs
.mnFlags
&= ~SAL_LAYOUT_DISABLE_GLYPH_PROCESSING
;
888 GenericSalLayout
* pLayout
= NULL
;
890 if( m_pServerFont
[ nFallbackLevel
]
891 && !(rArgs
.mnFlags
& SAL_LAYOUT_DISABLE_GLYPH_PROCESSING
) )
892 pLayout
= new PspServerFontLayout( *m_pPrinterGfx
, *m_pServerFont
[nFallbackLevel
], rArgs
);
894 pLayout
= new PspFontLayout( *m_pPrinterGfx
);
899 //--------------------------------------------------------------------------
901 BOOL
PspGraphics::CreateFontSubset(
902 const rtl::OUString
& rToFile
,
903 const ImplFontData
* pFont
,
904 sal_Int32
* pGlyphIDs
,
905 sal_uInt8
* pEncoding
,
908 FontSubsetInfo
& rInfo
911 // in this context the pFont->GetFontId() is a valid PSP
912 // font since they are the only ones left after the PDF
913 // export has filtered its list of subsettable fonts (for
914 // which this method was created). The correct way would
915 // be to have the GlyphCache search for the ImplFontData pFont
916 psp::fontID aFont
= pFont
->GetFontId();
918 psp::PrintFontManager
& rMgr
= psp::PrintFontManager::get();
919 bool bSuccess
= rMgr
.createFontSubset( rInfo
,
929 //--------------------------------------------------------------------------
931 const void* PspGraphics::GetEmbedFontData( const ImplFontData
* pFont
, const sal_Ucs
* pUnicodes
, sal_Int32
* pWidths
, FontSubsetInfo
& rInfo
, long* pDataLen
)
933 // in this context the pFont->GetFontId() is a valid PSP
934 // font since they are the only ones left after the PDF
935 // export has filtered its list of subsettable fonts (for
936 // which this method was created). The correct way would
937 // be to have the GlyphCache search for the ImplFontData pFont
938 psp::fontID aFont
= pFont
->GetFontId();
939 return PspGraphics::DoGetEmbedFontData( aFont
, pUnicodes
, pWidths
, rInfo
, pDataLen
);
942 //--------------------------------------------------------------------------
944 void PspGraphics::FreeEmbedFontData( const void* pData
, long nLen
)
946 PspGraphics::DoFreeEmbedFontData( pData
, nLen
);
949 //--------------------------------------------------------------------------
951 const Ucs2SIntMap
* PspGraphics::GetFontEncodingVector( const ImplFontData
* pFont
, const Ucs2OStrMap
** pNonEncoded
)
953 // in this context the pFont->GetFontId() is a valid PSP
954 // font since they are the only ones left after the PDF
955 // export has filtered its list of subsettable fonts (for
956 // which this method was created). The correct way would
957 // be to have the GlyphCache search for the ImplFontData pFont
958 psp::fontID aFont
= pFont
->GetFontId();
959 return PspGraphics::DoGetFontEncodingVector( aFont
, pNonEncoded
);
962 //--------------------------------------------------------------------------
964 void PspGraphics::GetGlyphWidths( const ImplFontData
* pFont
,
966 Int32Vector
& rWidths
,
967 Ucs2UIntMap
& rUnicodeEnc
)
969 // in this context the pFont->GetFontId() is a valid PSP
970 // font since they are the only ones left after the PDF
971 // export has filtered its list of subsettable fonts (for
972 // which this method was created). The correct way would
973 // be to have the GlyphCache search for the ImplFontData pFont
974 psp::fontID aFont
= pFont
->GetFontId();
975 PspGraphics::DoGetGlyphWidths( aFont
, bVertical
, rWidths
, rUnicodeEnc
);
978 // static helpers of PspGraphics
980 const void* PspGraphics::DoGetEmbedFontData( fontID aFont
, const sal_Ucs
* pUnicodes
, sal_Int32
* pWidths
, FontSubsetInfo
& rInfo
, long* pDataLen
)
982 psp::PrintFontManager
& rMgr
= psp::PrintFontManager::get();
984 psp::PrintFontInfo aFontInfo
;
985 if( ! rMgr
.getFontInfo( aFont
, aFontInfo
) )
989 switch( aFontInfo
.m_eType
)
991 case psp::fonttype::TrueType
: rInfo
.m_nFontType
= FontSubsetInfo::SFNT_TTF
; break;
992 case psp::fonttype::Type1
: rInfo
.m_nFontType
= FontSubsetInfo::ANY_TYPE1
; break;
996 rInfo
.m_nAscent
= aFontInfo
.m_nAscend
;
997 rInfo
.m_nDescent
= aFontInfo
.m_nDescend
;
998 rInfo
.m_aPSName
= rMgr
.getPSName( aFont
);
1000 int xMin
, yMin
, xMax
, yMax
;
1001 rMgr
.getFontBoundingBox( aFont
, xMin
, yMin
, xMax
, yMax
);
1003 psp::CharacterMetric aMetrics
[256];
1004 sal_Ucs aUnicodes
[256];
1005 if( aFontInfo
.m_aEncoding
== RTL_TEXTENCODING_SYMBOL
&& aFontInfo
.m_eType
== psp::fonttype::Type1
)
1007 for( int i
= 0; i
< 256; i
++ )
1008 aUnicodes
[i
] = pUnicodes
[i
] < 0x0100 ? pUnicodes
[i
] + 0xf000 : pUnicodes
[i
];
1009 pUnicodes
= aUnicodes
;
1011 if( ! rMgr
.getMetrics( aFont
, pUnicodes
, 256, aMetrics
) )
1014 OString aSysPath
= rMgr
.getFontFileSysPath( aFont
);
1016 if( stat( aSysPath
.getStr(), &aStat
) )
1018 int fd
= open( aSysPath
.getStr(), O_RDONLY
);
1021 void* pFile
= mmap( NULL
, aStat
.st_size
, PROT_READ
, MAP_SHARED
, fd
, 0 );
1023 if( pFile
== MAP_FAILED
)
1026 *pDataLen
= aStat
.st_size
;
1028 rInfo
.m_aFontBBox
= Rectangle( Point( xMin
, yMin
), Size( xMax
-xMin
, yMax
-yMin
) );
1029 rInfo
.m_nCapHeight
= yMax
; // Well ...
1031 for( int i
= 0; i
< 256; i
++ )
1033 pWidths
[i
] = (aMetrics
[i
].width
> 0 ? aMetrics
[i
].width
: 0);
1038 void PspGraphics::DoFreeEmbedFontData( const void* pData
, long nLen
)
1041 munmap( (char*)pData
, nLen
);
1044 const Ucs2SIntMap
* PspGraphics::DoGetFontEncodingVector( fontID aFont
, const Ucs2OStrMap
** pNonEncoded
)
1046 psp::PrintFontManager
& rMgr
= psp::PrintFontManager::get();
1048 psp::PrintFontInfo aFontInfo
;
1049 if( ! rMgr
.getFontInfo( aFont
, aFontInfo
) )
1052 *pNonEncoded
= NULL
;
1056 return rMgr
.getEncodingMap( aFont
, pNonEncoded
);
1059 void PspGraphics::DoGetGlyphWidths( psp::fontID aFont
,
1061 Int32Vector
& rWidths
,
1062 Ucs2UIntMap
& rUnicodeEnc
)
1064 psp::PrintFontManager
& rMgr
= psp::PrintFontManager::get();
1065 rMgr
.getGlyphWidths( aFont
, bVertical
, rWidths
, rUnicodeEnc
);
1068 // ----------------------------------------------------------------------------
1070 FontWidth
PspGraphics::ToFontWidth (psp::width::type eWidth
)
1074 case psp::width::UltraCondensed
: return WIDTH_ULTRA_CONDENSED
;
1075 case psp::width::ExtraCondensed
: return WIDTH_EXTRA_CONDENSED
;
1076 case psp::width::Condensed
: return WIDTH_CONDENSED
;
1077 case psp::width::SemiCondensed
: return WIDTH_SEMI_CONDENSED
;
1078 case psp::width::Normal
: return WIDTH_NORMAL
;
1079 case psp::width::SemiExpanded
: return WIDTH_SEMI_EXPANDED
;
1080 case psp::width::Expanded
: return WIDTH_EXPANDED
;
1081 case psp::width::ExtraExpanded
: return WIDTH_EXTRA_EXPANDED
;
1082 case psp::width::UltraExpanded
: return WIDTH_ULTRA_EXPANDED
;
1085 return WIDTH_DONTKNOW
;
1088 FontWeight
PspGraphics::ToFontWeight (psp::weight::type eWeight
)
1092 case psp::weight::Thin
: return WEIGHT_THIN
;
1093 case psp::weight::UltraLight
: return WEIGHT_ULTRALIGHT
;
1094 case psp::weight::Light
: return WEIGHT_LIGHT
;
1095 case psp::weight::SemiLight
: return WEIGHT_SEMILIGHT
;
1096 case psp::weight::Normal
: return WEIGHT_NORMAL
;
1097 case psp::weight::Medium
: return WEIGHT_MEDIUM
;
1098 case psp::weight::SemiBold
: return WEIGHT_SEMIBOLD
;
1099 case psp::weight::Bold
: return WEIGHT_BOLD
;
1100 case psp::weight::UltraBold
: return WEIGHT_ULTRABOLD
;
1101 case psp::weight::Black
: return WEIGHT_BLACK
;
1104 return WEIGHT_DONTKNOW
;
1107 FontPitch
PspGraphics::ToFontPitch (psp::pitch::type ePitch
)
1111 case psp::pitch::Fixed
: return PITCH_FIXED
;
1112 case psp::pitch::Variable
: return PITCH_VARIABLE
;
1115 return PITCH_DONTKNOW
;
1118 FontItalic
PspGraphics::ToFontItalic (psp::italic::type eItalic
)
1122 case psp::italic::Upright
: return ITALIC_NONE
;
1123 case psp::italic::Oblique
: return ITALIC_OBLIQUE
;
1124 case psp::italic::Italic
: return ITALIC_NORMAL
;
1127 return ITALIC_DONTKNOW
;
1130 FontFamily
PspGraphics::ToFontFamily (psp::family::type eFamily
)
1134 case psp::family::Decorative
: return FAMILY_DECORATIVE
;
1135 case psp::family::Modern
: return FAMILY_MODERN
;
1136 case psp::family::Roman
: return FAMILY_ROMAN
;
1137 case psp::family::Script
: return FAMILY_SCRIPT
;
1138 case psp::family::Swiss
: return FAMILY_SWISS
;
1139 case psp::family::System
: return FAMILY_SYSTEM
;
1142 return FAMILY_DONTKNOW
;
1145 ImplDevFontAttributes
PspGraphics::Info2DevFontAttributes( const psp::FastPrintFontInfo
& rInfo
)
1147 ImplDevFontAttributes aDFA
;
1148 aDFA
.maName
= rInfo
.m_aFamilyName
;
1149 aDFA
.maStyleName
= rInfo
.m_aStyleName
;
1150 aDFA
.meFamily
= ToFontFamily (rInfo
.m_eFamilyStyle
);
1151 aDFA
.meWeight
= ToFontWeight (rInfo
.m_eWeight
);
1152 aDFA
.meItalic
= ToFontItalic (rInfo
.m_eItalic
);
1153 aDFA
.meWidthType
= ToFontWidth (rInfo
.m_eWidth
);
1154 aDFA
.mePitch
= ToFontPitch (rInfo
.m_ePitch
);
1155 aDFA
.mbSymbolFlag
= (rInfo
.m_aEncoding
== RTL_TEXTENCODING_SYMBOL
);
1157 switch (rInfo
.m_eEmbeddedbitmap
)
1160 aDFA
.meEmbeddedBitmap
= EMBEDDEDBITMAP_DONTKNOW
;
1162 case psp::fcstatus::istrue
:
1163 aDFA
.meEmbeddedBitmap
= EMBEDDEDBITMAP_TRUE
;
1165 case psp::fcstatus::isfalse
:
1166 aDFA
.meEmbeddedBitmap
= EMBEDDEDBITMAP_FALSE
;
1170 switch (rInfo
.m_eAntialias
)
1173 aDFA
.meAntiAlias
= ANTIALIAS_DONTKNOW
;
1175 case psp::fcstatus::istrue
:
1176 aDFA
.meAntiAlias
= ANTIALIAS_TRUE
;
1178 case psp::fcstatus::isfalse
:
1179 aDFA
.meAntiAlias
= ANTIALIAS_FALSE
;
1183 switch( rInfo
.m_eType
)
1185 case psp::fonttype::Builtin
:
1186 aDFA
.mnQuality
= 1024;
1187 aDFA
.mbDevice
= true;
1188 aDFA
.mbSubsettable
= false;
1189 aDFA
.mbEmbeddable
= false;
1191 case psp::fonttype::TrueType
:
1192 aDFA
.mnQuality
= 512;
1193 aDFA
.mbDevice
= false;
1194 aDFA
.mbSubsettable
= true;
1195 aDFA
.mbEmbeddable
= false;
1197 case psp::fonttype::Type1
:
1199 aDFA
.mbDevice
= false;
1200 aDFA
.mbSubsettable
= false;
1201 aDFA
.mbEmbeddable
= true;
1205 aDFA
.mbDevice
= false;
1206 aDFA
.mbSubsettable
= false;
1207 aDFA
.mbEmbeddable
= false;
1211 aDFA
.mbOrientation
= true;
1213 // add font family name aliases
1214 ::std::list
< OUString
>::const_iterator it
= rInfo
.m_aAliases
.begin();
1215 bool bHasMapNames
= false;
1216 for(; it
!= rInfo
.m_aAliases
.end(); ++it
)
1219 aDFA
.maMapNames
.Append( ';' );
1220 aDFA
.maMapNames
.Append( (*it
).getStr() );
1221 bHasMapNames
= true;
1224 #if OSL_DEBUG_LEVEL > 2
1227 ByteString
aOrigName( aDFA
.maName
, osl_getThreadTextEncoding() );
1228 ByteString
aAliasNames( aDFA
.maMapNames
, osl_getThreadTextEncoding() );
1229 fprintf( stderr
, "using alias names \"%s\" for font family \"%s\"\n",
1230 aAliasNames
.GetBuffer(), aOrigName
.GetBuffer() );
1237 // -----------------------------------------------------------------------
1239 void PspGraphics::AnnounceFonts( ImplDevFontList
* pFontList
, const psp::FastPrintFontInfo
& aInfo
)
1243 if( aInfo
.m_eType
== psp::fonttype::TrueType
)
1245 // asian type 1 fonts are not known
1246 psp::PrintFontManager
& rMgr
= psp::PrintFontManager::get();
1247 ByteString
aFileName( rMgr
.getFontFileSysPath( aInfo
.m_nID
) );
1248 int nPos
= aFileName
.SearchBackward( '_' );
1249 if( nPos
== STRING_NOTFOUND
|| aFileName
.GetChar( nPos
+1 ) == '.' )
1253 static const char* pLangBoost
= NULL
;
1254 static bool bOnce
= true;
1258 const LanguageType aLang
= Application::GetSettings().GetUILanguage();
1261 case LANGUAGE_JAPANESE
:
1264 case LANGUAGE_CHINESE
:
1265 case LANGUAGE_CHINESE_SIMPLIFIED
:
1266 case LANGUAGE_CHINESE_SINGAPORE
:
1269 case LANGUAGE_CHINESE_TRADITIONAL
:
1270 case LANGUAGE_CHINESE_HONGKONG
:
1271 case LANGUAGE_CHINESE_MACAU
:
1274 case LANGUAGE_KOREAN
:
1275 case LANGUAGE_KOREAN_JOHAB
:
1282 if( aFileName
.Copy( nPos
+1, 3 ).EqualsIgnoreCaseAscii( pLangBoost
) )
1287 ImplPspFontData
* pFD
= new ImplPspFontData( aInfo
);
1288 pFD
->mnQuality
+= nQuality
;
1289 pFontList
->Add( pFD
);
1292 bool PspGraphics::filterText( const String
& rOrig
, String
& rNewText
, xub_StrLen nIndex
, xub_StrLen
& rLen
, xub_StrLen
& rCutStart
, xub_StrLen
& rCutStop
)
1297 rCutStop
= rCutStart
= STRING_NOTFOUND
;
1299 #define FAX_PHONE_TOKEN "@@#"
1300 #define FAX_PHONE_TOKEN_LENGTH 3
1301 #define FAX_END_TOKEN "@@"
1302 #define FAX_END_TOKEN_LENGTH 2
1305 bool bStarted
= false;
1306 bool bStopped
= false;
1309 USHORT nStop
= rLen
;
1310 String aPhone
= rOrig
.Copy( nIndex
, rLen
);
1312 if( ! m_bPhoneCollectionActive
)
1314 if( ( nPos
= aPhone
.SearchAscii( FAX_PHONE_TOKEN
) ) != STRING_NOTFOUND
)
1317 m_bPhoneCollectionActive
= true;
1318 m_aPhoneCollection
.Erase();
1323 if( m_bPhoneCollectionActive
)
1326 nPos
= bStarted
? nStart
+ FAX_PHONE_TOKEN_LENGTH
: 0;
1327 if( ( nPos
= aPhone
.SearchAscii( FAX_END_TOKEN
, nPos
) ) != STRING_NOTFOUND
)
1329 m_bPhoneCollectionActive
= false;
1330 nStop
= nPos
+ FAX_END_TOKEN_LENGTH
;
1333 int nTokenStart
= nStart
+ (bStarted
? FAX_PHONE_TOKEN_LENGTH
: 0);
1334 int nTokenStop
= nStop
- (bStopped
? FAX_END_TOKEN_LENGTH
: 0);
1335 m_aPhoneCollection
+= aPhone
.Copy( nTokenStart
, nTokenStop
- nTokenStart
);
1336 if( ! m_bPhoneCollectionActive
)
1338 m_pPhoneNr
->AppendAscii( "<Fax#>" );
1339 m_pPhoneNr
->Append( m_aPhoneCollection
);
1340 m_pPhoneNr
->AppendAscii( "</Fax#>" );
1341 m_aPhoneCollection
.Erase();
1344 if( m_aPhoneCollection
.Len() > 1024 )
1346 m_bPhoneCollectionActive
= false;
1347 m_aPhoneCollection
.Erase();
1351 if( bRet
&& m_bSwallowFaxNo
)
1353 rLen
-= nStop
- nStart
;
1354 rCutStart
= nStart
+nIndex
;
1355 rCutStop
= nStop
+nIndex
;
1357 rNewText
= rOrig
.Copy( 0, rCutStart
);
1358 rNewText
+= rOrig
.Copy( rCutStop
);
1361 return bRet
&& m_bSwallowFaxNo
;
1364 SystemFontData
PspGraphics::GetSysFontData( int nFallbacklevel
) const
1366 SystemFontData aSysFontData
;
1368 if (nFallbacklevel
>= MAX_FALLBACK
) nFallbacklevel
= MAX_FALLBACK
- 1;
1369 if (nFallbacklevel
< 0 ) nFallbacklevel
= 0;
1371 aSysFontData
.nSize
= sizeof( SystemFontData
);
1372 aSysFontData
.nFontId
= 0;
1373 aSysFontData
.nFontFlags
= 0;
1374 aSysFontData
.bFakeBold
= false;
1375 aSysFontData
.bFakeItalic
= false;
1376 aSysFontData
.bAntialias
= true;
1377 return aSysFontData
;
1380 SystemGraphicsData
PspGraphics::GetGraphicsData() const
1382 SystemGraphicsData aRes
;
1383 aRes
.nSize
= sizeof(aRes
);
1385 aRes
.pRenderFormat
= 0;