summaryrefslogtreecommitdiff
path: root/vcl/unx/source
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/unx/source')
-rw-r--r--vcl/unx/source/app/saldisp.cxx10
-rw-r--r--vcl/unx/source/app/salinst.cxx2
-rw-r--r--vcl/unx/source/gdi/makefile.mk10
-rw-r--r--vcl/unx/source/gdi/salgdi.cxx9
-rw-r--r--vcl/unx/source/gdi/salgdi3.cxx578
-rw-r--r--vcl/unx/source/gdi/xfont.cxx780
-rw-r--r--vcl/unx/source/gdi/xlfd_attr.cxx686
-rw-r--r--vcl/unx/source/gdi/xlfd_attr.hxx228
-rw-r--r--vcl/unx/source/gdi/xlfd_extd.cxx1001
-rw-r--r--vcl/unx/source/gdi/xlfd_extd.hxx272
-rw-r--r--vcl/unx/source/gdi/xlfd_smpl.cxx268
-rw-r--r--vcl/unx/source/gdi/xlfd_smpl.hxx92
-rw-r--r--vcl/unx/source/window/salframe.cxx2
13 files changed, 6 insertions, 3932 deletions
diff --git a/vcl/unx/source/app/saldisp.cxx b/vcl/unx/source/app/saldisp.cxx
index 354c4d433d42..92d5f75f7315 100644
--- a/vcl/unx/source/app/saldisp.cxx
+++ b/vcl/unx/source/app/saldisp.cxx
@@ -375,11 +375,6 @@ sal_GetServerVendor( Display *p_display )
{ vendor_none, NULL, 0 },
};
-#ifdef _USE_PRINT_EXTENSION_
- if ( ! XSalIsDisplay( p_display ) )
- return vendor_xprinter;
-#endif
-
// handle regular server vendors
char *p_name = ServerVendor( p_display );
vendor_t *p_vendor;
@@ -508,7 +503,6 @@ BOOL SalDisplay::BestVisual( Display *pDisplay,
SalDisplay::SalDisplay( Display *display ) :
mpInputMethod( NULL ),
- mpFallbackFactory ( NULL ),
pDisp_( display ),
m_pWMAdaptor( NULL ),
m_pDtIntegrator( NULL ),
@@ -557,7 +551,6 @@ void SalDisplay::doDestruct()
m_pDtIntegrator = NULL;
X11SalBitmap::ImplDestroyCache();
X11SalGraphics::releaseGlyphPeer();
- DestroyFontCache();
if( IsDisplay() )
{
@@ -814,8 +807,6 @@ void SalDisplay::Init()
eWindowManager_ = otherwm;
nProperties_ = PROPERTY_DEFAULT;
hEventGuard_ = NULL;
- m_pFontCache = NULL;
- mpFontList = (XlfdStorage*)NULL;
mpFactory = (AttributeProvider*)NULL;
m_pCapture = NULL;
m_bXinerama = false;
@@ -2575,6 +2566,7 @@ void SalDisplay::PrintInfo() const
fprintf( stderr, "\tProperties \t0x%lX\n", GetProperties() );
if( eWindowManager_ != otherwm )
fprintf( stderr, "\tWindowmanager \t%d\n", eWindowManager_ );
+ fprintf( stderr, "\tWMName \t%s\n", rtl::OUStringToOString( getWMAdaptor()->getWindowManagerName(), osl_getThreadTextEncoding() ).getStr() );
}
fprintf( stderr, "Screen\n" );
fprintf( stderr, "\tResolution/Size \t%ld*%ld %ld*%ld %.1lf\"\n",
diff --git a/vcl/unx/source/app/salinst.cxx b/vcl/unx/source/app/salinst.cxx
index 88af0b70ef7e..f125d5f98fa6 100644
--- a/vcl/unx/source/app/salinst.cxx
+++ b/vcl/unx/source/app/salinst.cxx
@@ -45,7 +45,7 @@
#include "sm.hxx"
#include "vcl/salwtype.hxx"
-#include "vcl/salatype.hxx"
+#include "vcl/apptypes.hxx"
#include "vcl/helper.hxx"
#include <tools/solarmutex.hxx>
#include "vos/mutex.hxx"
diff --git a/vcl/unx/source/gdi/makefile.mk b/vcl/unx/source/gdi/makefile.mk
index 536aadcac015..123fcbcf9131 100644
--- a/vcl/unx/source/gdi/makefile.mk
+++ b/vcl/unx/source/gdi/makefile.mk
@@ -53,29 +53,19 @@ SLOFILES= \
$(SLO)$/salvd.obj \
$(SLO)$/dtint.obj \
$(SLO)$/salcvt.obj \
- $(SLO)$/xfont.obj \
- $(SLO)$/xlfd_attr.obj \
- $(SLO)$/xlfd_extd.obj \
- $(SLO)$/xlfd_smpl.obj \
$(SLO)$/salgdi3.obj \
$(SLO)$/gcach_xpeer.obj \
$(SLO)$/xrender_peer.obj \
$(SLO)$/pspgraphics.obj
EXCEPTIONSFILES=\
- $(SLO)$/xlfd_extd.obj \
$(SLO)$/salgdi.obj \
$(SLO)$/salbmp.obj \
$(SLO)$/salgdi3.obj \
$(SLO)$/salcvt.obj
-.IF "$(USE_XPRINT)" == "TRUE"
-CFLAGS+=-D_USE_PRINT_EXTENSION_=1
-SLOFILES+=$(SLO)$/xprintext.obj
-.ELSE
SLOFILES+=$(SLO)$/salprnpsp.obj
EXCEPTIONSFILES+=$(SLO)$/salprnpsp.obj
-.ENDIF
.IF "$(OS)"=="SOLARIS"
SLOFILES+=$(SLO)$/cdeint.obj
diff --git a/vcl/unx/source/gdi/salgdi.cxx b/vcl/unx/source/gdi/salgdi.cxx
index 9215f2e25b16..9dfbfff22d03 100644
--- a/vcl/unx/source/gdi/salgdi.cxx
+++ b/vcl/unx/source/gdi/salgdi.cxx
@@ -113,10 +113,7 @@ X11SalGraphics::X11SalGraphics()
pFontGC_ = NULL;
for( int i = 0; i < MAX_FALLBACK; ++i )
- {
- mXFont[i] = NULL;
mpServerFont[i] = NULL;
- }
nTextPixel_ = 0;
nTextColor_ = MAKE_SALCOLOR( 0x00, 0x00, 0x00 ); // Black
@@ -338,13 +335,8 @@ GC X11SalGraphics::SelectBrush()
{
XSetFillStyle ( pDisplay, pBrushGC_, FillSolid );
XSetForeground( pDisplay, pBrushGC_, nBrushPixel_ );
- #if defined(_USE_PRINT_EXTENSION_)
- XSetBackground( pDisplay, pBrushGC_,
- WhitePixel(pDisplay, DefaultScreen(pDisplay)) );
- #else
if( bPrinter_ )
XSetTile( pDisplay, pBrushGC_, None );
- #endif
}
else
{
@@ -757,6 +749,7 @@ void X11SalGraphics::SetXORMode( bool bSet, bool )
{
bXORMode_ = bSet;
bPenGC_ = FALSE;
+ bFontGC_ = FALSE;
bBrushGC_ = FALSE;
bMonoGC_ = FALSE;
bCopyGC_ = FALSE;
diff --git a/vcl/unx/source/gdi/salgdi3.cxx b/vcl/unx/source/gdi/salgdi3.cxx
index 62e575ebc5ef..d9f81c0f67d2 100644
--- a/vcl/unx/source/gdi/salgdi3.cxx
+++ b/vcl/unx/source/gdi/salgdi3.cxx
@@ -46,11 +46,7 @@
#include "salgdi.h"
#include "pspgraphics.h"
#include "salvd.h"
-#include "xfont.hxx"
#include <vcl/sysdata.hxx>
-#include "xlfd_attr.hxx"
-#include "xlfd_smpl.hxx"
-#include "xlfd_extd.hxx"
#include "salcvt.hxx"
#include "vcl/printergfx.hxx"
@@ -112,391 +108,6 @@ struct _XRegion
};
using namespace rtl;
-// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-// ----------------------------------------------------------------------------
-//
-// manage X11 fonts and self rastered fonts
-//
-// ----------------------------------------------------------------------------
-
-#ifndef _USE_PRINT_EXTENSION_
-
-class FontLookup
-{
- public:
-
- struct hash;
- struct equal;
- typedef ::std::hash_set< FontLookup,
- FontLookup::hash,
- FontLookup::equal > fl_hashset;
-
- private:
-
- rtl::OString maName;
- FontWeight mnWeight;
- FontItalic mnItalic;
- sal_Bool mbDisplay;
-
- public:
-
- FontLookup ( ::std::list< psp::fontID >::iterator& it,
- const psp::PrintFontManager& rMgr );
- FontLookup (const Xlfd& rFont);
- FontLookup (const FontLookup &rRef) :
- maName (rRef.maName),
- mnWeight (rRef.mnWeight),
- mnItalic (rRef.mnItalic),
- mbDisplay(rRef.mbDisplay)
- {}
- ~FontLookup ()
- {}
-
- static void BuildSet (fl_hashset& rSet);
- static bool InSet (const fl_hashset& rSet, const Xlfd& rXfld);
- bool InSet (const fl_hashset& rSet) const;
-
- bool operator== (const FontLookup &rRef) const
- {
- return (abs(mnWeight - rRef.mnWeight) < 2)
- && (mnItalic == rRef.mnItalic)
- && (maName == rRef.maName)
- && (mbDisplay== rRef.mbDisplay);
- }
- FontLookup& operator= (const FontLookup &rRef)
- {
- mnWeight = rRef.mnWeight;
- mnItalic = rRef.mnItalic;
- maName = rRef.maName;
- mbDisplay= rRef.mbDisplay;
-
- return *this;
- }
- size_t Hash() const
- {
- return maName.hashCode ();
- }
-
- struct equal
- {
- bool operator()(const FontLookup &r1, const FontLookup &r2) const
- {
- return r1 == r2;
- }
- };
- struct hash
- {
- size_t operator()(const FontLookup &rArg) const
- {
- return rArg.Hash();
- }
- };
-};
-
-FontLookup::FontLookup ( ::std::list< psp::fontID >::iterator& it,
- const psp::PrintFontManager& rMgr )
-{
- psp::FastPrintFontInfo aInfo;
- if (rMgr.getFontFastInfo (*it, aInfo))
- {
- mnItalic = PspGraphics::ToFontItalic (aInfo.m_eItalic);
- mnWeight = PspGraphics::ToFontWeight (aInfo.m_eWeight);
- mbDisplay= aInfo.m_eType == psp::fonttype::Builtin
- || aInfo.m_eType == psp::fonttype::Unknown ? False : True;
- maName = rtl::OUStringToOString
- ( aInfo.m_aFamilyName,
- RTL_TEXTENCODING_ISO_8859_1).toAsciiLowerCase();
-
- sal_Int32 n_length = maName.getLength();
- const sal_Char* p_from = maName.getStr();
- sal_Char* p_to = (sal_Char*)alloca (n_length + 1);
-
- sal_Int32 i, j;
- for (i = 0, j = 0; i < n_length; i++)
- {
- if ( p_from[i] != ' ' )
- p_to[j++] = p_from[i];
- }
- maName = rtl::OString (p_to, j);
- if (mnItalic == ITALIC_OBLIQUE)
- mnItalic = ITALIC_NORMAL;
- }
- else
- {
- mnItalic = ITALIC_DONTKNOW;
- mnWeight = WEIGHT_DONTKNOW;
- mbDisplay= False;
- }
-}
-
-FontLookup::FontLookup (const Xlfd& rFont)
-{
- AttributeProvider* pFactory = rFont.mpFactory;
- Attribute* pAttr;
-
- pAttr = pFactory->RetrieveSlant (rFont.mnSlant);
- mnItalic = (FontItalic)pAttr->GetValue();
- pAttr = pFactory->RetrieveWeight (rFont.mnWeight);
- mnWeight = (FontWeight)pAttr->GetValue();
- pAttr = pFactory->RetrieveFamily (rFont.mnFamily);
- maName = pAttr->GetKey();
-
- if (mnItalic == ITALIC_OBLIQUE)
- mnItalic = ITALIC_NORMAL;
-
- mbDisplay = True;
-}
-
-void
-FontLookup::BuildSet (FontLookup::fl_hashset &rSet)
-{
- ::std::list< psp::fontID > aIdList;
-
- psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
- rMgr.getFontList( aIdList, NULL, false );
-
- ::std::list< psp::fontID >::iterator it;
- for (it = aIdList.begin(); it != aIdList.end(); ++it)
- {
- FontLookup aItem (it, rMgr);
- rSet.insert (aItem);
- }
-}
-
-bool
-FontLookup::InSet (const FontLookup::fl_hashset& rSet) const
-{
- fl_hashset::const_iterator it = rSet.find(*this);
- return it == rSet.end() ? false : true;
-}
-
-bool
-FontLookup::InSet (const FontLookup::fl_hashset& rSet, const Xlfd& rXlfd)
-{
- FontLookup aNeedle (rXlfd);
- return aNeedle.InSet (rSet);
-}
-
-#endif
-
-// ----------------------------------------------------------------------------
-//
-// SalDisplay
-//
-// ----------------------------------------------------------------------------
-
-XlfdStorage*
-SalDisplay::GetXlfdList() const
-{
- if ( mpFontList != NULL )
- {
- return mpFontList;
- }
- else
- {
- const_cast<SalDisplay*>(this)->mpFactory = new AttributeProvider;
- const_cast<SalDisplay*>(this)->mpFontList = new XlfdStorage;
- const_cast<SalDisplay*>(this)->mpFallbackFactory = new VirtualXlfd;
-
- int i, nFontCount;
- const int nMaxCount = 64 * 1024 - 1;
- Display *pDisplay = GetDisplay();
- char **ppFontList = XListFonts(pDisplay, "-*", nMaxCount, &nFontCount);
-
- //
- // create a list of simple Xlfd font information
- //
-
- Xlfd *pXlfdList = (Xlfd*)malloc( nFontCount * sizeof(Xlfd) );
- int nXlfdCount = 0;
-
- for ( i = 0; i < nFontCount; i++ )
- {
- if ( pXlfdList[ nXlfdCount ].FromString(ppFontList[i], mpFactory) )
- ++nXlfdCount;
- }
-
- XFreeFontNames( ppFontList );
-
- mpFactory->AddClassification();
- // add some pretty print description
- mpFactory->AddAnnotation();
- // misc feature checking
- mpFactory->TagFeature();
-
- // sort according to font style
- qsort( pXlfdList, nXlfdCount, sizeof(Xlfd), XlfdCompare );
-
-#ifndef _USE_PRINT_EXTENSION_
- // create a list of fonts already managed by the fontmanager
- FontLookup::fl_hashset aSet;
- FontLookup::BuildSet (aSet);
-#endif
-
- //
- // create a font list with merged encoding information
- //
-
- BitmapXlfdStorage aBitmapList;
- ScalableXlfd *pScalableFont = NULL;
-
- int nFrom = 0;
- for ( i = 0; i < nXlfdCount; i++ )
- {
- // exclude openlook glyph and cursor
- Attribute *pAttr = mpFactory->RetrieveFamily(pXlfdList[i].mnFamily);
- if ( pAttr->HasFeature( XLFD_FEATURE_OL_GLYPH
- | XLFD_FEATURE_OL_CURSOR) )
- continue;
- // exclude fonts with unknown encoding
- if ( pXlfdList[i].GetEncoding() == RTL_TEXTENCODING_DONTKNOW )
- continue;
- // exclude "interface system" and "interface user"
- if (pAttr->HasFeature( XLFD_FEATURE_APPLICATION_FONT ) )
- continue;
- // exclude fonts already managed by fontmanager, anyway keep
- // gui fonts: they are candidates for GetInterfaceFont ()
- if (pXlfdList[i].Fonttype() == eTypeScalable)
- ((VirtualXlfd*)mpFallbackFactory)->FilterInterfaceFont (pXlfdList + i);
-#ifndef _USE_PRINT_EXTENSION_
- if (FontLookup::InSet (aSet, pXlfdList[i]))
- continue;
-#endif
- Bool bSameOutline = pXlfdList[i].SameFontoutline(pXlfdList + nFrom);
- XlfdFonttype eType = pXlfdList[i].Fonttype();
-
- // flush the old merged font list if the name doesn't match any more
- if ( !bSameOutline )
- {
- mpFontList->Add( pScalableFont );
- mpFontList->Add( &aBitmapList );
- pScalableFont = NULL;
- aBitmapList.Reset();
- }
-
- // merge the font or generate a new one
- switch( eType )
- {
- case eTypeScalable:
- if ( pScalableFont == NULL )
- pScalableFont = new ScalableXlfd;
- pScalableFont->AddEncoding(pXlfdList + i);
- break;
-
- case eTypeBitmap:
- aBitmapList.AddBitmapFont( pXlfdList + i );
- break;
-
- case eTypeScalableBitmap:
- // ignore scaled X11 bitmap fonts because they look too ugly
- default:
- break;
- }
-
- nFrom = i;
- }
-
- // flush the merged list into the global list
- mpFontList->Add( pScalableFont );
- mpFontList->Add( &aBitmapList );
- if (mpFallbackFactory->NumEncodings() > 0)
- mpFontList->Add( mpFallbackFactory );
- // cleanup the list of simple font information
- if ( pXlfdList != NULL )
- free( pXlfdList );
-
- return mpFontList;
- }
-}
-
-// ---------------------------------------------------------------------------
-
-ExtendedFontStruct*
-SalDisplay::GetFont( const ExtendedXlfd *pRequestedFont,
- const Size& rPixelSize, sal_Bool bVertical ) const
-{
- // TODO: either get rid of X11 fonts or get rid of the non-hashmapped cache
- if( !m_pFontCache )
- {
- m_pFontCache = new SalFontCache( 64, 64, 16 ); // ???
- }
- else
- {
- ExtendedFontStruct *pItem;
- for ( pItem = m_pFontCache->First();
- pItem != NULL;
- pItem = m_pFontCache->Next() )
- {
- if ( pItem->Match(pRequestedFont, rPixelSize, bVertical) )
- {
- if( m_pFontCache->GetCurPos() )
- {
- m_pFontCache->Remove( pItem );
- m_pFontCache->Insert( pItem, 0UL );
- }
- return pItem;
- }
- }
- }
-
- // before we expand the cache, we look for very old and unused items
- if( m_pFontCache->Count() >= 64 )
- {
- ExtendedFontStruct *pItem;
- for ( pItem = m_pFontCache->Last();
- pItem != NULL;
- pItem = m_pFontCache->Prev() )
- {
- if( 1 == pItem->GetRefCount() )
- {
- m_pFontCache->Remove( pItem );
- pItem->ReleaseRef();
- if( m_pFontCache->Count() < 64 )
- break;
- }
- }
- }
-
- ExtendedFontStruct *pItem = new ExtendedFontStruct( GetDisplay(),
- rPixelSize, bVertical,
- const_cast<ExtendedXlfd*>(pRequestedFont) );
- m_pFontCache->Insert( pItem, 0UL );
- pItem->AddRef();
-
- return pItem;
-}
-
-// ---------------------------------------------------------------------------
-
-void
-SalDisplay::DestroyFontCache()
-{
- if( m_pFontCache )
- {
- ExtendedFontStruct *pItem = m_pFontCache->First();
- while( pItem )
- {
- delete pItem;
- pItem = m_pFontCache->Next();
- }
- delete m_pFontCache;
- }
- if( mpFontList )
- {
- mpFontList->Dispose();
- delete mpFontList;
- }
- if ( mpFactory )
- {
- delete mpFactory;
- }
-
- m_pFontCache = (SalFontCache*)NULL;
- mpFontList = (XlfdStorage*)NULL;
- mpFactory = (AttributeProvider*)NULL;
-}
-
// ===========================================================================
// PspKernInfo allows on-demand-querying of psprint provided kerning info (#i29881#)
@@ -538,7 +149,7 @@ void PspKernInfo::Initialize() const
// ----------------------------------------------------------------------------
GC
-X11SalGraphics::SelectFont()
+X11SalGraphics::GetFontGC()
{
Display *pDisplay = GetXDisplay();
@@ -549,18 +160,10 @@ X11SalGraphics::SelectFont()
values.fill_rule = EvenOddRule; // Pict import/ Gradient
values.graphics_exposures = False;
values.foreground = nTextPixel_;
-#ifdef _USE_PRINT_EXTENSION_
- values.background = xColormap_->GetWhitePixel();
- pFontGC_ = XCreateGC( pDisplay, hDrawable_,
- GCSubwindowMode | GCFillRule
- | GCGraphicsExposures | GCBackground | GCForeground,
- &values );
-#else
pFontGC_ = XCreateGC( pDisplay, hDrawable_,
GCSubwindowMode | GCFillRule
| GCGraphicsExposures | GCForeground,
&values );
-#endif
}
if( !bFontGC_ )
{
@@ -594,8 +197,6 @@ bool X11SalGraphics::setFont( const ImplFontSelectData *pEntry, int nFallbackLev
// release all no longer needed font resources
for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i )
{
- mXFont[i] = NULL; // ->ReleaseRef()
-
if( mpServerFont[i] != NULL )
{
// old server side font is no longer referenced
@@ -614,18 +215,6 @@ bool X11SalGraphics::setFont( const ImplFontSelectData *pEntry, int nFallbackLev
if( !pEntry->mpFontData )
return false;
- // handle the request for a native X11-font
- if( ImplX11FontData::CheckFontData( *pEntry->mpFontData ) )
- {
- const ImplX11FontData* pRequestedFont = static_cast<const ImplX11FontData*>( pEntry->mpFontData );
- const ExtendedXlfd& rX11Font = pRequestedFont->GetExtendedXlfd();
-
- Size aReqSize( pEntry->mnWidth, pEntry->mnHeight );
- mXFont[ nFallbackLevel ] = GetDisplay()->GetFont( &rX11Font, aReqSize, bFontVertical_ );
- bFontGC_ = FALSE;
- return true;
- }
-
// handle the request for a non-native X11-font => use the GlyphCache
ServerFont* pServerFont = GlyphCache::GetInstance().CacheFont( *pEntry );
if( pServerFont != NULL )
@@ -674,83 +263,6 @@ void ImplServerFontEntry::HandleFontOptions( void )
//--------------------------------------------------------------------------
-inline sal_Unicode SwapBytes( const sal_Unicode nIn )
-{
- return ((nIn >> 8) & 0x00ff) | ((nIn & 0x00ff) << 8);
-}
-
-// draw string in a specific multibyte encoding
-static void
-ConvertTextItem16( XTextItem16* pTextItem, rtl_TextEncoding nEncoding )
-{
- if ( (pTextItem == NULL) || (pTextItem->nchars <= 0) )
- return;
-
- SalConverterCache* pCvt = SalConverterCache::GetInstance();
- // convert the string into the font encoding
- sal_Size nSize;
- sal_Size nBufferSize = pTextItem->nchars * 2;
- sal_Char *pBuffer = (sal_Char*)alloca( nBufferSize );
-
- nSize = pCvt->ConvertStringUTF16( (sal_Unicode*)pTextItem->chars, pTextItem->nchars,
- pBuffer, nBufferSize, nEncoding);
-
- sal_Char *pTextChars = (sal_Char*)pTextItem->chars;
- unsigned int n = 0, m = 0;
-
- if ( nEncoding == RTL_TEXTENCODING_GB_2312
- || nEncoding == RTL_TEXTENCODING_GBT_12345
- || nEncoding == RTL_TEXTENCODING_GBK
- || nEncoding == RTL_TEXTENCODING_BIG5 )
- {
- // GB and Big5 needs special treatment since chars can be single or
- // double byte: encoding is
- // [ 0x00 - 0x7f ] | [ 0x81 - 0xfe ] [ 0x40 - 0x7e 0x80 - 0xfe ]
- while ( n < nSize )
- {
- if ( (unsigned char)pBuffer[ n ] < 0x80 )
- {
- pTextChars[ m++ ] = 0x0;
- pTextChars[ m++ ] = pBuffer[ n++ ];
- }
- else
- {
- pTextChars[ m++ ] = pBuffer[ n++ ];
- pTextChars[ m++ ] = pBuffer[ n++ ];
- }
- }
- pTextItem->nchars = m / 2;
- }
- else
- if ( pCvt->IsSingleByteEncoding(nEncoding) )
- {
- // Single Byte encoding has to be padded
- while ( n < nSize )
- {
- pTextChars[ m++ ] = 0x0;
- pTextChars[ m++ ] = pBuffer[ n++ ];
- }
- pTextItem->nchars = nSize;
- }
- else
- {
- while ( n < nSize )
- {
- pTextChars[ m++ ] = pBuffer[ n++ ];
- }
- pTextItem->nchars = nSize / 2;
- }
-
- // XXX FIXME
- if ( (nEncoding == RTL_TEXTENCODING_GB_2312)
- || (nEncoding == RTL_TEXTENCODING_EUC_KR) )
- {
- for (unsigned int n_char = 0; n_char < m; n_char++ )
- pTextChars[ n_char ] &= 0x7F;
- }
-}
-
-//--------------------------------------------------------------------------
namespace {
class CairoWrapper
@@ -1289,7 +801,7 @@ bool X11SalGraphics::DrawServerAAForcedString( const ServerFontLayout& rLayout )
}
// prepare context
- GC nGC = SelectFont();
+ GC nGC = GetFontGC();
XGCValues aGCVal;
XGetGCValues( pDisplay, nGC, GCForeground, &aGCVal );
@@ -1376,7 +888,7 @@ void X11SalGraphics::DrawServerSimpleFontString( const ServerFontLayout& rSalLay
X11GlyphPeer& rGlyphPeer = X11GlyphCache::GetInstance().GetPeer();
Display* pDisplay = GetXDisplay();
- GC nGC = SelectFont();
+ GC nGC = GetFontGC();
XGCValues aGCVal;
aGCVal.fill_style = FillStippled;
@@ -1439,61 +951,6 @@ void X11SalGraphics::DrawServerFontLayout( const ServerFontLayout& rLayout )
//--------------------------------------------------------------------------
-void X11SalGraphics::DrawStringUCS2MB( ExtendedFontStruct& rFont,
- const Point& rPoint, const sal_Unicode* pStr, int nLength )
-{
- Display* pDisplay = GetXDisplay();
- GC nGC = SelectFont();
-
- if( rFont.GetAsciiEncoding() == RTL_TEXTENCODING_UNICODE )
- {
- // plain Unicode, can handle all chars and can be handled straight forward
- XFontStruct* pFontStruct = rFont.GetFontStruct( RTL_TEXTENCODING_UNICODE );
- if( !pFontStruct )
- return;
-
- XSetFont( pDisplay, nGC, pFontStruct->fid );
-
- #ifdef OSL_LITENDIAN
- sal_Unicode *pBuffer = (sal_Unicode*)alloca( nLength * sizeof(sal_Unicode) );
- for ( int i = 0; i < nLength; i++ )
- pBuffer[ i ] = SwapBytes(pStr[ i ]) ;
- #else
- sal_Unicode *pBuffer = const_cast<sal_Unicode*>(pStr);
- #endif
-
- XDrawString16( pDisplay, hDrawable_, nGC, rPoint.X(), rPoint.Y(), (XChar2b*)pBuffer, nLength );
- }
- else
- {
- XTextItem16 *pTextItem = (XTextItem16*)alloca( nLength * sizeof(XTextItem16) );
- XChar2b *pMBChar = (XChar2b*)pStr;
- int nItem = 0;
-
- DBG_ASSERT( nLength<=1, "#i49902# DrawStringUCS2MB with nLength>1 => problems with XOrg6.8.[0123]");
-
- for( int nChar = 0; nChar < nLength; ++nChar )
- {
- rtl_TextEncoding nEnc;
- XFontStruct* pFontStruct = rFont.GetFontStruct( pStr[nChar], &nEnc );
- if( !pFontStruct )
- continue;
-
- pTextItem[ nItem ].chars = pMBChar + nChar;
- pTextItem[ nItem ].delta = 0;
- pTextItem[ nItem ].font = pFontStruct->fid;
- pTextItem[ nItem ].nchars = 1;
-
- ConvertTextItem16( &pTextItem[ nItem ], nEnc );
- ++nItem;
- }
-
- XDrawText16( pDisplay, hDrawable_, nGC, rPoint.X(), rPoint.Y(), pTextItem, nItem );
- }
-}
-
-//--------------------------------------------------------------------------
-
const ImplFontCharMap* X11SalGraphics::GetImplFontCharMap() const
{
if( !mpServerFont[0] )
@@ -1575,15 +1032,6 @@ void RegisterFontSubstitutors( ImplDevFontList* );
void X11SalGraphics::GetDevFontList( ImplDevFontList *pList )
{
- // allow disabling of native X11 fonts
- static const char* pEnableX11FontStr = getenv( "SAL_ENABLE_NATIVE_XFONTS" );
- if( pEnableX11FontStr && (pEnableX11FontStr[0] != '0') )
- {
- // announce X11 fonts
- XlfdStorage* pX11FontList = GetDisplay()->GetXlfdList();
- pX11FontList->AnnounceFonts( pList );
- }
-
// prepare the GlyphCache using psprint's font infos
X11GlyphCache& rGC = X11GlyphCache::GetInstance();
@@ -1766,12 +1214,6 @@ X11SalGraphics::GetFontMetric( ImplFontMetricData *pMetric, int nFallbackLevel )
long rDummyFactor;
mpServerFont[nFallbackLevel]->FetchFontMetric( *pMetric, rDummyFactor );
}
- else if( mXFont[nFallbackLevel] != NULL )
- {
- mXFont[nFallbackLevel]->ToImplFontMetricData( pMetric );
- if ( bFontVertical_ )
- pMetric->mnOrientation = 0;
- }
}
// ---------------------------------------------------------------------------
@@ -1859,10 +1301,6 @@ SalLayout* X11SalGraphics::GetTextLayout( ImplLayoutArgs& rArgs, int nFallbackLe
#endif
pLayout = new ServerFontLayout( *mpServerFont[ nFallbackLevel ] );
}
- else if( mXFont[ nFallbackLevel ] )
- pLayout = new X11FontLayout( *mXFont[ nFallbackLevel ] );
- else
- pLayout = NULL;
return pLayout;
}
@@ -1926,7 +1364,6 @@ BOOL X11SalGraphics::CreateFontSubset(
const void* X11SalGraphics::GetEmbedFontData( const ImplFontData* pFont, const sal_Ucs* pUnicodes, sal_Int32* pWidths, FontSubsetInfo& rInfo, long* pDataLen )
{
-#ifndef _USE_PRINT_EXTENSION_
// in this context the pFont->GetFontId() is a valid PSP
// font since they are the only ones left after the PDF
// export has filtered its list of subsettable fonts (for
@@ -1934,25 +1371,19 @@ const void* X11SalGraphics::GetEmbedFontData( const ImplFontData* pFont, const s
// be to have the GlyphCache search for the ImplFontData pFont
psp::fontID aFont = pFont->GetFontId();
return PspGraphics::DoGetEmbedFontData( aFont, pUnicodes, pWidths, rInfo, pDataLen );
-#else
- return NULL;
-#endif
}
//--------------------------------------------------------------------------
void X11SalGraphics::FreeEmbedFontData( const void* pData, long nLen )
{
-#ifndef _USE_PRINT_EXTENSION_
PspGraphics::DoFreeEmbedFontData( pData, nLen );
-#endif
}
//--------------------------------------------------------------------------
const Ucs2SIntMap* X11SalGraphics::GetFontEncodingVector( const ImplFontData* pFont, const Ucs2OStrMap** pNonEncoded )
{
-#ifndef _USE_PRINT_EXTENSION_
// in this context the pFont->GetFontId() is a valid PSP
// font since they are the only ones left after the PDF
// export has filtered its list of subsettable fonts (for
@@ -1960,9 +1391,6 @@ const Ucs2SIntMap* X11SalGraphics::GetFontEncodingVector( const ImplFontData* pF
// be to have the GlyphCache search for the ImplFontData pFont
psp::fontID aFont = pFont->GetFontId();
return PspGraphics::DoGetFontEncodingVector( aFont, pNonEncoded );
-#else
- return NULL;
-#endif
}
//--------------------------------------------------------------------------
diff --git a/vcl/unx/source/gdi/xfont.cxx b/vcl/unx/source/gdi/xfont.cxx
deleted file mode 100644
index f6d19909cd4a..000000000000
--- a/vcl/unx/source/gdi/xfont.cxx
+++ /dev/null
@@ -1,780 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_vcl.hxx"
-
-#include <salunx.h>
-#include "xfont.hxx"
-#include "xlfd_extd.hxx"
-#include "salcvt.hxx"
-#include <tools/string.hxx>
-#include <vcl/outfont.hxx>
-#include <saldisp.hxx>
-#include <salgdi.h>
-
-// for GetMirroredChar
-#include <vcl/svapp.hxx>
-
-#if OSL_DEBUG_LEVEL > 1
-#include <cstdio>
-#endif
-
-#include <algorithm>
-
-#define VCLASS_ROTATE 0
-#define VCLASS_ROTATE_REVERSE 1
-#define VCLASS_TRANSFORM1 2
-#define VCLASS_TRANSFORM2 3
-#define VCLASS_CJK 4
-#define VCLASS_DONTKNOW 5
-#define VCLASS_FONT_NUM 2 // Other than rotate and rotate_reverse,
- // don't have spacial font
-
-// Select the max size of a font, which is token for real
-// This routine is (and should be) called only once, the result should be
-// stored in some static variable
-
-static int GetMaxFontHeight()
-{
- static int nMaxFontHeight = 0;
- if( nMaxFontHeight <= 0 )
- {
- const char *pFontHeight = getenv ("SAL_MAXFONTHEIGHT");
- if( pFontHeight )
- nMaxFontHeight = atoi( pFontHeight );
- static const int DEFAULT_MAXFONTHEIGHT = 250;
- if (nMaxFontHeight <= 20)
- nMaxFontHeight = DEFAULT_MAXFONTHEIGHT;
- }
-
- return nMaxFontHeight;
-}
-
-
-ExtendedFontStruct::ExtendedFontStruct( Display* pDisplay, const Size& rPixelSize,
- sal_Bool bVertical, ExtendedXlfd* pXlfd ) :
- mpDisplay( pDisplay ),
- maPixelSize( rPixelSize ),
- mfXScale(1.0), mfYScale(1.0),
- mbVertical( bVertical ),
- mnCachedEncoding( RTL_TEXTENCODING_DONTKNOW ),
- mpXlfd( pXlfd ),
- mpRangeCodes(NULL),
- mnRangeCount(-1)
-{
- if( !maPixelSize.Width() )
- maPixelSize.Width() = maPixelSize.Height();
- mnAsciiEncoding = GetAsciiEncoding (NULL);
- mnDefaultWidth = GetDefaultWidth();
-
- mpXFontStruct = (XFontStruct**)calloc( mpXlfd->NumEncodings(),
- sizeof(XFontStruct*) );
-}
-
-ExtendedFontStruct::~ExtendedFontStruct()
-{
- delete[] mpRangeCodes;
-
- for ( int nIdx = 0; nIdx < mpXlfd->NumEncodings(); nIdx++ )
- if ( mpXFontStruct[nIdx] != NULL )
- XFreeFont( mpDisplay, mpXFontStruct[nIdx] );
-
- free(mpXFontStruct);
-}
-
-rtl_TextEncoding
-ExtendedFontStruct::GetAsciiEncoding( int *pAsciiRange ) const
-{
- return mpXlfd->GetAsciiEncoding( pAsciiRange );
-}
-
-FontPitch
-ExtendedFontStruct::GetSpacing( rtl_TextEncoding nEncoding )
-{
- return mpXlfd->GetPitch( nEncoding );
-}
-
-static XFontStruct*
-LoadXFont (Display* pDisplay, const char* pFontName)
-{
- XFontStruct* pFont = XLoadQueryFont (pDisplay, pFontName);
- if ((pFont != NULL) && (pFont->fid == 0))
- pFont->fid = XLoadFont(pDisplay, pFontName);
-
-#ifdef HDU_DEBUG
- fprintf( stderr, "XLoadFont \"%s\" => %d\n", pFontName, (pFont!= NULL) );
-#endif
- return pFont;
-}
-
-int
-ExtendedFontStruct::LoadEncoding( rtl_TextEncoding nEncoding )
-{
- int nIdx = mpXlfd->GetEncodingIdx( nEncoding );
- if ( (nIdx < 0) || (mpXFontStruct[ nIdx ] != NULL) )
- return nIdx;
-
- // limit font height that gets requested from the XServer
- // see BugId #44528# FontWork (-> #45038#) and as well Bug #47127#
- int nReqPixelHeight = maPixelSize.Height();
- if( nReqPixelHeight > GetMaxFontHeight() )
- nReqPixelHeight = GetMaxFontHeight();
- else if( nReqPixelHeight < 2 )
- nReqPixelHeight = 2;
-
- // get the X11 font from a matching XLFD
- ByteString aFontName;
- mpXlfd->ToString( aFontName, nReqPixelHeight, nEncoding );
- mpXFontStruct[ nIdx ] = LoadXFont( mpDisplay, aFontName.GetBuffer() );
- if (mpXFontStruct[nIdx] == NULL)
- mpXFontStruct[nIdx] = LoadXFont( mpDisplay, "fixed" );
-
- // calculate correction factors to improve matching
- // the selected font size to the used bitmap font
- int nRealPixelSize = mpXlfd->GetPixelSize();
- if( !nRealPixelSize ) // check for scalable mpXlfd
- nRealPixelSize = nReqPixelHeight;
- if( nRealPixelSize && (nRealPixelSize != maPixelSize.Width()) )
- mfXScale = (float)maPixelSize.Width() / nRealPixelSize;
- if( nRealPixelSize && (nRealPixelSize != maPixelSize.Height()) )
- mfYScale = (float)maPixelSize.Height() / nRealPixelSize;
-
- return nIdx;
-}
-
-XFontStruct*
-ExtendedFontStruct::GetFontStruct( rtl_TextEncoding nEncoding )
-{
- int nIdx = LoadEncoding( nEncoding );
- return nIdx < 0 ? NULL : mpXFontStruct[nIdx] ;
-}
-
-bool
-ExtendedFontStruct::GetFontBoundingBox( XCharStruct *pCharStruct,
- int *pAscent, int *pDescent )
-{
- pCharStruct->lbearing = 0;
- pCharStruct->rbearing = 0;
- pCharStruct->width = 0;
- pCharStruct->ascent = 0;
- pCharStruct->descent = 0;
-
- *pAscent = 0;
- *pDescent = 0;
-
- int nIdx;
-
- // check if there is at least one encoding already loaded
- bool bEmpty = true;
- for ( nIdx = 0; nIdx < mpXlfd->NumEncodings(); nIdx++ )
- bEmpty &= (mpXFontStruct[nIdx] == NULL);
- if ( bEmpty )
- LoadEncoding( mpXlfd->GetAsciiEncoding() );
-
- // get the max bounding box from all font structs
- for ( nIdx = 0; nIdx < mpXlfd->NumEncodings(); nIdx++ )
- if ( mpXFontStruct[ nIdx ] != NULL )
- {
- *pAscent = std::max( mpXFontStruct[nIdx]->ascent, *pAscent );
- *pDescent = std::max( mpXFontStruct[nIdx]->descent, *pDescent );
-
- XCharStruct* pMaxBounds = &(mpXFontStruct[nIdx]->max_bounds);
-
- pCharStruct->lbearing = std::max( pMaxBounds->lbearing,
- pCharStruct->lbearing );
- pCharStruct->rbearing = std::max( pMaxBounds->rbearing,
- pCharStruct->rbearing );
- pCharStruct->width = std::max( pMaxBounds->width,
- pCharStruct->width );
- pCharStruct->ascent = std::max( pMaxBounds->ascent,
- pCharStruct->ascent );
- pCharStruct->descent = std::max( pMaxBounds->descent,
- pCharStruct->descent );
- }
-
- // apply correction factors to better match selected size to available size
- if( mfYScale != 1.0 )
- {
- *pAscent = int(*pAscent * mfYScale);
- *pDescent = int(*pDescent * mfYScale);
- pCharStruct->ascent = (short int)(pCharStruct->ascent * mfYScale);
- pCharStruct->descent = (short int)(pCharStruct->descent * mfYScale);
- }
- if( mfXScale != 1.0 )
- {
- pCharStruct->lbearing = (short int)(pCharStruct->lbearing * mfXScale);
- pCharStruct->rbearing = (short int)(pCharStruct->rbearing * mfXScale);
- pCharStruct->width = (short int)(pCharStruct->width * mfXScale);
- }
-
- return (pCharStruct->width > 0);
-}
-
-bool
-ExtendedFontStruct::ToImplFontMetricData(ImplFontMetricData *pFontMetric)
-{
- pFontMetric->mnOrientation = 0;
- pFontMetric->mnSlant = 0;
- pFontMetric->mbDevice = true;
- pFontMetric->mbScalableFont = mpXlfd->IsScalable();
- pFontMetric->mbKernableFont = false;
- pFontMetric->mbSymbolFlag= mpXlfd->IsSymbolFont();
- pFontMetric->meFamily = mpXlfd->GetFamilyType();
- pFontMetric->meWeight = mpXlfd->GetWeight();
- pFontMetric->mePitch = mpXlfd->GetPitch();
- pFontMetric->meItalic = mpXlfd->GetSlant();
-
- int nAscent, nDescent;
- XCharStruct aBoundingBox;
- if ( GetFontBoundingBox(&aBoundingBox, &nAscent, &nDescent) )
- {
- pFontMetric->mnWidth = aBoundingBox.width;
- pFontMetric->mnAscent = aBoundingBox.ascent;
- pFontMetric->mnDescent = aBoundingBox.descent;
- pFontMetric->mnIntLeading = std::max(0, aBoundingBox.ascent - nAscent
- + aBoundingBox.descent - nDescent );
- pFontMetric->mnExtLeading = 0; // TODO!!!
- return true;
- }
- else
- {
- return false;
- }
-}
-
-bool
-ExtendedFontStruct::Match( const ExtendedXlfd *pXlfd,
- const Size& rPixelSize, sal_Bool bVertical ) const
-{
- if( mpXlfd != pXlfd )
- return false;
-
- if( bVertical != mbVertical )
- return FALSE;
-
- if( rPixelSize.Height() != maPixelSize.Height() )
- return FALSE;
-
- long nReqWidth = rPixelSize.Width();
- if( !nReqWidth )
- nReqWidth = rPixelSize.Height();
- if( nReqWidth != maPixelSize.Width() )
- return FALSE;
-
- return true;
-}
-
-// Get an appropriate x-font that contains a glyph for the given unicode
-// code point.
-// This routine is designed to be called for each character in a text.
-// It first checks the given encoding to optimize for the fact that two
-// adjacent characters in a text most probably have the same encoding
-// In the first call initialize pEncodingInOut to dontknow, this causes
-// EncodingHasChar() to fail and thus bootstraps the encoding, otherwise
-// make sure that the initial value of pFontInOut matches the encoding and
-// that the encoding is valid for the font.
-XFontStruct*
-ExtendedFontStruct::GetFontStruct( sal_Unicode nChar, rtl_TextEncoding *pEncoding )
-{
- SalConverterCache *pCvt = SalConverterCache::GetInstance();
-
- if ( pCvt->EncodingHasChar(mnAsciiEncoding, nChar) )
- {
- *pEncoding = mnAsciiEncoding;
- return GetFontStruct (mnAsciiEncoding);
- }
- else
- if ( pCvt->EncodingHasChar(mnCachedEncoding, nChar) )
- {
- *pEncoding = mnCachedEncoding;
- return GetFontStruct (mnCachedEncoding);
- }
- else
- {
- for ( int nIdx = 0; nIdx < mpXlfd->NumEncodings(); nIdx++ )
- {
- rtl_TextEncoding nEnc = mpXlfd->GetEncoding(nIdx);
- if ( (nEnc != mnCachedEncoding) && (nEnc != mnAsciiEncoding)
- && pCvt->EncodingHasChar(nEnc, nChar))
- {
- mnCachedEncoding = nEnc;
- *pEncoding = mnCachedEncoding;
- return GetFontStruct (mnCachedEncoding);
- }
- }
- }
-
- *pEncoding = RTL_TEXTENCODING_DONTKNOW;
- return NULL;
-}
-
-// ---------------------------------------------------------------------------
-// utility functions to handle xfontstruct information, this is all to
-// calculate charwidth information
-// ---------------------------------------------------------------------------
-
-static bool
-CharExists( const XCharStruct* pChar )
-{
- if ( pChar == NULL )
- return false;
-
- return pChar->width
- || pChar->ascent || pChar->descent
- || pChar->lbearing || pChar->rbearing;
-}
-
-// this relies on non-null per_char information in the fontstruct
-static XCharStruct*
-GetCharinfo( const XFontStruct *pXFontStruct, sal_MultiByte nChar )
-{
- unsigned int nRow = nChar >> 8;
- unsigned int nCol = nChar & 0xFF;
-
- unsigned int nMinRow = pXFontStruct->min_byte1;
- unsigned int nMaxRow = pXFontStruct->max_byte1;
- unsigned int nMinCol = pXFontStruct->min_char_or_byte2;
- unsigned int nMaxCol = pXFontStruct->max_char_or_byte2;
-
- if ( nRow >= nMinRow && nRow <= nMaxRow
- && nCol >= nMinCol && nCol <= nMaxCol )
- {
- return &pXFontStruct->per_char[
- (nRow-nMinRow) * (nMaxCol-nMinCol+1) + (nCol-nMinCol) ];
- }
-
- return NULL;
-}
-
-static sal_Size
-QueryCharWidth16( Display* pDisplay, XLIB_Font nFontID, sal_MultiByte nChar,
- sal_Size nDefaultWidth )
-{
- int nDirection, nFontAscent, nFontDescent;
- XCharStruct aBoundingBox;
-
- XQueryTextExtents16( pDisplay, nFontID, (XChar2b*)&nChar, 1,
- &nDirection, &nFontAscent, &nFontDescent, &aBoundingBox );
-
- return CharExists( &aBoundingBox ) ? aBoundingBox.width : nDefaultWidth;
-}
-
-#if 0
-// currently not used
-static sal_Size
-QueryCharWidth8( XFontStruct* pXFontStruct, sal_Char nChar,
- sal_Size nDefaultWidth )
-{
- int nDirection, nFontAscent, nFontDescent;
- XCharStruct aBoundingBox;
-
- XTextExtents( pXFontStruct, &nChar, 1,
- &nDirection, &nFontAscent, &nFontDescent, &aBoundingBox );
-
- return CharExists( &aBoundingBox ) ? aBoundingBox.width : nDefaultWidth;
-}
-#endif
-
-sal_Size
-ExtendedFontStruct::GetDefaultWidth()
-{
- return (maPixelSize.Width() + 1) / 2;
-}
-
-// Handle single byte fonts which do not require conversion, this exploits
-// the fact that unicode equals latin1 or ansi1252 in the range [0..0xff] and
-// is compatible with iso8859-X at least in the range to 0x7f
-sal_Size
-ExtendedFontStruct::GetCharWidth8( sal_Unicode nFrom, sal_Unicode nTo,
- sal_Int32* pWidthArray, rtl_TextEncoding nEncoding )
-{
- if ( !(nFrom <= nTo) )
- return 0;
-
- XFontStruct* pXFontStruct = GetFontStruct( nEncoding );
- if ( pXFontStruct == NULL )
- return 0;
-
- // query the font metrics
- if ( (pXFontStruct->max_bounds.width == pXFontStruct->min_bounds.width)
- || (pXFontStruct->per_char == NULL) )
- {
- // fixed width font
- for ( int nIdx = nFrom; nIdx <= nTo; nIdx++, pWidthArray++ )
- *pWidthArray = pXFontStruct->max_bounds.width;
- }
- else
- {
- // variable width font
- int nMinChar = pXFontStruct->min_char_or_byte2;
- int nMaxChar = pXFontStruct->max_char_or_byte2;
-
- int nIdx = nFrom;
-
- for ( ; nIdx < std::min((int)nTo, nMinChar); nIdx++, pWidthArray++ )
- *pWidthArray = mnDefaultWidth;
- for ( ; nIdx <= std::min((int)nTo, nMaxChar); nIdx++, pWidthArray++ )
- {
- XCharStruct* pChar = &(pXFontStruct->per_char[nIdx - nMinChar]);
- *pWidthArray = CharExists(pChar) ? pChar->width : mnDefaultWidth;
- }
- for ( ; nIdx <= nTo; nIdx++, pWidthArray++ )
- *pWidthArray = mnDefaultWidth;
- }
-
- // return amount of handled chars
- return nTo - nFrom + 1;
-}
-
-// Handle utf16 encoded fonts, which do not require conversion
-sal_Size
-ExtendedFontStruct::GetCharWidthUTF16( sal_Unicode nFrom, sal_Unicode nTo,
- sal_Int32* pWidthArray )
-{
- if ( !(nFrom <= nTo) )
- return 0;
-
- XFontStruct* pXFontStruct = GetFontStruct( RTL_TEXTENCODING_UNICODE );
- FontPitch nSpacing = mpXlfd->GetPitch( RTL_TEXTENCODING_UNICODE );
-
- if ( pXFontStruct == NULL )
- return 0;
-
- // query the font metrics
- if ( nSpacing == PITCH_VARIABLE
- && pXFontStruct->per_char == NULL)
- {
- // get per_char information from the server
- for ( sal_Int32 nIdx = nFrom; nIdx <= nTo; nIdx++, pWidthArray++ )
- *pWidthArray = QueryCharWidth16( mpDisplay, pXFontStruct->fid,
- nIdx, mnDefaultWidth );
- }
- else
- if ( (pXFontStruct->max_bounds.width == pXFontStruct->min_bounds.width)
- || (pXFontStruct->per_char == NULL) )
- {
- // really a fixed width font
- for ( sal_Int32 nIdx = nFrom; nIdx <= nTo; nIdx++, pWidthArray++ )
- *pWidthArray = pXFontStruct->max_bounds.width;
- }
- else
- {
- // get per_char information from the xfontstruct
- for ( sal_Int32 nIdx = nFrom; nIdx <= nTo; nIdx++, pWidthArray++ )
- {
- XCharStruct* pChar = GetCharinfo( pXFontStruct, nIdx );
- *pWidthArray = CharExists(pChar) ? pChar->width : mnDefaultWidth;
- }
- }
-
- // return amount of handled chars
- return nTo - nFrom + 1;
-}
-
-// handle non unicode fonts that are converted into encoding matching the
-// font in fontstruct, 8 and 16 bit fonts are handled the same way
-sal_Size
-ExtendedFontStruct::GetCharWidth16( sal_Unicode nFrom, sal_Unicode nTo,
- sal_Int32* pWidthArray, ExtendedFontStruct *pFallback )
-{
- if ( nFrom > nTo )
- return 0;
-
- sal_Char pBuffer[64];
-
- SalConverterCache *pCvt = SalConverterCache::GetInstance();
- for ( sal_Int32 nIdx = nFrom ; nIdx <= nTo ; nIdx++, pWidthArray++ )
- {
- FontPitch nSpacing;
- sal_Size nSize;
- sal_Unicode nUniIdx = (sal_Unicode)nIdx;
-
- // get a matching fontstruct
- rtl_TextEncoding nEnc;
- XFontStruct *pFont;
-
- if ( (pFont = GetFontStruct(nUniIdx, &nEnc)) != NULL )
- {
- nSpacing = GetSpacing( nEnc );
- }
- else
- if ( (pFallback != NULL)
- && ((pFont = pFallback->GetFontStruct(nUniIdx, &nEnc)) != NULL) )
- {
- nSpacing = pFallback->GetSpacing( nEnc );
- }
- else
- if ( (pFallback != NULL)
- && ((pFont = pFallback->GetFontStruct(nUniIdx = '?', &nEnc)) != NULL) )
- {
- nSpacing = pFallback->GetSpacing( nEnc );
- }
- else
- {
- // TODO What should the default value be?
- nSpacing = PITCH_FIXED;
- }
-
- if ( pFont )
- {
- nSize = pCvt->ConvertStringUTF16(&nUniIdx, 1, pBuffer, sizeof(pBuffer), nEnc);
- // XXX FIXME
- if ((nEnc == RTL_TEXTENCODING_GB_2312) || (nEnc == RTL_TEXTENCODING_EUC_KR))
- {
- for (unsigned int n_char = 0; n_char < nSize; n_char++ )
- pBuffer[ n_char ] &= 0x7F;
- }
- }
-
- // query font metrics
- if ( pFont && (nSize == 1 || nSize == 2) )
- {
- sal_MultiByte nChar = (nSize == 1) ? (unsigned char)pBuffer[0] :
- ((sal_MultiByte)pBuffer[0] << 8) + (sal_MultiByte)pBuffer[1];
-
- if ( nSpacing == PITCH_VARIABLE
- && pFont->per_char == NULL)
- {
- // get per_char information from the x-server
- *pWidthArray = QueryCharWidth16( mpDisplay, pFont->fid,
- nChar, mnDefaultWidth );
- }
- else
- if ( (pFont->max_bounds.width == pFont->min_bounds.width)
- || (pFont->per_char == NULL) )
- {
- // fixed width font
- *pWidthArray = pFont->max_bounds.width;
- }
- else
- {
- // get per_char information from the xfontstruct
- XCharStruct* pChar = GetCharinfo( pFont, nChar );
- *pWidthArray = CharExists(pChar) ? pChar->width : mnDefaultWidth;
- }
- }
- else
- {
- // conversion error
- *pWidthArray = mnDefaultWidth;
- }
- }
-
- // return amount of handled chars
- return nTo - nFrom + 1;
-}
-
-sal_Size
-ExtendedFontStruct::GetCharWidth( sal_Unicode cChar, sal_Int32 *pPhysicalWidth,
- sal_Int32 *pLogicalWidth )
-{
- sal_Size nConverted = 0;
-
- // dispatch querying of metrics to most promising encoding candidate
- int nAsciiRange;
- rtl_TextEncoding nEncoding = mpXlfd->GetAsciiEncoding(&nAsciiRange);
- if ( nEncoding == RTL_TEXTENCODING_UNICODE )
- {
- // if we have a unicode encoded system font than we get the charwidth
- // straight forward
- nConverted = GetCharWidthUTF16( cChar, cChar, pPhysicalWidth );
- }
- else
- {
- if ( cChar < nAsciiRange )
- {
- // optimize the most frequent case, requesting only the latin1
- // chars which are mappable to a single encoding
- nConverted = GetCharWidth8( cChar, cChar, pPhysicalWidth, nEncoding );
- }
-
- // if further requests are pending, then the according unicode
- // codepoint has to be dispatched to one of the system fonts and
- // converted to this fonts encoding
- nConverted += GetCharWidth16( cChar + nConverted, cChar,
- pPhysicalWidth + nConverted, NULL );
- }
-
- // convert physical width to logical width, apply correction factor if needed
- *pLogicalWidth = *pPhysicalWidth;
- if( mfXScale != 1.0 )
- *pLogicalWidth = sal_Int32(*pLogicalWidth * mfXScale);
-
- return nConverted;
-}
-
-bool ExtendedFontStruct::HasUnicodeChar( sal_Unicode cChar ) const
-{
- // #i18818# return false if there are no known encodings
- if( !mnRangeCount )
- return false;
-
- // init unicode range cache if needed
- if( mnRangeCount < 0 )
- {
- mnRangeCount = mpXlfd->GetFontCodeRanges( NULL );
- if( !mnRangeCount )
- return false;
- mpRangeCodes = new sal_uInt32[ 2*mnRangeCount ];
- mpXlfd->GetFontCodeRanges( mpRangeCodes );
- // TODO: make sure everything is sorted
- }
-
- // binary search in unicode ranges
- int nLower = 0;
- int nMid = mnRangeCount;
- int nUpper = 2 * mnRangeCount - 1;
- while( nLower < nUpper )
- {
- if( cChar >= mpRangeCodes[ nMid ] )
- nLower = nMid;
- else
- nUpper = nMid - 1;
- nMid = (nLower + nUpper + 1) / 2;
- }
- if( (nMid == 0) && (cChar < mpRangeCodes[0]) )
- return false;
- return (nMid & 1) ? false: true;
-}
-
-int ExtendedFontStruct::GetFontCodeRanges( sal_uInt32* pCodePairs ) const
-{
- // make sure unicode range cache is initialized
- HasUnicodeChar(0);
-
- // transfer range pairs if requested
- if( pCodePairs )
- {
- for( int i = 0; i < 2*mnRangeCount; ++i )
- pCodePairs[i] = mpRangeCodes[i];
- }
-
- return mnRangeCount;
-}
-
-// =======================================================================
-
-X11FontLayout::X11FontLayout( ExtendedFontStruct& rFont )
-: mrFont( rFont )
-{}
-
-// -----------------------------------------------------------------------
-
-bool X11FontLayout::LayoutText( ImplLayoutArgs& rArgs )
-{
- Point aNewPos( 0, 0 );
- bool bRightToLeft;
- int nCharPos;
-
- for( nCharPos = -1; rArgs.GetNextPos( &nCharPos, &bRightToLeft ); )
- {
- sal_UCS4 cChar = rArgs.mpStr[ nCharPos ];
- if( bRightToLeft )
- cChar = GetMirroredChar( cChar );
- int nGlyphIndex = cChar | GF_ISCHAR;
-
- // check if the font supports the char
- if( !mrFont.HasUnicodeChar( cChar ) )
- {
- // try to replace the failing char using the same font
- const char* pApproxUTF8 = GetAutofallback( cChar );
- cChar = 0;
- if( pApproxUTF8 )
- {
- String aApproxStr( pApproxUTF8, RTL_TEXTENCODING_UTF8 );
- if( aApproxStr.Len() == 1 )
- {
- // TODO: support Autofallback for len>1
- sal_Unicode cApprox = aApproxStr.GetChar( 0 );
- if( mrFont.HasUnicodeChar( cApprox ) )
- nGlyphIndex = (cChar = cApprox) | GF_ISCHAR;
- }
- }
- // request fallback glyph if necessary
- if( !cChar )
- {
- rArgs.NeedFallback( nCharPos, bRightToLeft );
- if( rArgs.mnFlags & SAL_LAYOUT_FOR_FALLBACK )
- nGlyphIndex = 0; // drop NotDef fallback glyphs
- }
- }
-
- sal_Int32 nPhysGlyphWidth, nLogGlyphWidth;
- mrFont.GetCharWidth( cChar, &nPhysGlyphWidth, &nLogGlyphWidth );
- int nGlyphFlags = (nPhysGlyphWidth > 0) ? 0 : GlyphItem::IS_IN_CLUSTER;
- if( bRightToLeft )
- nGlyphFlags |= GlyphItem::IS_RTL_GLYPH;
- GlyphItem aGI( nCharPos, nGlyphIndex, aNewPos, nGlyphFlags, nPhysGlyphWidth );
- aGI.mnNewWidth = nLogGlyphWidth;
- AppendGlyph( aGI );
-
- aNewPos.X() += nLogGlyphWidth;
- }
-
- return (nCharPos >= 0);
-}
-
-// -----------------------------------------------------------------------
-
-void X11FontLayout::AdjustLayout( ImplLayoutArgs& rArgs )
-{
- GenericSalLayout::AdjustLayout( rArgs );
- SetOrientation( 0 ); // X11 fonts are to be rotated in upper layers
-}
-
-// -----------------------------------------------------------------------
-
-void X11FontLayout::DrawText( SalGraphics& rSalGraphics ) const
-{
- static const int MAXGLYPHS = 160;
- int nMaxGlyphs = GetOrientation() ? 1 : MAXGLYPHS;
-
- // workaround for #i49902# similar to #b6228733 with XDrawText items
- // => output each item separately for non-unicode font encodings!
- // this is done here instead of in DrawStringUCS2MB() because
- // it needs the item positions and they are easily available here
- if( mrFont.GetAsciiEncoding() != RTL_TEXTENCODING_UNICODE )
- nMaxGlyphs = 1;
-
- Point aPos;
- sal_GlyphId aGlyphAry[ MAXGLYPHS ];
- sal_Unicode pStr[ MAXGLYPHS ];
- for( int nStart=0;;)
- {
- int nGlyphCount = GetNextGlyphs( nMaxGlyphs, aGlyphAry, aPos, nStart );
- if( !nGlyphCount )
- break;
-
- for( int i = 0; i < nGlyphCount; ++i )
- pStr[ i ] = aGlyphAry[ i ] & GF_IDXMASK;
-
- static_cast<X11SalGraphics&>(rSalGraphics).DrawStringUCS2MB( mrFont, aPos, pStr, nGlyphCount );
- }
-}
-
-// =======================================================================
diff --git a/vcl/unx/source/gdi/xlfd_attr.cxx b/vcl/unx/source/gdi/xlfd_attr.cxx
deleted file mode 100644
index ca49a8548afb..000000000000
--- a/vcl/unx/source/gdi/xlfd_attr.cxx
+++ /dev/null
@@ -1,686 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_vcl.hxx"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sal/alloca.h>
-#include "xlfd_attr.hxx"
-#include <rtl/tencinfo.h>
-#include <vcl/vclenum.hxx>
-
-// ---------------------------------------------------------------------------
-//
-//
-// Attribute is a container for simple name value pairs
-// eg. ( "times", FAMILY_ROMAN ) or ( "demi bold", WEIGHT_SEMIBOLD )
-// enriched with an annotation which is a pretty-printed version of the
-// string, i.e. "itc avant garde" would get an annotation of "Itc Avant Garde"
-//
-//
-// ---------------------------------------------------------------------------
-
-// release the stored string
-void
-Attribute::Release()
-{
- if ( mpAnnotation != NULL )
- delete mpAnnotation;
- if ( mpKeyName != NULL )
- delete mpKeyName;
- if ( mpName != NULL )
- free( (void*)mpName );
-}
-
-// get a private copy of the given argument
-void
-Attribute::SetName( const char *p, int nLen )
-{
- mpName = (char*)malloc( nLen + 1 );
- mnLength = nLen;
- memcpy( (void*)mpName, p, mnLength );
- ((char*)mpName)[ mnLength ] = '\0';
-}
-
-// Compare whether two strings a equal for the first nLen bytes
-// i.e. arial == arialnarrow
-int
-Attribute::Compare( const char *p, int nLen )
-{
- return strncmp( mpName, p, nLen );
-}
-
-// Get a all lowercase name with all blanks removed
-const rtl::OString&
-Attribute::GetKey ()
-{
- static rtl::OString aEmptyStr;
-
- if (mpKeyName != NULL)
- return *mpKeyName;
- if (mnLength == 0)
- return aEmptyStr;
-
- sal_Char* pBuffer = (sal_Char*)alloca (mnLength);
-
- sal_Int32 i, j;
- for (i = 0, j = 0; i < mnLength; i++)
- {
- if ( mpName[i] != ' ' )
- pBuffer[j++] = mpName[i];
- }
- mpKeyName = new rtl::OString(pBuffer, j);
-
- return *mpKeyName;
-}
-
-void
-Attribute::InitKey ()
-{
- mpKeyName = NULL;
-}
-
-// Compare two strings, they have to be equal for nLen bytes, after nLen
-// bytes both strings have to be terminated either by '\0' or by '-'
-// this is for comparing a string being a substring in a Xlfd with a
-// zeroterminated string
-Bool
-Attribute::ExactMatch( const char *p, int nLen )
-{
- Bool bMatch;
- if ( nLen > 0 )
- bMatch = Compare( p, nLen ) == 0;
- else
- bMatch = True;
- if ( bMatch )
- {
- char c1 = p[ nLen ];
- char c2 = mpName[ nLen ];
- bMatch = (c1 == '-' || c1 == '\0') && (c2 == '-' || c2 == '\0');
- }
-
- return bMatch;
-}
-
-void
-Attribute::TagFeature( unsigned short nFeature )
-{
- if ( (nFeature & XLFD_FEATURE_NARROW)
- && (strstr(mpName, "narrow") != NULL) )
- {
- mnFeature |= XLFD_FEATURE_NARROW;
- }
-
- if ( (nFeature & XLFD_FEATURE_OL_CURSOR)
- && (strcmp(mpName, "open look cursor") == 0) )
- {
- mnFeature |= XLFD_FEATURE_OL_CURSOR;
- }
-
- if ( (nFeature & XLFD_FEATURE_OL_GLYPH)
- && (strcmp(mpName, "open look glyph") == 0) )
- {
- mnFeature |= XLFD_FEATURE_OL_GLYPH;
- }
-
- if ( (nFeature & XLFD_FEATURE_APPLICATION_FONT)
- && ( (strcmp(mpName, "interface user") == 0)
- || (strcmp(mpName, "interface system") == 0)))
- {
- mnFeature |= XLFD_FEATURE_APPLICATION_FONT;
- }
-
- if (nFeature & XLFD_FEATURE_INTERFACE_FONT)
- {
- // european
- if (strcmp(mpName, "arial") == 0)
- mnFeature |= (XLFD_FEATURE_INTERFACE_FONT | XLFD_FEATURE_HQ | XLFD_FEATURE_MQ);
- else
- if (strcmp(mpName, "helvetica") == 0)
- mnFeature |= (XLFD_FEATURE_INTERFACE_FONT | XLFD_FEATURE_HQ);
- else
- if ( (strcmp(mpName, "lucidux sans") == 0)
- || (strcmp(mpName, "luxi sans") == 0))
- mnFeature |= (XLFD_FEATURE_INTERFACE_FONT | XLFD_FEATURE_MQ | XLFD_FEATURE_LQ);
- else
- if (strcmp(mpName, "charter") == 0)
- mnFeature |= (XLFD_FEATURE_INTERFACE_FONT | XLFD_FEATURE_MQ);
- else
- // japanese
- if ( (strcmp(mpName, "hg mincho l") == 0) /* Solaris: jisx0208 jisx0201 */
- || (strcmp(mpName, "heiseimin") == 0) /* Solaris: jisx0212 */
- || (strcmp(mpName, "minchol") == 0) /* TurboLinux */
- || (strcmp(mpName, "mincho") == 0)) /* Redhat 6.2 JP */
- {
- mnFeature |= XLFD_FEATURE_INTERFACE_FONT;
- }
- else
- // chinese
- if ( (strcmp(mpName, "kai") == 0) /* Solaris */
- || (strcmp(mpName, "ar pl mingti2l big5") == 0)) /* TurboLinux */
- {
- mnFeature |= XLFD_FEATURE_INTERFACE_FONT;
- }
- else
- // korean
- if ( (strcmp(mpName, "myeongjo") == 0)) /* Solaris */
- {
- mnFeature |= XLFD_FEATURE_INTERFACE_FONT;
- }
- }
-
- if ( nFeature & XLFD_FEATURE_REDUNDANTSTYLE )
- {
- switch ( mpName[0] )
- {
- case '\0':
- mnFeature |= XLFD_FEATURE_REDUNDANTSTYLE;
- break;
-
- case 'b':
- if ( (strcmp(mpName, "bold") == 0)
- || (strcmp(mpName, "bold italic") == 0)
- || (strcmp(mpName, "bold sans") == 0) )
- mnFeature |= XLFD_FEATURE_REDUNDANTSTYLE;
- break;
-
- case 'd':
- if ( (strcmp(mpName, "demi") == 0)
- || (strcmp(mpName, "demi italic") == 0) )
- mnFeature |= XLFD_FEATURE_REDUNDANTSTYLE;
- break;
-
- case 'i':
- if ( strcmp(mpName, "italic") == 0 )
- mnFeature |= XLFD_FEATURE_REDUNDANTSTYLE;
- break;
-
- case 's':
- if ( (strcmp(mpName, "sans") == 0)
- || (strcmp(mpName, "serif") == 0) )
- mnFeature |= XLFD_FEATURE_REDUNDANTSTYLE;
- break;
- }
- }
-}
-
-// given Attribute classifications, strings have to be in alphabetical
-// order, since they are treated by binary search algorithm
-
-#define InitializeAttributeWith( p, a ) p, sizeof(p) - 1, a, 0, NULL, NULL
-#define MembersOf( p ) (sizeof(p) / sizeof(p[0]) )
-
-const Attribute pFamilyAttribute[] = {
- { InitializeAttributeWith( "arial", FAMILY_SWISS ) },
- { InitializeAttributeWith( "arioso", FAMILY_SCRIPT ) },
- { InitializeAttributeWith( "avant garde", FAMILY_SWISS ) },
- { InitializeAttributeWith( "avantgarde", FAMILY_SWISS ) },
- { InitializeAttributeWith( "bembo", FAMILY_ROMAN ) },
- { InitializeAttributeWith( "bookman", FAMILY_ROMAN ) },
- { InitializeAttributeWith( "conga", FAMILY_ROMAN ) },
- { InitializeAttributeWith( "courier", FAMILY_MODERN ) },
- { InitializeAttributeWith( "curl", FAMILY_SCRIPT ) },
- { InitializeAttributeWith( "fixed", FAMILY_MODERN ) },
- { InitializeAttributeWith( "gill", FAMILY_SWISS ) },
- { InitializeAttributeWith( "helmet", FAMILY_MODERN ) },
- { InitializeAttributeWith( "helvetica", FAMILY_SWISS ) },
- { InitializeAttributeWith( "international", FAMILY_MODERN ) },
- { InitializeAttributeWith( "lucida", FAMILY_SWISS ) },
- { InitializeAttributeWith( "new century schoolbook", FAMILY_ROMAN ) },
- { InitializeAttributeWith( "palatino", FAMILY_ROMAN ) },
- { InitializeAttributeWith( "roman", FAMILY_ROMAN ) },
- { InitializeAttributeWith( "sans serif", FAMILY_SWISS ) },
- { InitializeAttributeWith( "sansserif", FAMILY_SWISS ) },
- { InitializeAttributeWith( "serf", FAMILY_ROMAN ) },
- { InitializeAttributeWith( "serif", FAMILY_ROMAN ) },
- { InitializeAttributeWith( "times", FAMILY_ROMAN ) },
- { InitializeAttributeWith( "utopia", FAMILY_ROMAN ) },
- { InitializeAttributeWith( "zapf chancery", FAMILY_SCRIPT ) },
- { InitializeAttributeWith( "zapfchancery", FAMILY_SCRIPT ) }
-};
-
-const Attribute pWeightAttribute[] = {
- { InitializeAttributeWith( "black", WEIGHT_BLACK ) },
- { InitializeAttributeWith( "bold", WEIGHT_BOLD ) },
- { InitializeAttributeWith( "book", WEIGHT_LIGHT ) },
- { InitializeAttributeWith( "demi", WEIGHT_SEMIBOLD ) },
- { InitializeAttributeWith( "demi bold", WEIGHT_SEMIBOLD ) },
- { InitializeAttributeWith( "demibold", WEIGHT_SEMIBOLD ) },
- { InitializeAttributeWith( "light", WEIGHT_LIGHT ) },
- { InitializeAttributeWith( "medium", WEIGHT_MEDIUM ) },
- { InitializeAttributeWith( "normal", WEIGHT_NORMAL ) },
- { InitializeAttributeWith( "regular", WEIGHT_NORMAL ) },
- { InitializeAttributeWith( "roman", WEIGHT_NORMAL ) },
- { InitializeAttributeWith( "semicondensed", WEIGHT_LIGHT ) },
- { InitializeAttributeWith( "ultrabold", WEIGHT_ULTRABOLD ) }
-};
-
-const Attribute pSlantAttribute[] = {
- { InitializeAttributeWith( "i", ITALIC_NORMAL ) },
- { InitializeAttributeWith( "o", ITALIC_OBLIQUE ) },
- { InitializeAttributeWith( "r", ITALIC_NONE ) }
-};
-
-const Attribute pSetwidthAttribute[] = {
- { InitializeAttributeWith( "bold", WIDTH_SEMI_EXPANDED ) },
- { InitializeAttributeWith( "condensed", WIDTH_CONDENSED ) },
- { InitializeAttributeWith( "double wide", WIDTH_ULTRA_EXPANDED ) },
- { InitializeAttributeWith( "expanded", WIDTH_EXPANDED ) },
- { InitializeAttributeWith( "extracondensed", WIDTH_EXTRA_CONDENSED ) },
- { InitializeAttributeWith( "extraexpanded", WIDTH_EXTRA_EXPANDED ) },
- { InitializeAttributeWith( "medium", WIDTH_NORMAL ) },
- { InitializeAttributeWith( "narrow", WIDTH_CONDENSED ) },
- { InitializeAttributeWith( "normal", WIDTH_NORMAL ) },
- { InitializeAttributeWith( "semicondensed", WIDTH_SEMI_CONDENSED ) },
- { InitializeAttributeWith( "semiexpanded", WIDTH_SEMI_EXPANDED ) },
- { InitializeAttributeWith( "ultracondensed", WIDTH_ULTRA_CONDENSED ) },
- { InitializeAttributeWith( "ultraexpanded", WIDTH_ULTRA_EXPANDED ) },
- { InitializeAttributeWith( "wide", WIDTH_EXPANDED ) }
-};
-
-const Attribute pEnhancedCharsetAttribute[] = {
- { InitializeAttributeWith( "iso8859-1", RTL_TEXTENCODING_MS_1252 ) },
- { InitializeAttributeWith( "iso8859_1", RTL_TEXTENCODING_MS_1252 ) }
-};
-
-// -------------------------------------------------------------------------
-//
-// String handling utility functions
-//
-// -------------------------------------------------------------------------
-
-
-void
-AppendAttribute( Attribute *pAttribute, ByteString &rString )
-{
- if ( pAttribute == NULL )
- return ;
-
- int nLength = pAttribute->GetLength();
- char *pBuffer = (char*)alloca( nLength + 1);
-
- pBuffer[ 0 ] = '-';
- memcpy( pBuffer + 1, pAttribute->GetName(), nLength );
- rString.Append( pBuffer, nLength + 1);
-}
-
-//
-// Prettify the font name: make each leading character of a fontname
-// uppercase. For example
-// times new roman -> Times New Roman
-//
-
-static void
-ToUpper( char *pCharacter )
-{
- // replace [a,z] with [A,Z]
- if ( (*pCharacter >= 97) && (*pCharacter <= 122) )
- *pCharacter -= 32;
-}
-
-static String*
-Capitalize( const char *pStr, int nLength )
-{
- char *pCopy = (char*)alloca( nLength + 1 );
- char *pPtr = pCopy;
- memcpy( pPtr, pStr, nLength + 1 );
-
- // loop over string data and uppercase first char and all chars
- // following a space (other white space would be unexpected here)
- char nPreviousChar = ' ';
- while ( *pPtr )
- {
- if ( nPreviousChar == ' ' )
- ToUpper( pPtr );
- nPreviousChar = *pPtr++;
- }
-
- return new String( pCopy, RTL_TEXTENCODING_ISO_8859_1 );
-}
-
-String*
-AnnotateString( const Attribute& rAttribute )
-{
- return Capitalize(rAttribute.GetName(), rAttribute.GetLength());
-}
-
-String*
-AnnotateSlant( const Attribute& rAttribute )
-{
- const char* pStr = rAttribute.GetName();
- int nLen = rAttribute.GetLength();
-
- static const struct {
- const char *pFrom; const char *pTo;
- } pTranslation[] = {
- { "r", "Roman" },
- { "o", "Oblique" },
- { "i", "Italic" },
- { "ri", "Reverse Italic" },
- { "ro", "Reverse Oblique" },
- { "ot", "Other" }
- };
-
- for ( unsigned int i = 0; i < MembersOf(pTranslation); i++ )
- if ( strcmp(pStr, pTranslation[i].pFrom) == 0 )
- {
- return new String( pTranslation[i].pTo,
- RTL_TEXTENCODING_ISO_8859_1 );
- }
-
- return Capitalize(pStr, nLen);
-}
-
-String*
-AnnotateNone( const Attribute& )
-{
- return new String();
-}
-
-// ---------------------------------------------------------------------------
-//
-//
-// manage global lists of Attributes
-// since XListFonts does never list more than 64K fonts this storage does
-// handle array size and indices with unsigned short values for low
-// memory consumption
-//
-//
-// ---------------------------------------------------------------------------
-
-AttributeStorage::AttributeStorage( unsigned short nDefaultValue ) :
- mpList( NULL ),
- mnSize( 0 ),
- mnCount( 0 ),
- mnLastmatch( 0 ),
- mnDefaultValue( nDefaultValue )
-{
-}
-
-AttributeStorage::~AttributeStorage()
-{
- if ( mpList != NULL )
- {
- for ( int i = 0; i < mnCount; i++ )
- mpList[i].Release();
- free( mpList );
- }
-}
-
-#if OSL_DEBUG_LEVEL > 1
-void
-AttributeStorage::Dump()
-{
- fprintf(stderr, "AttributeStorage: size=%i, used=%i\n", mnSize, mnCount);
- for ( int i = 0; i < mnCount; i++ )
- {
- ByteString aAnnotation = ByteString(
- mpList[i].GetAnnotation(),
- RTL_TEXTENCODING_ISO_8859_1 );
- fprintf(stderr, "\t%4i: <%s><len=%i><val=%i><%s>\n", i, mpList[i].GetName(),
- mpList[i].GetLength(), mpList[i].GetValue(),
- aAnnotation.GetBuffer() );
- }
- fprintf(stderr, "\n");
-}
-#endif
-
-Attribute*
-AttributeStorage::Retrieve( unsigned short nIndex ) const
-{
- return nIndex < mnCount ? &mpList[ nIndex ] : (Attribute*)NULL ;
-}
-
-// pClassification contains a list of name-value pairs. If names in
-// the AttributeStorage match those in the pClassification then
-// the according value is copied. Matching means match for the length
-// of the string in pClassification (i.e. arial matches arialnarrow)
-// the strings in pClassification must be in alphabetical order, all
-// strings Lowercase
-void
-AttributeStorage::AddClassification( Attribute *pClassification,
- unsigned short nNum )
-{
- for ( int i = 0; i < mnCount; i++ )
- {
- unsigned int nLower = 0;
- unsigned int nUpper = nNum;
- unsigned int nCurrent;
- int nComparison = 1;
- Attribute *pHaystack = 0, *pNeedle;
-
- pNeedle = &mpList[ i ];
-
- // binary search
- while ( nLower < nUpper )
- {
- nCurrent = (nLower + nUpper) / 2;
- pHaystack = &pClassification[ nCurrent ];
- nComparison = pNeedle->Compare( pHaystack->GetName(),
- pHaystack->GetLength() );
- if (nComparison < 0)
- nUpper = nCurrent;
- else
- if (nComparison > 0)
- nLower = nCurrent + 1;
- else
- break;
- }
-
- // if there's a match store the according classification in the
- // Attribute storage, otherwise do nothing since defaults are
- // already provided in AttributeStorage::Insert()
- if ( nComparison == 0 )
- pNeedle->SetValue( pHaystack->GetValue() );
- }
-}
-
-void
-AttributeStorage::AddClassification( AttributeClassifierT Classify )
-{
- for ( int i = 0; i < mnCount; i++ )
- {
- Attribute& rCurrent = mpList[i] ;
- int nValue = Classify( rCurrent.GetName() );
- rCurrent.SetValue( nValue );
- }
-}
-
-void
-AttributeStorage::AddAnnotation( AttributeAnnotatorT Annotate )
-{
- for ( int i = 0; i < mnCount; i++ )
- {
- String* pAnnotation = Annotate( mpList[i] );
- mpList[i].SetAnnotation( pAnnotation );
- }
-}
-
-void
-AttributeStorage::TagFeature( unsigned short nFeature )
-{
- for ( int i = 0; i < mnCount; i++ )
- mpList[i].TagFeature( nFeature );
-}
-
-// Enlarge the list of Attributes
-void
-AttributeStorage::Enlarge()
-{
- if ( mnSize == 0 )
- {
- mnSize = 8;
- mpList = (Attribute*) malloc( mnSize * sizeof(Attribute) );
- }
- else
- {
- mnSize = mnSize < 32768 ? (mnSize * 2) : 65535;
- mpList = (Attribute*) realloc( mpList, mnSize * sizeof(Attribute) );
- }
-}
-
-// nLength is the length as it would be reported by strlen(3)
-// for an null-terminated string. if a string is part of a Xlfd
-// the field separator '-' is taken as '\0'
-// the AttributeStorage itself is NOT sorted to make sure that the
-// leased keys are still valid
-unsigned short
-AttributeStorage::Insert( const char *pString, int nLength )
-{
- // check whether the last match is still equal to the current
- // string since XListFonts lists fonts in sets of similar fontnames
- if ( mnLastmatch < mnCount )
- {
- if ( mpList[mnLastmatch].ExactMatch(pString, nLength) )
- return mnLastmatch;
- }
-
- // otherwise search in list
- for ( int i = 0; i < mnCount; i++ )
- {
- if ( mpList[i].ExactMatch(pString, nLength) )
- return mnLastmatch = i;
- }
-
- // if still not found we have to Insert the new string
- if ( mnSize == mnCount )
- Enlarge();
- mpList[mnCount].SetName( pString, nLength );
- mpList[mnCount].SetValue( mnDefaultValue );
- mpList[mnCount].SetAnnotation( NULL );
- mpList[mnCount].SetFeature( XLFD_FEATURE_NONE );
- mpList[mnCount].InitKey( );
- mnLastmatch = mnCount;
- mnCount = mnCount < 65535 ? mnCount + 1 : mnCount;
-
- return mnLastmatch;
-}
-
-
-// ---------------------------------------------------------------------------
-//
-//
-// Attribute provider is a frame for a set of AttributeStorages.
-//
-//
-// ---------------------------------------------------------------------------
-
-AttributeProvider::AttributeProvider ()
-{
- mpField[eXLFDFoundry ] = new AttributeStorage(0);
- mpField[eXLFDFamilyName ] = new AttributeStorage(FAMILY_DONTKNOW);
- mpField[eXLFDWeightName ] = new AttributeStorage(WEIGHT_NORMAL);
- mpField[eXLFDSlant ] = new AttributeStorage(ITALIC_NONE);
- mpField[eXLFDSetwidthName] = new AttributeStorage(WIDTH_NORMAL);
- mpField[eXLFDAddstyleName] = new AttributeStorage(RTL_TEXTENCODING_DONTKNOW);
- mpField[eXLFDCharset ] = new AttributeStorage(RTL_TEXTENCODING_DONTKNOW);
-}
-
-AttributeProvider::~AttributeProvider()
-{
- for ( int i = 0; i < eXLFDMaxEntry; i++ )
- delete mpField[ i ];
-}
-
-#if OSL_DEBUG_LEVEL > 1
-void
-AttributeProvider::Dump()
-{
- for ( int i = 0; i < eXLFDMaxEntry; i++ )
- mpField[ i ]->Dump();
-}
-#endif
-
-extern "C" rtl_TextEncoding
-GetTextEncodingFromAddStylename( const sal_Char *pAddStylename )
-{
- int nBufferLength = strlen( pAddStylename ) + 1;
- sal_Char *pBuffer = (sal_Char*)alloca( nBufferLength );
- for ( int i = 0; i < nBufferLength; i++ )
- pBuffer[i] = pAddStylename[i] == '_' ? '-' : pAddStylename[i] ;
-
- return rtl_getTextEncodingFromUnixCharset( pBuffer );
-}
-
-
-// classification information is needed before sorting because of course the
-// classification is the sort criteria
-void
-AttributeProvider::AddClassification()
-{
- /* mpField[ eXLFDFoundry ] doesn't need classification */
- mpField[ eXLFDFamilyName ]->AddClassification(
- (Attribute*)pFamilyAttribute,
- MembersOf(pFamilyAttribute) );
- mpField[ eXLFDWeightName ]->AddClassification(
- (Attribute*)pWeightAttribute,
- MembersOf(pWeightAttribute) );
- mpField[ eXLFDSlant ]->AddClassification(
- (Attribute*)pSlantAttribute,
- MembersOf(pSlantAttribute) );
- mpField[ eXLFDSetwidthName ]->AddClassification(
- (Attribute*)pSetwidthAttribute,
- MembersOf(pSetwidthAttribute) );
- mpField[ eXLFDAddstyleName ]->AddClassification(
- GetTextEncodingFromAddStylename );
- mpField[ eXLFDCharset ]->AddClassification(
- rtl_getTextEncodingFromUnixCharset );
-}
-
-// add some pretty print description
-void
-AttributeProvider::AddAnnotation()
-{
- mpField[ eXLFDFoundry ]->AddAnnotation( AnnotateNone );
- mpField[ eXLFDFamilyName ]->AddAnnotation( AnnotateString );
- mpField[ eXLFDWeightName ]->AddAnnotation( AnnotateString );
- mpField[ eXLFDSlant ]->AddAnnotation( AnnotateSlant );
- mpField[ eXLFDSetwidthName ]->AddAnnotation( AnnotateString );
- mpField[ eXLFDAddstyleName ]->AddAnnotation( AnnotateNone );
- mpField[ eXLFDCharset ]->AddAnnotation( AnnotateNone );
-}
-
-// this is the misc or any section: dirty hacks for dirty xlfd usage
-void
-AttributeProvider::TagFeature()
-{
- mpField[ eXLFDFamilyName ]->TagFeature(
- XLFD_FEATURE_OL_GLYPH
- | XLFD_FEATURE_OL_CURSOR
- | XLFD_FEATURE_NARROW
- | XLFD_FEATURE_INTERFACE_FONT
- | XLFD_FEATURE_APPLICATION_FONT);
-
- mpField[ eXLFDSetwidthName ]->TagFeature(
- XLFD_FEATURE_NARROW );
-
- mpField[ eXLFDAddstyleName ]->TagFeature(
- XLFD_FEATURE_REDUNDANTSTYLE );
-}
-
diff --git a/vcl/unx/source/gdi/xlfd_attr.hxx b/vcl/unx/source/gdi/xlfd_attr.hxx
deleted file mode 100644
index b721310da506..000000000000
--- a/vcl/unx/source/gdi/xlfd_attr.hxx
+++ /dev/null
@@ -1,228 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-#ifndef XLFD_ATTRIBUTE_HXX
-#define XLFD_ATTRIBUTE_HXX
-
-#include <salunx.h>
-#include <tools/string.hxx>
-
-
-struct Attribute {
-
- const char* mpName;
- unsigned short mnLength;
- unsigned short mnValue;
- unsigned short mnFeature;
- String* mpAnnotation;
- rtl::OString* mpKeyName;
-
- const char* GetName() const
- { return mpName; }
- unsigned short GetValue() const
- { return mnValue; }
- unsigned short GetLength() const
- { return mnLength; }
- Bool HasFeature( unsigned short nFeature ) const
- { return ((mnFeature & nFeature) != 0); }
- const String &GetAnnotation() const
- { return *mpAnnotation; }
- const rtl::OString&
- GetKey();
- void InitKey();
-
- void SetName( const char *p, int nLen );
- void SetValue( unsigned short nIn )
- { mnValue = nIn; }
- void SetAnnotation( String *pString )
- { mpAnnotation = pString; }
- void SetFeature( unsigned short nFeature )
- { mnFeature = nFeature; }
- void TagFeature( unsigned short nFeature );
-
- int Compare( const char *p, int nLen );
- Bool ExactMatch( const char *p, int nLen );
- void Release();
-};
-
-
-void
-AppendAttribute( Attribute *pAttribute, ByteString &rString );
-
-
-typedef String*(*AttributeAnnotatorT)(const Attribute &rAttribute);
-extern "C" {
-typedef rtl_TextEncoding(*AttributeClassifierT)(const char* pStr);
-}
-
-#define XLFD_FEATURE_NONE 0x0000
-#define XLFD_FEATURE_NARROW 0x0001
-#define XLFD_FEATURE_OL_GLYPH 0x0002
-#define XLFD_FEATURE_OL_CURSOR 0x0004
-#define XLFD_FEATURE_REDUNDANTSTYLE 0x0008
-#define XLFD_FEATURE_APPLICATION_FONT 0x0010
-
-#define XLFD_FEATURE_INTERFACE_FONT 0x0020
-#define XLFD_FEATURE_LQ 0x0040
-#define XLFD_FEATURE_MQ 0x0080
-#define XLFD_FEATURE_HQ 0x0100
-
-// ---------------------------------------------------------------------------
-//
-//
-// manage global lists of Attributes
-// since XListFonts does never list more than 64K fonts this storage does
-// handle array size and indices with unsigned short values for low
-// memory consumption
-//
-//
-// ---------------------------------------------------------------------------
-
-class AttributeStorage {
-
- private:
-
- Attribute* mpList;
- unsigned short mnSize;
- unsigned short mnCount;
- unsigned short mnLastmatch;
- unsigned short mnDefaultValue;
-
- void Enlarge();
- AttributeStorage();
-
- public:
-
- AttributeStorage( unsigned short nDefaultValue );
- ~AttributeStorage();
- unsigned short Insert( const char *pString, int nLength );
- Attribute* Retrieve( unsigned short nIndex ) const ;
- void AddClassification( Attribute *pClassification,
- unsigned short nNum );
- void AddClassification( AttributeClassifierT Classify );
- void TagFeature( unsigned short nFeature );
- void AddAnnotation( AttributeAnnotatorT Annotate );
- #if OSL_DEBUG_LEVEL > 1
- void Dump();
- #endif
-};
-
-
-// ---------------------------------------------------------------------------
-//
-//
-// Attribute provider is a frame for a set of AttributeStorages. For XLFD
-// interpretation and efficient storage, AttributeStorages for foundry,
-// family_name, weight_name, slant, setwidth_name, add_style_name and combined
-// charset_registry and charset_encoding are used. pixel_size, point_size,
-// resolution_x and resolution_y are stored as numbers. please note that this
-// does not allow storage of matrix-enhanced fonts. spacing is stored as
-// a char, since only the 'm', 'c' and 'p' types are defined.
-//
-//
-// ---------------------------------------------------------------------------
-
-enum eXLFDAttributeT {
- eXLFDFoundry = 0,
- eXLFDFamilyName,
- eXLFDWeightName,
- eXLFDSlant,
- eXLFDSetwidthName,
- eXLFDAddstyleName,
- eXLFDCharset,
- eXLFDMaxEntry
-};
-
-class AttributeProvider {
-
- private:
-
- AttributeStorage* mpField[ eXLFDMaxEntry ];
-
- AttributeStorage* GetField( eXLFDAttributeT eXLFDField )
- { return mpField[ eXLFDField]; }
- public:
-
- AttributeProvider ();
- ~AttributeProvider ();
-
- void AddClassification();
- void AddAnnotation();
- void TagFeature();
- #if OSL_DEBUG_LEVEL > 1
- void Dump();
- #endif
-
- // these are just shortcuts or proxies for the most common used
- // AttributeStorage functionality
- AttributeStorage* GetFoundry()
- { return GetField(eXLFDFoundry); }
- AttributeStorage* GetFamily()
- { return GetField(eXLFDFamilyName); }
- AttributeStorage* GetWeight()
- { return GetField(eXLFDWeightName); }
- AttributeStorage* GetSlant()
- { return GetField(eXLFDSlant); }
- AttributeStorage* GetSetwidth()
- { return GetField(eXLFDSetwidthName); }
- AttributeStorage* GetAddstyle()
- { return GetField(eXLFDAddstyleName); }
- AttributeStorage* GetCharset()
- { return GetField(eXLFDCharset); }
-
- Attribute* RetrieveFoundry( unsigned short nIndex )
- { return GetFoundry()->Retrieve(nIndex); }
- Attribute* RetrieveFamily( unsigned short nIndex )
- { return GetFamily()->Retrieve(nIndex); }
- Attribute* RetrieveWeight( unsigned short nIndex )
- { return GetWeight()->Retrieve(nIndex); }
- Attribute* RetrieveSlant( unsigned short nIndex )
- { return GetSlant()->Retrieve(nIndex); }
- Attribute* RetrieveSetwidth( unsigned short nIndex )
- { return GetSetwidth()->Retrieve(nIndex); }
- Attribute* RetrieveAddstyle( unsigned short nIndex )
- { return GetAddstyle()->Retrieve(nIndex); }
- Attribute* RetrieveCharset( unsigned short nIndex )
- { return GetCharset()->Retrieve(nIndex); }
-
- unsigned short InsertFoundry( const char *pString, int nLength )
- { return GetFoundry()->Insert(pString, nLength); }
- unsigned short InsertFamily( const char *pString, int nLength )
- { return GetFamily()->Insert(pString, nLength); }
- unsigned short InsertWeight( const char *pString, int nLength )
- { return GetWeight()->Insert(pString, nLength); }
- unsigned short InsertSlant( const char *pString, int nLength )
- { return GetSlant()->Insert(pString, nLength); }
- unsigned short InsertSetwidth( const char *pString, int nLength )
- { return GetSetwidth()->Insert(pString, nLength);}
- unsigned short InsertAddstyle( const char *pString, int nLength )
- { return GetAddstyle()->Insert(pString, nLength);}
- unsigned short InsertCharset( const char *pString, int nLength )
- { return GetCharset()->Insert(pString, nLength); }
-};
-
-#endif /* XLFD_ATTRIBUTE_HXX */
-
diff --git a/vcl/unx/source/gdi/xlfd_extd.cxx b/vcl/unx/source/gdi/xlfd_extd.cxx
deleted file mode 100644
index 73731eddf115..000000000000
--- a/vcl/unx/source/gdi/xlfd_extd.cxx
+++ /dev/null
@@ -1,1001 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_vcl.hxx"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "xlfd_attr.hxx"
-#include "xlfd_smpl.hxx"
-#include "xlfd_extd.hxx"
-#include <vcl/outfont.hxx>
-#include <rtl/alloc.h>
-
-#ifndef _RTL_TENCINFO_H_
-#include <rtl/tencinfo.h>
-#endif
-
-#include <set>
-
-// --------------------------------------------------------------------------
-
-ImplX11FontData::ImplX11FontData( const ExtendedXlfd& rXlfd, int nHeight )
-: ImplFontData( rXlfd, X11IFD_MAGIC ),
- mrXlfd( rXlfd )
-{
- mnHeight = nHeight;
- mnWidth = 0;
-}
-
-ImplFontEntry* ImplX11FontData::CreateFontInstance( ImplFontSelectData& rFSD ) const
-{
- ImplFontEntry* pEntry = new ImplFontEntry( rFSD );
- return pEntry;
-}
-
-sal_IntPtr ImplX11FontData::GetFontId() const
-{
- return reinterpret_cast<sal_IntPtr>(&mrXlfd);
-}
-
-// --------------------------------------------------------------------------
-//
-// classes for Xlfd handling that contain more than a single encoding.
-// Members that may vary through different encodings are stored in
-// a mpEncodingInfo member. There are three different classes:
-// true scalable fonts (truetype and type1) scalable bitmap fonts
-// (the ugly ones) and bitmap fonts. The ExtendedXlfd stores all the members
-// that are specific to a font outline
-// ( e.g. adobe-times-roman-medium-r-normal- X -p- X )
-// and specifies the interface.
-//
-// --------------------------------------------------------------------------
-
-ExtendedXlfd::EncodingInfo&
-ExtendedXlfd::EncodingInfo::operator= ( const Xlfd *pXlfd )
-{
- mcSpacing = pXlfd->mcSpacing;
- mnResolutionX = pXlfd->mnResolutionX;
- mnResolutionY = pXlfd->mnResolutionY;
- mnAddstyle = pXlfd->mnAddstyle;
- mnCharset = pXlfd->mnCharset;
- mnEncoding = pXlfd->GetEncoding();
-
- return *this;
-}
-
-// ------ base class --------------------------------------------------------
-
-ExtendedXlfd::ExtendedXlfd( bool bScalable )
-: mbScalable( bScalable ),
- mnEncodings( 0 ),
- mnEncCapacity( 0 ),
- mpEncodingInfo( NULL )
-{
- mbOrientation = false;
- mbDevice = false;
- mbSubsettable = false;
- mbEmbeddable = false;
-
- mnQuality = -1;
-}
-
-ExtendedXlfd::~ExtendedXlfd()
-{
- if ( mnEncodings != 0 )
- rtl_freeMemory( mpEncodingInfo );
-}
-
-inline void*
-Realloc( void *pPtr, sal_Size nSize )
-{
- return rtl_reallocateMemory( pPtr, nSize );
-}
-
-int
-ExtendedXlfd::GetEncodingIdx( rtl_TextEncoding nEncoding ) const
-{
- for ( int i = 0; i < mnEncodings; i++ )
- if ( nEncoding == mpEncodingInfo[i].mnEncoding )
- return i;
- return -1;
-}
-
-bool
-ExtendedXlfd::HasEncoding( rtl_TextEncoding nEncoding ) const
-{
- return !(GetEncodingIdx( nEncoding ) < 0) ;
-}
-
-rtl_TextEncoding
-ExtendedXlfd::GetEncoding( int i ) const
-{
- if ( i < mnEncodings && i >= 0 )
- return mpEncodingInfo[i].mnEncoding;
-
- return RTL_TEXTENCODING_DONTKNOW;
-}
-
-rtl_TextEncoding
-ExtendedXlfd::GetEncoding() const
-{
- return mnEncodings == 1 ? mpEncodingInfo[0].mnEncoding : RTL_TEXTENCODING_DONTKNOW;
-}
-
-// query the most unicode / Ascii compatible font: either one of the fonts
-// is utf16 encoded or there's a single byte font which is unicode
-// compatible for the first 256 chars (latin1) or for at least 128
-// chars (most latin-X encodings, cyrillic encodings)
-rtl_TextEncoding
-ExtendedXlfd::GetAsciiEncoding( int *pAsciiRange ) const
-{
- rtl_TextEncoding nBestEncoding = RTL_TEXTENCODING_DONTKNOW;
- int nLargestRange = 0x0000;
-
- for ( int i = 0; i < mnEncodings && nLargestRange < 0xffff; i++ )
- {
- rtl_TextEncoding nCurEncoding = mpEncodingInfo[i].mnEncoding;
- switch ( nCurEncoding )
- {
- case RTL_TEXTENCODING_UNICODE:
- nLargestRange = 0xffff;
- nBestEncoding = nCurEncoding;
- break;
-
- case RTL_TEXTENCODING_ISO_8859_1:
- case RTL_TEXTENCODING_MS_1252:
- nLargestRange = 0x00ff;
- nBestEncoding = nCurEncoding;
- break;
-
- case RTL_TEXTENCODING_ISO_8859_2:
- case RTL_TEXTENCODING_ISO_8859_4:
- case RTL_TEXTENCODING_ISO_8859_5:
- case RTL_TEXTENCODING_ISO_8859_6:
- case RTL_TEXTENCODING_ISO_8859_7:
- case RTL_TEXTENCODING_ISO_8859_8:
- case RTL_TEXTENCODING_ISO_8859_9:
- case RTL_TEXTENCODING_ISO_8859_13:
- case RTL_TEXTENCODING_ISO_8859_15:
- case RTL_TEXTENCODING_MS_1251:
- case RTL_TEXTENCODING_KOI8_R:
- case RTL_TEXTENCODING_JIS_X_0201:
- if ( nLargestRange < 0x0080 )
- {
- nLargestRange = 0x0080;
- nBestEncoding = nCurEncoding;
- }
- break;
-
- default:
- if ( nLargestRange == 0x0000 )
- {
- nBestEncoding = nCurEncoding;
- }
- break;
- }
- }
-
- if ( pAsciiRange != NULL )
- *pAsciiRange = nLargestRange;
-
- return nBestEncoding;
-}
-
-bool
-ExtendedXlfd::AddEncoding( const Xlfd *pXlfd )
-{
- rtl_TextEncoding nEncoding = pXlfd->GetEncoding();
- if ( HasEncoding(nEncoding) )
- return false;
-
- if ( mnEncodings == 0 )
- {
- // bootstrap
- mnFoundry = pXlfd->mnFoundry;
- mnFamily = pXlfd->mnFamily;
- mnWeight = pXlfd->mnWeight;
- mnSlant = pXlfd->mnSlant;
- mnSetwidth = pXlfd->mnSetwidth;
- mpFactory = pXlfd->mpFactory;
-
- Attribute *pFamilyAttr = mpFactory->RetrieveFamily( mnFamily );
- Attribute *pWeightAttr = mpFactory->RetrieveWeight( mnWeight );
- Attribute *pWidthAttr = mpFactory->RetrieveSetwidth( mnSetwidth );
- Attribute *pSlantAttr = mpFactory->RetrieveSlant( mnSlant );
-
- meFamily = GetFamilyType();
- meWeight = GetWeight();
- meItalic = GetSlant();
- meWidthType = GetWidthType();
- mbSymbolFlag= (GetEncoding() == RTL_TEXTENCODING_SYMBOL);
- mePitch = GetPitch();
-
- maName = pFamilyAttr->GetAnnotation();
-
- // the helvetica narrow hack
- if ( ! pFamilyAttr->HasFeature(XLFD_FEATURE_NARROW)
- && pWidthAttr->HasFeature(XLFD_FEATURE_NARROW) )
- {
- static const String aNarrow( RTL_CONSTASCII_USTRINGPARAM(" Narrow") );
- maName += aNarrow;
- }
-
- // stylename = weight + slant + width
- // XXX Fix me: there may be a space missing between them
- if ( meWeight != WEIGHT_NORMAL )
- maStyleName += pWeightAttr->GetAnnotation();
- if ( meItalic != ITALIC_NONE )
- maStyleName += pSlantAttr->GetAnnotation();
- if ( (meWidthType != WIDTH_NORMAL)
- && (! pWidthAttr->HasFeature(XLFD_FEATURE_NARROW)) )
- maStyleName += pWidthAttr->GetAnnotation();
- }
-
- if( mnEncodings <= mnEncCapacity )
- {
- mnEncCapacity += mnEncodings + 4;
- mpEncodingInfo = (EncodingInfo*)Realloc( mpEncodingInfo, mnEncCapacity * sizeof(EncodingInfo) );
- }
-
- mpEncodingInfo[ mnEncodings ] = pXlfd;
- mnEncodings += 1;
- return true;
-}
-
-void
-ExtendedXlfd::ToString( ByteString &rString,
- unsigned short /*nPixelSize*/, rtl_TextEncoding /*nEncoding*/ ) const
-{
- AppendAttribute( mpFactory->RetrieveFoundry(mnFoundry), rString );
- AppendAttribute( mpFactory->RetrieveFamily(mnFamily), rString );
- AppendAttribute( mpFactory->RetrieveWeight(mnWeight), rString );
- AppendAttribute( mpFactory->RetrieveSlant(mnSlant), rString );
- AppendAttribute( mpFactory->RetrieveSetwidth(mnSetwidth), rString );
-}
-
-void
-ExtendedXlfd::ToString( ByteString &rString,
- unsigned short /*nPixelSize*/, char* /*pMatricsString*/, rtl_TextEncoding /*nEncoding*/ ) const
-{
- AppendAttribute( mpFactory->RetrieveFoundry(mnFoundry), rString );
- AppendAttribute( mpFactory->RetrieveFamily(mnFamily), rString );
- AppendAttribute( mpFactory->RetrieveWeight(mnWeight), rString );
- AppendAttribute( mpFactory->RetrieveSlant(mnSlant), rString );
- AppendAttribute( mpFactory->RetrieveSetwidth(mnSetwidth), rString );
-}
-
-static FontPitch GetPitchFromX11Pitch( const char cSpacing )
-{
- switch ( cSpacing )
- {
- case 'c': // fall through
- case 'm': return PITCH_FIXED;
- case 'p': return PITCH_VARIABLE;
- default: return PITCH_DONTKNOW;
- }
-}
-
-// you must not call any of the ExtendedXlfd::GetXXX() functions if the
-// ExtendedXlfd is really empty (i.e. mnEncodings is zero)
-
-FontPitch ExtendedXlfd::GetPitch() const
-{
- if( mnEncodings > 1 )
- return PITCH_VARIABLE;
- if( mnEncodings == 1 )
- return GetPitchFromX11Pitch( mpEncodingInfo[0].mcSpacing );
- return PITCH_DONTKNOW;
-}
-
-FontPitch ExtendedXlfd::GetPitch( rtl_TextEncoding nEncoding ) const
-{
- for ( int nIdx = 0; nIdx < mnEncodings; nIdx++ )
- if ( mpEncodingInfo[nIdx].mnEncoding == nEncoding )
- return GetPitchFromX11Pitch( mpEncodingInfo[nIdx].mcSpacing );
- return PITCH_DONTKNOW;
-}
-
-FontFamily ExtendedXlfd::GetFamilyType() const
-{
- Attribute *pFamilyAttr= mpFactory->RetrieveFamily(mnFamily);
- return (FontFamily)pFamilyAttr->GetValue();
-}
-
-FontWeight ExtendedXlfd::GetWeight() const
-{
- Attribute *pWeightAttr = mpFactory->RetrieveWeight(mnWeight);
- return (FontWeight)pWeightAttr->GetValue();
-}
-
-FontItalic ExtendedXlfd::GetSlant() const
-{
- Attribute *pSlantAttr = mpFactory->RetrieveSlant(mnSlant);
- return (FontItalic)pSlantAttr->GetValue();
-}
-
-FontWidth ExtendedXlfd::GetWidthType() const
-{
- Attribute *pWidthAttr = mpFactory->RetrieveSetwidth(mnSetwidth);
- return (FontWidth)pWidthAttr->GetValue();
-}
-
-class CodeRange
-{
-public:
- CodeRange( int nMin, int nEnd ) : mnMin( nMin ), mnEnd( nEnd ) {}
-
- sal_uInt32 GetMin() const { return mnMin; }
- sal_uInt32 GetEnd() const { return mnEnd; }
-
- bool operator<( const CodeRange& r ) const
- { return (mnMin<r.mnMin) || ((mnMin==r.mnMin) && (mnEnd<r.mnEnd)); }
-
-private:
- sal_uInt32 mnMin, mnEnd;
-};
-
-
-int ExtendedXlfd::GetFontCodeRanges( sal_uInt32* pCodePairs ) const
-{
- bool bHasUnicode = false;
- bool bHasUnknownEncoding = false;
-
- // approximate unicode ranges from encodings
- typedef std::set<CodeRange> RangeSet;
- RangeSet aRangeSet;
-
- for( unsigned short i = 0; i < mnEncodings; ++i )
- {
- // TODO: move encoding -> unicode range mapping to RTL
- // NOTE: for now only some are VERY roughly approximated
- const rtl_TextEncoding eEncoding = mpEncodingInfo[i].mnEncoding;
- switch( mpEncodingInfo[i].mnEncoding )
- {
- case RTL_TEXTENCODING_SYMBOL: // postscript symbol encoding
- aRangeSet.insert( CodeRange( 0x0020, 0x0100 ) ); // symbol aliasing
- aRangeSet.insert( CodeRange( 0xF020, 0xF100 ) );
- break;
-
- case RTL_TEXTENCODING_ISO_8859_15:
- aRangeSet.insert( CodeRange( 0x20AC, 0x20AD ) ); // Euro currency symbol
- // fall through
- case RTL_TEXTENCODING_APPLE_ROMAN:
- case RTL_TEXTENCODING_ISO_8859_1:
- case RTL_TEXTENCODING_MS_1252:
- case RTL_TEXTENCODING_IBM_437:
- case RTL_TEXTENCODING_IBM_852:
- aRangeSet.insert( CodeRange( 0x0020, 0x0080 ) );
- aRangeSet.insert( CodeRange( 0x00A0, 0x0100 ) );
- break;
-
- // Traditional, Simplified, Japanese
- case RTL_TEXTENCODING_APPLE_CHINSIMP:
- case RTL_TEXTENCODING_APPLE_CHINTRAD:
- case RTL_TEXTENCODING_APPLE_JAPANESE:
- case RTL_TEXTENCODING_SHIFT_JIS:
- case RTL_TEXTENCODING_GB_2312:
- case RTL_TEXTENCODING_GBT_12345:
- case RTL_TEXTENCODING_GBK:
- case RTL_TEXTENCODING_BIG5:
- case RTL_TEXTENCODING_EUC_JP:
- case RTL_TEXTENCODING_EUC_CN:
- case RTL_TEXTENCODING_EUC_TW:
- case RTL_TEXTENCODING_ISO_2022_JP:
- case RTL_TEXTENCODING_ISO_2022_CN:
- case RTL_TEXTENCODING_GB_18030:
- case RTL_TEXTENCODING_BIG5_HKSCS:
- case RTL_TEXTENCODING_JIS_X_0201:
- case RTL_TEXTENCODING_JIS_X_0208:
- case RTL_TEXTENCODING_JIS_X_0212:
- case RTL_TEXTENCODING_MS_932:
- case RTL_TEXTENCODING_MS_936:
- case RTL_TEXTENCODING_MS_950:
- aRangeSet.insert( CodeRange( 0x3000, 0xA000 ) );
- aRangeSet.insert( CodeRange( 0xF900, 0xFB00 ) );
- break;
-
- // Korean
- case RTL_TEXTENCODING_APPLE_KOREAN:
- case RTL_TEXTENCODING_MS_949:
- case RTL_TEXTENCODING_MS_1361:
- case RTL_TEXTENCODING_EUC_KR:
- case RTL_TEXTENCODING_ISO_2022_KR:
- aRangeSet.insert( CodeRange( 0x1100, 0x1200 ) );
- aRangeSet.insert( CodeRange( 0x3130, 0x3190 ) );
- aRangeSet.insert( CodeRange( 0xAC00, 0xD7A4 ) );
- break;
-
- // unknown encoding
- case RTL_TEXTENCODING_DONTKNOW:
- bHasUnknownEncoding = true;
- break;
-
- // Unicode
- case RTL_TEXTENCODING_UNICODE:
- case RTL_TEXTENCODING_UTF7:
- case RTL_TEXTENCODING_UTF8:
- bHasUnicode = true;
- break;
-
- // misc 8bit encodings
- default:
- if( !rtl_isOctetTextEncoding( eEncoding ) )
- bHasUnknownEncoding = true;
- else
- {
- // use the unicode converter to get the coverage of an 8bit encoding
- rtl_TextToUnicodeConverter aConverter = rtl_createTextToUnicodeConverter( eEncoding );
- rtl_UnicodeToTextContext aCvtContext = rtl_createTextToUnicodeContext( aConverter );
- if( !aConverter || !aCvtContext )
- bHasUnknownEncoding = true;
- else
- {
- sal_Char cCharsInp[ 0x100 ];
- for( int j = 0x20; j < 0x080; ++j )
- cCharsInp[ j-0x20 ] = j;
- for( int j = 0xA0; j < 0x100; ++j )
- cCharsInp[ j-0x40 ] = j;
-
- sal_Unicode cCharsOut[ 0x100 ];
- sal_uInt32 nCvtInfo;
- sal_Size nSrcCvtBytes;
- int nOutLen = rtl_convertTextToUnicode(
- aConverter, aCvtContext,
- cCharsInp, 0xC0,
- cCharsOut, sizeof(cCharsOut)/sizeof(*cCharsOut),
- RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE
- | RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE,
- &nCvtInfo, &nSrcCvtBytes );
-
- for( int j = 0; j < nOutLen; ++j )
- aRangeSet.insert( CodeRange( cCharsOut[j], cCharsOut[j]+1 ) );
-
- rtl_destroyTextToUnicodeConverter( aCvtContext );
- rtl_destroyTextToUnicodeConverter( aConverter );
- }
- }
- break;
- }
- }
-
- // unicode encoded fonts usually do not cover the entire unicode range
- // => only use them to determine coverage when no other encodings are available
- if( aRangeSet.empty() && (bHasUnicode || bHasUnknownEncoding) )
- {
- if( pCodePairs )
- {
- pCodePairs[0] = 0x0020;
- pCodePairs[1] = 0xD800;
- pCodePairs[2] = 0xE000;
- pCodePairs[3] = 0xFFFE;
- }
- return 2;
- }
-
- if( aRangeSet.empty() )
- return 0;
-
- // sort and merge the code pairs
- sal_uInt32* pDst = pCodePairs;
- RangeSet::const_iterator it = aRangeSet.begin();
- for( sal_uInt32 nEnd = 0; it != aRangeSet.end(); ++it )
- {
- // check overlap with to previous range
- const CodeRange& rSrc = *it;
- if( nEnd < rSrc.GetMin() )
- {
- nEnd = rSrc.GetEnd();
- if( pCodePairs )
- {
- pDst[0] = rSrc.GetMin();
- pDst[1] = rSrc.GetEnd();
- }
- pDst += 2;
- }
- else
- {
- // merge overlapping ranges
- if( nEnd < rSrc.GetEnd() )
- {
- nEnd = rSrc.GetEnd();
- if( pCodePairs )
- pDst[-1] = nEnd;
- }
- }
- }
-
- int nRangeCount = (pDst - pCodePairs) / 2;
- return nRangeCount;
-}
-
-// ------ class to handle scalable bitmap fonts ------------------------------
-
-ScalableBitmapXlfd::ScalableBitmapXlfd()
-: ExtendedXlfd( true )
-{}
-
-ScalableBitmapXlfd::~ScalableBitmapXlfd()
-{}
-
-void
-ScalableBitmapXlfd::ToString( ByteString &rString,
- unsigned short nPixelSize, rtl_TextEncoding nEncoding ) const
-{
- int nIdx = GetEncodingIdx( nEncoding );
- if ( nIdx < 0 )
- return;
-
- ExtendedXlfd::ToString( rString, nPixelSize, nEncoding );
- EncodingInfo& rInfo = mpEncodingInfo[ nIdx ];
-
- AppendAttribute( mpFactory->RetrieveAddstyle(rInfo.mnAddstyle), rString );
-
- rString += '-';
- rString += ByteString::CreateFromInt32( nPixelSize );
- rString += "-0-";
- rString += ByteString::CreateFromInt32( rInfo.mnResolutionX );
- rString += '-';
- rString += ByteString::CreateFromInt32( rInfo.mnResolutionY );
- rString += '-';
- rString += static_cast< char >(rInfo.mcSpacing);
- rString += "-0";
-
- AppendAttribute( mpFactory->RetrieveCharset(rInfo.mnCharset), rString );
-}
-
-void
-ScalableBitmapXlfd::ToString( ByteString &rString,
- unsigned short nPixelSize, char *pMatricsString, rtl_TextEncoding nEncoding ) const
-{
- int nIdx = GetEncodingIdx( nEncoding );
- if ( nIdx < 0 )
- return;
-
- ExtendedXlfd::ToString( rString, nPixelSize, nEncoding );
- EncodingInfo& rInfo = mpEncodingInfo[ nIdx ];
-
- AppendAttribute( mpFactory->RetrieveAddstyle(rInfo.mnAddstyle), rString );
-
- rString += "-*-";
- char pTmp[256];
- snprintf( pTmp, sizeof(pTmp), pMatricsString, nPixelSize, nPixelSize );
- rString += pTmp;
- rString += "-*-*-";
- rString += static_cast< char >(rInfo.mcSpacing);
- rString += "-*";
-
- AppendAttribute( mpFactory->RetrieveCharset(rInfo.mnCharset), rString );
-}
-
-ImplFontData* ScalableBitmapXlfd::GetImplFontData() const
-{
- ImplX11FontData* pFontData = new ImplX11FontData( *this, 0 );
- pFontData->mnQuality= 0;
- return pFontData;
-}
-
-// ------ class to handle true bitmap fonts ----------------------------------
-
-void
-BitmapXlfd::ToString( ByteString &rString,
- unsigned short nPixelSize, char *pMatricsString, rtl_TextEncoding nEncoding ) const
-{
- int nIdx = GetEncodingIdx( nEncoding );
- if ( nIdx < 0 )
- return;
-
- ExtendedXlfd::ToString( rString, nPixelSize, nEncoding );
- EncodingInfo& rInfo = mpEncodingInfo[ nIdx ];
-
- AppendAttribute( mpFactory->RetrieveAddstyle(rInfo.mnAddstyle), rString );
-
- rString += "-*-";
- char pTmp[256];
- snprintf( pTmp, sizeof(pTmp), pMatricsString, nPixelSize, nPixelSize );
- rString += pTmp;
- rString += "-*-*-";
- rString += static_cast< char >(rInfo.mcSpacing);
- rString += "-*";
-
- AppendAttribute( mpFactory->RetrieveCharset(rInfo.mnCharset), rString );
-}
-
-BitmapXlfd::BitmapXlfd( )
-: ExtendedXlfd( false )
-{}
-
-BitmapXlfd::~BitmapXlfd( )
-{}
-
-bool
-BitmapXlfd::AddEncoding( const Xlfd *pXlfd )
-{
- if ( mnEncodings == 0 )
- {
- mnPixelSize = pXlfd->mnPixelSize;
- mnPointSize = pXlfd->mnPointSize;
- mnAverageWidth = pXlfd->mnAverageWidth;
- }
-
- return ExtendedXlfd::AddEncoding( pXlfd );
-}
-
-void
-BitmapXlfd::ToString( ByteString &rString,
- unsigned short nPixelSize, rtl_TextEncoding nEncoding ) const
-{
- int nIdx = GetEncodingIdx( nEncoding );
- if ( nIdx < 0 )
- return;
-
- ExtendedXlfd::ToString( rString, nPixelSize, nEncoding );
- EncodingInfo& rInfo = mpEncodingInfo[ nIdx ];
- AppendAttribute( mpFactory->RetrieveAddstyle(rInfo.mnAddstyle), rString );
- rString += '-';
- rString += ByteString::CreateFromInt32( mnPixelSize );
- rString += "-*-*-*-";
- rString += static_cast< char >(rInfo.mcSpacing);
- rString += "-*";
-
- AppendAttribute( mpFactory->RetrieveCharset(rInfo.mnCharset), rString );
-}
-
-ImplFontData* BitmapXlfd::GetImplFontData() const
-{
- ImplX11FontData* pFontData = new ImplX11FontData( *this, mnPixelSize );
- pFontData->mnQuality= 100;
- return pFontData;
-}
-
-// ------ class to handle true scalable fonts --------------------------------
-
-ScalableXlfd::ScalableXlfd()
-: ExtendedXlfd( true )
-{}
-
-ScalableXlfd::~ScalableXlfd()
-{}
-
-void
-ScalableXlfd::ToString( ByteString &rString,
- unsigned short nPixelSize, rtl_TextEncoding nEncoding ) const
-{
- int nIdx = GetEncodingIdx( nEncoding );
- if ( nIdx < 0 )
- return;
-
- ExtendedXlfd::ToString( rString, nPixelSize, nEncoding);
-
- EncodingInfo& rInfo = mpEncodingInfo[ nIdx ];
- AppendAttribute( mpFactory->RetrieveAddstyle(rInfo.mnAddstyle), rString );
-
- rString += '-';
- rString += ByteString::CreateFromInt32( nPixelSize );
- rString += "-0-0-0-";
- rString += static_cast< char >(rInfo.mcSpacing);
- rString += "-0";
-
- AppendAttribute( mpFactory->RetrieveCharset(rInfo.mnCharset), rString );
-}
-
-void
-ScalableXlfd::ToString( ByteString &rString,
- unsigned short nPixelSize, char* pMatricsString, rtl_TextEncoding nEncoding ) const
-{
- int nIdx = GetEncodingIdx( nEncoding );
- if ( nIdx < 0 )
- return;
-
- ExtendedXlfd::ToString( rString, nPixelSize, nEncoding);
-
- EncodingInfo& rInfo = mpEncodingInfo[ nIdx ];
- AppendAttribute( mpFactory->RetrieveAddstyle(rInfo.mnAddstyle), rString );
-
- rString += "-*-";
- char pTmp[256];
- snprintf( pTmp, sizeof(pTmp), pMatricsString, nPixelSize, nPixelSize );
- rString += pTmp;
- rString += "-*-*-";
- rString += static_cast< char >(rInfo.mcSpacing);
- rString += "-*";
-
- AppendAttribute( mpFactory->RetrieveCharset(rInfo.mnCharset), rString );
-}
-
-ImplFontData* ScalableXlfd::GetImplFontData() const
-{
- ImplX11FontData* pFontData = new ImplX11FontData( *this, 0 );
- pFontData->mnQuality= 200;
- return pFontData;
-}
-
-/* ------- virtual fonts for user interface ------------------------------- */
-
-VirtualXlfd::ExtEncodingInfo&
-VirtualXlfd::ExtEncodingInfo::operator= ( const Xlfd *pXlfd )
-{
- mnFoundry = pXlfd->mnFoundry;
- mnFamily = pXlfd->mnFamily;
- mnWeight = pXlfd->mnWeight;
- mnSlant = pXlfd->mnSlant;
- mnSetwidth = pXlfd->mnSetwidth;
-
- return *this;
-}
-
-VirtualXlfd::VirtualXlfd()
-: ExtendedXlfd( true ),
- mnExtCapacity(0),
- mpExtEncodingInfo(NULL)
-{
- mnFoundry = 0;
- mnFamily = 0;
- mnWeight = 0;
- mnSlant = 0;
- mnSetwidth = 0;
-}
-
-VirtualXlfd::~VirtualXlfd()
-{
- if ( mpExtEncodingInfo != NULL )
- rtl_freeMemory( mpExtEncodingInfo );
-}
-
-int
-VirtualXlfd::GetFontQuality (unsigned short nFamily)
-{
- Attribute *pFamily = mpFactory->RetrieveFamily(nFamily);
- int nQuality = 0;
-
- if (pFamily->HasFeature(XLFD_FEATURE_HQ))
- nQuality += 16;
- if (pFamily->HasFeature(XLFD_FEATURE_MQ))
- nQuality += 8;
- if (pFamily->HasFeature(XLFD_FEATURE_LQ))
- nQuality += 4;
- return nQuality;
-}
-
-bool
-VirtualXlfd::AddEncoding( const Xlfd *pXlfd )
-{
- // add new font
- bool bRC = ExtendedXlfd::AddEncoding( pXlfd );
-
- int nIdx;
- if( bRC )
- {
- // new encoding => append the new pXlfd
- nIdx = mnEncodings - 1;
- if( nIdx >= mnExtCapacity )
- {
- mnExtCapacity = mnEncCapacity;
- mpExtEncodingInfo = (ExtEncodingInfo*)Realloc( mpExtEncodingInfo,
- mnExtCapacity * sizeof(ExtEncodingInfo) );
- }
- }
- else
- {
- // existing encoding => check if the new pXlfd is better
- rtl_TextEncoding nEncoding = pXlfd->GetEncoding();
- nIdx = GetEncodingIdx( nEncoding );
-
- int nOldQuality = GetFontQuality( mpExtEncodingInfo[nIdx].mnFamily );
- int nNewQuality = GetFontQuality( pXlfd->mnFamily );
- if( nOldQuality >= nNewQuality )
- return false;
- }
-
- mpExtEncodingInfo[ nIdx ] = pXlfd;
- return true;
-}
-
-void
-VirtualXlfd::FilterInterfaceFont (const Xlfd *pXlfd)
-{
- Attribute *pAttr;
- AttributeProvider *pFactory = pXlfd->mpFactory;
-
- if (! pXlfd->Fonttype() == TYPE_SCALABLE)
- return;
- pAttr = pFactory->RetrieveFamily(pXlfd->mnFamily);
- if (! pAttr->HasFeature(XLFD_FEATURE_INTERFACE_FONT))
- return;
- pAttr = pFactory->RetrieveSlant(pXlfd->mnSlant);
- if (! (FontItalic)pAttr->GetValue() == ITALIC_NONE)
- return;
- pAttr = pFactory->RetrieveSetwidth(pXlfd->mnSetwidth);
- if (pAttr->HasFeature(XLFD_FEATURE_NARROW))
- return;
- pAttr = pFactory->RetrieveWeight(pXlfd->mnWeight);
- FontWeight eWeight = (FontWeight)pAttr->GetValue();
- if ((eWeight != WEIGHT_NORMAL) && (eWeight != WEIGHT_MEDIUM))
- return;
-
- AddEncoding (pXlfd);
-}
-
-void
-VirtualXlfd::ToString( ByteString &rString, unsigned short nPixelSize,
- rtl_TextEncoding nEncoding ) const
-{
- int nIdx = GetEncodingIdx( nEncoding );
- if ( nIdx < 0 )
- return;
-
- ExtEncodingInfo &rExtInfo = mpExtEncodingInfo[ nIdx ];
-
- AppendAttribute( mpFactory->RetrieveFoundry(rExtInfo.mnFoundry), rString );
- AppendAttribute( mpFactory->RetrieveFamily(rExtInfo.mnFamily), rString );
- AppendAttribute( mpFactory->RetrieveWeight(rExtInfo.mnWeight), rString );
- AppendAttribute( mpFactory->RetrieveSlant(rExtInfo.mnSlant), rString );
- AppendAttribute( mpFactory->RetrieveSetwidth(rExtInfo.mnSetwidth), rString );
-
- EncodingInfo& rInfo = mpEncodingInfo[ nIdx ];
- AppendAttribute( mpFactory->RetrieveAddstyle(rInfo.mnAddstyle), rString );
-
- rString += '-';
- rString += ByteString::CreateFromInt32( nPixelSize );
- rString += "-0-0-0-";
- rString += static_cast< char >(rInfo.mcSpacing);
- rString += "-0";
-
- AppendAttribute( mpFactory->RetrieveCharset(rInfo.mnCharset), rString );
-}
-
-void
-VirtualXlfd::ToString( ByteString &rString, unsigned short nPixelSize,
- char* pMatricsString, rtl_TextEncoding nEncoding ) const
-{
- int nIdx = GetEncodingIdx( nEncoding );
- if ( nIdx < 0 )
- return;
-
- ExtEncodingInfo &rExtInfo = mpExtEncodingInfo[ nIdx ];
-
- AppendAttribute( mpFactory->RetrieveFoundry(rExtInfo.mnFoundry), rString );
- AppendAttribute( mpFactory->RetrieveFamily(rExtInfo.mnFamily), rString );
- AppendAttribute( mpFactory->RetrieveWeight(rExtInfo.mnWeight), rString );
- AppendAttribute( mpFactory->RetrieveSlant(rExtInfo.mnSlant), rString );
- AppendAttribute( mpFactory->RetrieveSetwidth(rExtInfo.mnSetwidth), rString );
-
- EncodingInfo& rInfo = mpEncodingInfo[ nIdx ];
- AppendAttribute( mpFactory->RetrieveAddstyle(rInfo.mnAddstyle), rString );
-
- rString += "-*-";
- char pTmp[256];
- snprintf( pTmp, sizeof(pTmp), pMatricsString, nPixelSize, nPixelSize );
- rString += pTmp;
- rString += "-*-*-";
- rString += static_cast< char >(rInfo.mcSpacing);
- rString += "-*";
-
- AppendAttribute( mpFactory->RetrieveCharset(rInfo.mnCharset), rString );
-}
-
-ImplFontData* VirtualXlfd::GetImplFontData() const
-{
- ImplX11FontData* pFontData = new ImplX11FontData( *this, 0 );
-
- // family name
- static const String aFontName( RTL_CONSTASCII_USTRINGPARAM("Interface User") );
- pFontData->maName = aFontName;
- // pFontData->maStyleName = aStyleName;
- pFontData->meFamily = FAMILY_SWISS;
- pFontData->meWeight = WEIGHT_NORMAL;
- pFontData->meItalic = ITALIC_NONE;
- pFontData->meWidthType = WIDTH_NORMAL;
- pFontData->mePitch = PITCH_VARIABLE;
-
- pFontData->mbSymbolFlag = false;
- pFontData->mbOrientation= false;
- pFontData->mbDevice = true;
- pFontData->mnQuality = 100;
-
- return pFontData;
-}
-
-// ------ font list -------------------------------------------------------
-
-XlfdStorage::XlfdStorage()
-{
- maXlfdList.reserve( 256 );
-}
-
-void
-XlfdStorage::Dispose()
-{
- XlfdList::const_iterator it = maXlfdList.begin();
- for(; it != maXlfdList.end(); ++it )
- delete *it;
- maXlfdList.clear();
-}
-
-void
-XlfdStorage::Reset()
-{
- maXlfdList.clear();
-}
-
-void
-XlfdStorage::Add( const ExtendedXlfd* pXlfd )
-{
- if ( pXlfd != NULL )
- maXlfdList.push_back( pXlfd );
-}
-
-void
-XlfdStorage::Add( const XlfdStorage* pXlfd )
-{
- if ( !pXlfd || pXlfd->maXlfdList.empty() )
- return;
-
- maXlfdList.reserve( maXlfdList.size() + pXlfd->maXlfdList.size() );
- XlfdList::const_iterator it = pXlfd->maXlfdList.begin();
- for(; it != pXlfd->maXlfdList.end(); ++it )
- maXlfdList.push_back( *it );
-}
-
-void XlfdStorage::AnnounceFonts( ImplDevFontList* pList ) const
-{
- XlfdList::const_iterator it = maXlfdList.begin();
- for(; it != maXlfdList.end(); ++it )
- {
- const ExtendedXlfd* pXlfd = *it;
- ImplFontData* pFontData = pXlfd->GetImplFontData();
- pList->Add( pFontData );
- }
-}
-
-// ------ bitmap font list --------------------------------------------------
-
-void
-BitmapXlfdStorage::AddBitmapFont( const Xlfd *pXlfd )
-{
- if ( pXlfd == NULL )
- return;
-
- int nPixelSize = pXlfd->mnPixelSize;
- XlfdList::const_iterator it = maXlfdList.begin();
- for(; it != maXlfdList.end(); ++it )
- {
- BitmapXlfd* pBitmapXlfd = (BitmapXlfd*)*it;
- if( nPixelSize == pBitmapXlfd->GetPixelSize() )
- {
- // we need to add an encoding to an existing bitmap font
- pBitmapXlfd->AddEncoding( pXlfd );
- return;
- }
- }
-
- // we have a new bitmap font
- BitmapXlfd* pBitmapXlfd = new BitmapXlfd;
- pBitmapXlfd->AddEncoding( pXlfd );
- Add( pBitmapXlfd );
-}
diff --git a/vcl/unx/source/gdi/xlfd_extd.hxx b/vcl/unx/source/gdi/xlfd_extd.hxx
deleted file mode 100644
index 523f87fac477..000000000000
--- a/vcl/unx/source/gdi/xlfd_extd.hxx
+++ /dev/null
@@ -1,272 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-#ifndef XLFD_EXTENDED_HXX
-#define XLFD_EXTENDED_HXX
-
-#include <salunx.h>
-#ifndef _VCL_VCLENUM_HXX
-#include <vcl/enum.hxx>
-#endif
-#ifndef _VCL_OUTFONT_HXX
-#include <vcl/outfont.hxx>
-#endif
-
-#include <vector>
-
-class Xlfd;
-class AttributeProvider;
-class ImplDevFontList;
-class ByteString;
-
-// --------------------------------------------------------------------------
-//
-// classes for Xlfd handling that contain more than a single encoding.
-// Members that may vary through different encodings are stored in
-// a mpEncodingInfo member. There are three different classes:
-// true scalable fonts (truetype and type1) scalable bitmap fonts
-// (the ugly ones) and bitmap fonts. The ExtendedXlfd stores all the members
-// that are specific to a font outline
-// ( e.g. adobe-times-roman-medium-r-normal- * -p- * )
-// and specifies the interface.
-//
-// --------------------------------------------------------------------------
-
-// base class
-
-class ExtendedXlfd : public ImplDevFontAttributes
-{
- public:
- ExtendedXlfd( bool bScalable );
- virtual ~ExtendedXlfd();
- virtual bool AddEncoding( const Xlfd* );
- bool HasEncoding( rtl_TextEncoding ) const;
- int GetEncodingIdx( rtl_TextEncoding nEncoding ) const;
- unsigned short NumEncodings() const
- { return mnEncodings; }
- virtual int GetPixelSize() const
- { return 0; }
- virtual void ToString( ByteString &rString,
- unsigned short nPixelSize,
- rtl_TextEncoding nEncoding ) const ;
- virtual void ToString( ByteString &rString,
- unsigned short nPixelSize,
- char* pMatricsString,
- rtl_TextEncoding nEncoding ) const;
-
- virtual ImplFontData* GetImplFontData() const = 0;
- bool IsScalable() const { return mbScalable; }
- virtual FontFamily GetFamilyType() const;
- virtual FontWeight GetWeight() const;
- virtual FontItalic GetSlant() const;
- virtual FontWidth GetWidthType() const;
- virtual FontPitch GetPitch() const;
- virtual FontPitch GetPitch( rtl_TextEncoding ) const;
- rtl_TextEncoding GetAsciiEncoding( int *pAsciiRange = NULL ) const;
- rtl_TextEncoding GetEncoding() const;
- rtl_TextEncoding GetEncoding( int i ) const;
-
- int GetFontCodeRanges( sal_uInt32* pCodePairs ) const;
-
- protected:
- AttributeProvider* mpFactory;
-
- public:
- unsigned short mnFoundry;
- unsigned short mnFamily;
- unsigned short mnWeight;
- unsigned short mnSlant;
- unsigned short mnSetwidth;
- bool mbScalable;
-
- protected:
- unsigned short mnEncodings;
- unsigned short mnEncCapacity;
- struct EncodingInfo {
- unsigned char mcSpacing;
- unsigned short mnResolutionX;
- unsigned short mnResolutionY;
- unsigned short mnAddstyle;
- unsigned short mnCharset;
- rtl_TextEncoding mnEncoding;
-
- EncodingInfo& operator= ( const Xlfd *pXlfd );
- } *mpEncodingInfo;
-};
-
-// class to handle scalable bitmap fonts
-
-class ScalableBitmapXlfd : public ExtendedXlfd {
-
- public:
- ScalableBitmapXlfd();
- virtual ~ScalableBitmapXlfd();
- virtual void ToString( ByteString &rString,
- unsigned short nPixelSize,
- rtl_TextEncoding nEncoding ) const;
- virtual void ToString( ByteString &rString,
- unsigned short nPixelSize,
- char* pMatricsString,
- rtl_TextEncoding nEncoding ) const;
-
- virtual ImplFontData* GetImplFontData() const ;
-};
-
-// class to handle true bitmap fonts
-
-class ScalableXlfd;
-
-class BitmapXlfd : public ExtendedXlfd {
-
- public:
- BitmapXlfd();
- ~BitmapXlfd();
- bool AddEncoding( const Xlfd* );
- virtual int GetPixelSize() const
- { return mnPixelSize; }
- virtual void ToString( ByteString &rString,
- unsigned short nPixelSize,
- rtl_TextEncoding nEncoding ) const;
- virtual void ToString( ByteString &rString,
- unsigned short nPixelSize,
- char* pMatricsString,
- rtl_TextEncoding nEncoding ) const;
- virtual ImplFontData* GetImplFontData() const ;
- protected:
-
- unsigned short mnPixelSize;
- unsigned short mnPointSize;
- unsigned short mnAverageWidth;
-};
-
-// class to handle true scalable fonts
-
-class ScalableXlfd : public ExtendedXlfd {
-
- friend class BitmapXlfd;
-
- public:
- ScalableXlfd();
- virtual ~ScalableXlfd();
- virtual void ToString( ByteString &rString,
- unsigned short nPixelSize,
- rtl_TextEncoding nEncoding ) const;
-
- virtual void ToString( ByteString &rString,
- unsigned short nPixelSize,
- char* pMatricsString,
- rtl_TextEncoding nEncoding ) const;
- virtual ImplFontData* GetImplFontData() const ;
-};
-
-// class to maintain a list of fonts ( bitmap and scalable )
-
-class XlfdStorage {
-
- public:
- XlfdStorage();
-
- void Dispose();
- void Reset();
-
- void Add( const ExtendedXlfd *pXlfd );
- void Add( const XlfdStorage *pXlfd );
- void AnnounceFonts( ImplDevFontList* ) const;
-
- protected:
-
- typedef ::std::vector<const ExtendedXlfd*> XlfdList;
- XlfdList maXlfdList;
-};
-
-// list of fonts specific for bitmap fonts
-
-class BitmapXlfdStorage : public XlfdStorage {
-
- public:
-
- void AddBitmapFont( const Xlfd *pXlfd );
-};
-
-
-/* Virtual font for User Interface */
-
-class VirtualXlfd : public ExtendedXlfd
-{
- private:
-
- int GetFontQuality (unsigned short nFamily);
-
- public:
- VirtualXlfd();
- virtual ~VirtualXlfd();
- virtual bool AddEncoding( const Xlfd* );
- void FilterInterfaceFont (const Xlfd *pXlfd);
- virtual void ToString( ByteString &rString,
- unsigned short nPixelSize,
- rtl_TextEncoding nEncoding ) const ;
- virtual void ToString( ByteString &rString,
- unsigned short nPixelSize,
- char* pMatricsString,
- rtl_TextEncoding nEncoding ) const;
-
- virtual ImplFontData* GetImplFontData() const ;
- protected:
-
- unsigned short mnExtCapacity;
- struct ExtEncodingInfo {
- unsigned short mnFoundry;
- unsigned short mnFamily;
- unsigned short mnWeight;
- unsigned short mnSlant;
- unsigned short mnSetwidth;
-
- ExtEncodingInfo& operator= ( const Xlfd *pXlfd );
- } *mpExtEncodingInfo;
-
- friend class ExtEncodingInfo;
-};
-
-
-// class to describe a X11 physically available font face
-
-class ImplX11FontData : public ImplFontData
-{
-private:
- enum { X11IFD_MAGIC = 0x111FDA1C };
- const ExtendedXlfd& mrXlfd;
-
-public:
- ImplX11FontData( const ExtendedXlfd&, int nHeight );
- const ExtendedXlfd& GetExtendedXlfd() const { return mrXlfd; }
- virtual ImplFontData* Clone() const { return new ImplX11FontData( *this ); }
- virtual ImplFontEntry* CreateFontInstance( ImplFontSelectData& ) const;
- virtual sal_IntPtr GetFontId() const;
-
- static bool CheckFontData( const ImplFontData& r ) { return r.CheckMagic( X11IFD_MAGIC ); }
-};
-
-#endif /* XLFD_EXTENDED_HXX */
diff --git a/vcl/unx/source/gdi/xlfd_smpl.cxx b/vcl/unx/source/gdi/xlfd_smpl.cxx
deleted file mode 100644
index 6cf18d98de1e..000000000000
--- a/vcl/unx/source/gdi/xlfd_smpl.cxx
+++ /dev/null
@@ -1,268 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_vcl.hxx"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "xlfd_attr.hxx"
-#include "xlfd_smpl.hxx"
-
-// --------------------------------------------------------------------------
-//
-//
-// broken down structure equivalent to a Xlfd string
-//
-//
-// --------------------------------------------------------------------------
-
-Xlfd::Xlfd()
-{
-}
-
-// XlfdCompare abi has to be qsort(3) compatible, the sorting result must
-// guarantee that fonts with SameFontoutline() are successive
-// XlfdCompare relies on vFrom->mpFactory eq vTo->mpFactory. Since comparing
-// Xlfd's is done by comparing attributes there is no way around this.
-extern "C" int
-XlfdCompare( const void *vFrom, const void *vTo )
-{
- const Xlfd *pFrom = (Xlfd*)vFrom;
- const Xlfd *pTo = (Xlfd*)vTo;
-
- // Compare outline description
- if ( pFrom->mnFoundry != pTo->mnFoundry )
- return (int)pFrom->mnFoundry - (int)pTo->mnFoundry;
- if ( pFrom->mnFamily != pTo->mnFamily )
- return (int)pFrom->mnFamily - (int)pTo->mnFamily;
- if ( pFrom->mnWeight != pTo->mnWeight )
- return (int)pFrom->mnWeight - (int)pTo->mnWeight;
- if ( pFrom->mnSlant != pTo->mnSlant )
- return (int)pFrom->mnSlant - (int)pTo->mnSlant;
- if ( pFrom->mnSetwidth != pTo->mnSetwidth )
- return (int)pFrom->mnSetwidth - (int)pTo->mnSetwidth;
-
- // Addstyle name is futile tricky. it may contain encoding information
- // (like "ansi_1251") which Compares equal, or it may contain style
- // information (like "serif") which Compares unequal, anyway if the font
- // is "interface user" or "interface system" then compare equal anyway to
- // build fontsets as large as possible
- if ( pFrom->mnAddstyle == pTo->mnAddstyle )
- return 0;
-
- AttributeProvider *pFactory = pFrom->mpFactory;
- Attribute *pFamily = pFactory->RetrieveFamily( pFrom->mnFamily );
- if ( pFamily->HasFeature(XLFD_FEATURE_APPLICATION_FONT) )
- return 0;
-
- Attribute *pFromAddStyle = pFactory->RetrieveAddstyle( pFrom->mnAddstyle );
- Attribute *pToAddStyle = pFactory->RetrieveAddstyle( pTo->mnAddstyle );
-
- // if both addstyles denote encodings or if one denotes an
- // encoding and the other denotes a style which really
- // duplicates weight and slant information
-
- int nFromCompare = (pFromAddStyle->GetValue() != RTL_TEXTENCODING_DONTKNOW)
- || (pFromAddStyle->HasFeature(XLFD_FEATURE_REDUNDANTSTYLE)) ?
- -1 : pFrom->mnAddstyle;
- int nToCompare = (pToAddStyle->GetValue() != RTL_TEXTENCODING_DONTKNOW)
- || (pToAddStyle->HasFeature(XLFD_FEATURE_REDUNDANTSTYLE)) ?
- -1 : pTo->mnAddstyle;
-
- return nFromCompare - nToCompare;
-}
-
-// check whether two fonts are identical as appearance is concerned
-// this does not Compare the actual scaling of two fonts
-Bool
-Xlfd::SameFontoutline( const Xlfd* pComparedTo ) const
-{
- void* pThis = (void*)this;
- return XlfdCompare( (void*)pThis, (void*)pComparedTo ) == 0 ;
-}
-
-unsigned short
-Xlfd::GetEncoding() const
-{
- Attribute *pAddstyle = mpFactory->RetrieveAddstyle( mnAddstyle );
- if ( pAddstyle->GetValue() != RTL_TEXTENCODING_DONTKNOW )
- return pAddstyle->GetValue();
-
- Attribute *pEncoding = mpFactory->RetrieveCharset( mnCharset );
- return pEncoding->GetValue();
-}
-
-XlfdFonttype
-Xlfd::Fonttype() const
-{
- if ( (mnAverageWidth == 0) && (mnPixelSize == 0) && (mnPointSize == 0) )
- {
- return (mnResolutionX == 0)
- && (mnResolutionY == 0) ? eTypeScalable : eTypeScalableBitmap;
- }
-
- return eTypeBitmap;
-}
-
-void
-Advance( const char** pFrom, const char** pTo )
-{
- const char *pTmp = *pTo;
-
- for( ; (*pTmp != '\0') && (*pTmp++ != '-'); )
- {}
- *pFrom = *pTo;
- *pTo = pTmp;
-}
-
-Bool
-Xlfd::IsConformant (const char* pXlfd) const
-{
- // X FontNameRegistry prefix "-"
- if (*pXlfd++ != '-')
- return False;
-
- // All Xlfd FontName fields are defined
- int nNumFields = 1;
- while (*pXlfd != '\0')
- {
- if (*pXlfd++ == '-')
- nNumFields++;
- }
- // enough entries ?
- if (nNumFields != 14)
- return False;
- // and the last one is not empty as well ?
- if (*(pXlfd - 1) == '-')
- return False;
-
- return True;
-}
-
-// this is the real workhorse function. Since this is called for every font
-// in the fontpath it has to be as fast a possible
-Bool
-Xlfd::FromString( const char* pXlfdstring, AttributeProvider *pFactory )
-{
- if (!IsConformant(pXlfdstring))
- return False;
-
- const char* pFrom = pXlfdstring + 1;
- const char* pTo = pFrom;
- mpFactory = pFactory;
-
- Advance( &pFrom, &pTo ); //-foundry-*
- mnFoundry = mpFactory->InsertFoundry( pFrom, pTo - pFrom - 1 );
-
- Advance( &pFrom, &pTo ); // -*-family-*
- mnFamily = mpFactory->InsertFamily( pFrom, pTo - pFrom - 1 );
-
- Advance( &pFrom, &pTo ); // -*-*-weight-*
- mnWeight = mpFactory->InsertWeight( pFrom, pTo - pFrom - 1 );
-
- Advance( &pFrom, &pTo ); //-*-*-*-slant-*
- mnSlant = mpFactory->InsertSlant( pFrom, pTo - pFrom - 1 );
-
- Advance( &pFrom, &pTo ); //-*-*-*-*-setwidth-*
- mnSetwidth = mpFactory->InsertSetwidth( pFrom, pTo - pFrom - 1 );
-
- Advance( &pFrom, &pTo ); //-*-*-*-*-*-Addstyle-*
- mnAddstyle = mpFactory->InsertAddstyle( pFrom, pTo - pFrom - 1 );
-
- Advance( &pFrom, &pTo ); //-*-*-*-*-*-*-height-*
- mnPixelSize = atoi( pFrom );
-
- Advance( &pFrom, &pTo ); //-*-*-*-*-*-*-*-pt height-*
- mnPointSize = atoi( pFrom );
-
- Advance( &pFrom, &pTo ); //-*-*-*-*-*-*-*-*-x resolution-*
- mnResolutionX = atoi( pFrom );
-
- Advance( &pFrom, &pTo ); //-*-*-*-*-*-*-*-*-*-y resolution-*
- mnResolutionY = atoi( pFrom );
-
- Advance( &pFrom, &pTo ); //-*-*-*-*-*-*-*-*-*-*-spacing-*
- mcSpacing = pFrom == pTo ? '\0' : *pFrom;
-
- Advance( &pFrom, &pTo ); //-*-*-*-*-*-*-*-*-*-*-*-average-*
- mnAverageWidth = atoi( pFrom );
-
- Advance( &pFrom, &pTo ); //-*-*-*-*-*-*-*-*-*-*-*-*-registry-encoding
- const char* pTmp = pFrom;
- Advance( &pTmp, &pTo );
- mnCharset = mpFactory->InsertCharset( pFrom, pTo - pFrom );
-
- // sanity check whether we have really found a valid XLFD, if not
- // throw away the whole font, since we have no idea what parts of
- // the XLFD contains the error.
- if ( !(pTo > pFrom) )
- return False;
-
- // a non-empty family name is essential, since otherwise the font
- // would match the "default font" #52299#
- Attribute* pFamily = mpFactory->RetrieveFamily( mnFamily );
- const char* pFamilyName = pFamily->GetName();
- if ( pFamilyName[0] == '\0' )
- return False;
-
- // well done
- return True;
-}
-
-#if OSL_DEBUG_LEVEL > 1
-// pure debug for now: this is only to inspect/pretty print a Xlfd struct
-const char*
-Xlfd::ToString( ByteString &rString ) const
-{
- AppendAttribute( mpFactory->RetrieveFoundry(mnFoundry), rString );
- AppendAttribute( mpFactory->RetrieveFamily(mnFamily), rString );
- AppendAttribute( mpFactory->RetrieveWeight(mnWeight), rString );
- AppendAttribute( mpFactory->RetrieveSlant(mnSlant), rString );
- AppendAttribute( mpFactory->RetrieveSetwidth(mnSetwidth), rString );
- AppendAttribute( mpFactory->RetrieveAddstyle(mnAddstyle), rString );
-
- rString.Append("-"); rString.Append( ByteString::CreateFromInt32( mnPixelSize ) );
- rString.Append("-"); rString.Append( ByteString::CreateFromInt32( mnPointSize ) );
- rString.Append("-"); rString.Append( ByteString::CreateFromInt32( mnResolutionX ) );
- rString.Append("-"); rString.Append( ByteString::CreateFromInt32( mnResolutionY ) );
- rString.Append("-"); rString.Append( (char)mcSpacing );
- rString.Append("-"); rString.Append( ByteString::CreateFromInt32( mnAverageWidth ) );
-
- AppendAttribute( mpFactory->RetrieveCharset(mnCharset), rString );
-
- return rString.GetBuffer() ;
-}
-
-void
-Xlfd::Dump() const
-{
- ByteString aString;
- fprintf(stderr, "Xlfd: %s\n", ToString(aString) );
-}
-#endif
-
diff --git a/vcl/unx/source/gdi/xlfd_smpl.hxx b/vcl/unx/source/gdi/xlfd_smpl.hxx
deleted file mode 100644
index f62ac381e6b9..000000000000
--- a/vcl/unx/source/gdi/xlfd_smpl.hxx
+++ /dev/null
@@ -1,92 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2000, 2010 Oracle and/or its affiliates.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-#ifndef XLFD_SIMPLE_HXX
-#define XLFD_SIMPLE_HXX
-
-#include <salunx.h>
-#include <vcl/vclenum.hxx>
-#include <tools/string.hxx>
-
-class AttributeProvider;
-
-// --------------------------------------------------------------------------
-//
-//
-// broken down structure equivalent to a Xlfd string
-//
-//
-// --------------------------------------------------------------------------
-
-enum XlfdFonttype {
- eTypeUnknown = TYPE_DONTKNOW,
- eTypeBitmap = TYPE_RASTER,
- eTypeScalableBitmap = TYPE_VECTOR,
- eTypeScalable = TYPE_SCALABLE
-};
-
-class Xlfd {
-
- public:
-
- unsigned short mnFoundry;
- unsigned short mnFamily;
- unsigned short mnWeight;
- unsigned short mnSlant;
- unsigned short mnSetwidth;
- unsigned short mnAddstyle;
- unsigned short mnPixelSize;
- unsigned short mnPointSize;
- unsigned short mnResolutionX;
- unsigned short mnResolutionY;
- unsigned char mcSpacing;
- unsigned short mnAverageWidth;
- unsigned short mnCharset;
-
- // all foundry, family, weight ... information referres
- // to this factory
- AttributeProvider *mpFactory;
-
- Bool IsConformant( const char* pXlfdstring ) const;
-
- public:
- Xlfd();
- Bool FromString( const char* pXlfdstring,
- AttributeProvider *pFactory );
- Bool SameFontoutline( const Xlfd *pComparedTo ) const ;
- XlfdFonttype Fonttype() const ;
- unsigned short GetEncoding() const ;
- #if OSL_DEBUG_LEVEL > 1
- const char* ToString( ByteString &rString ) const ;
- void Dump() const;
- #endif
-};
-
-extern "C" int
-XlfdCompare( const void *vFrom, const void *vTo );
-
-#endif /* XLFD_SIMPLE_HXX */
-
diff --git a/vcl/unx/source/window/salframe.cxx b/vcl/unx/source/window/salframe.cxx
index 9934277302e1..11c20aa40f5a 100644
--- a/vcl/unx/source/window/salframe.cxx
+++ b/vcl/unx/source/window/salframe.cxx
@@ -3588,9 +3588,7 @@ long X11SalFrame::HandleFocusEvent( XFocusChangeEvent *pEvent )
if( FocusIn == pEvent->type )
{
-#ifndef _USE_PRINT_EXTENSION_
vcl_sal::PrinterUpdate::update();
-#endif
mbInputFocus = True;
ImplSVData* pSVData = ImplGetSVData();