diff options
Diffstat (limited to 'vcl/source/gdi/outdev3.cxx')
-rw-r--r-- | vcl/source/gdi/outdev3.cxx | 683 |
1 files changed, 382 insertions, 301 deletions
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index b41fa00c95ff..fd399c6c0a11 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -28,56 +28,57 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" -#include <cstring> -#include <i18npool/mslangid.hxx> - -#include <svsys.h> -#include <vcl/salgdi.hxx> -#include <vcl/sallayout.hxx> -#include <rtl/tencinfo.h> -#include <tools/debug.hxx> -#include <vcl/svdata.hxx> -#include <vcl/metric.hxx> -#include <vcl/impfont.hxx> -#include <vcl/metaact.hxx> -#include <vcl/gdimtf.hxx> -#include <vcl/outdata.hxx> -#include <vcl/outfont.hxx> -#include <basegfx/polygon/b2dpolygon.hxx> -#include <basegfx/polygon/b2dpolypolygon.hxx> -#include <basegfx/matrix/b2dhommatrix.hxx> -#include <tools/poly.hxx> -#include <vcl/outdev.h> -#include <vcl/virdev.hxx> -#include <vcl/print.hxx> -#include <vcl/event.hxx> -#include <vcl/window.h> -#include <vcl/window.hxx> -#include <vcl/svapp.hxx> -#include <vcl/bmpacc.hxx> -#include <unotools/fontcvt.hxx> -#include <vcl/outdev.hxx> -#include <vcl/edit.hxx> -#include <unotools/fontcfg.hxx> -#include <vcl/sysdata.hxx> -#include <vcl/textlayout.hxx> -#include <osl/file.h> + +#include "i18npool/mslangid.hxx" + +#include "svsys.h" +#include "vcl/salgdi.hxx" +#include "vcl/sallayout.hxx" +#include "rtl/tencinfo.h" +#include "tools/debug.hxx" +#include "vcl/svdata.hxx" +#include "vcl/metric.hxx" +#include "vcl/impfont.hxx" +#include "vcl/metaact.hxx" +#include "vcl/gdimtf.hxx" +#include "vcl/outdata.hxx" +#include "vcl/outfont.hxx" +#include "basegfx/polygon/b2dpolygon.hxx" +#include "basegfx/polygon/b2dpolypolygon.hxx" +#include "basegfx/matrix/b2dhommatrix.hxx" +#include "tools/poly.hxx" +#include "vcl/outdev.h" +#include "vcl/virdev.hxx" +#include "vcl/print.hxx" +#include "vcl/event.hxx" +#include "vcl/window.h" +#include "vcl/window.hxx" +#include "vcl/svapp.hxx" +#include "vcl/bmpacc.hxx" +#include "unotools/fontcvt.hxx" +#include "vcl/outdev.hxx" +#include "vcl/edit.hxx" +#include "unotools/fontcfg.hxx" +#include "vcl/sysdata.hxx" +#include "vcl/textlayout.hxx" +#include "vcl/svids.hrc" +#include "osl/file.h" #ifdef ENABLE_GRAPHITE -#include <vcl/graphite_features.hxx> +#include "vcl/graphite_features.hxx" #endif #ifdef USE_BUILTIN_RASTERIZER -#include <vcl/glyphcache.hxx> +#include "vcl/glyphcache.hxx" #endif -#include <vcl/unohelp.hxx> -#include <pdfwriter_impl.hxx> -#include <vcl/controllayout.hxx> -#include <rtl/logfile.hxx> +#include "vcl/unohelp.hxx" +#include "pdfwriter_impl.hxx" +#include "vcl/controllayout.hxx" +#include "rtl/logfile.hxx" -#include <com/sun/star/beans/PropertyValues.hdl> -#include <com/sun/star/i18n/XBreakIterator.hpp> -#include <com/sun/star/i18n/WordType.hpp> -#include <com/sun/star/linguistic2/XLinguServiceManager.hpp> +#include "com/sun/star/beans/PropertyValues.hpp" +#include "com/sun/star/i18n/XBreakIterator.hpp" +#include "com/sun/star/i18n/WordType.hpp" +#include "com/sun/star/linguistic2/XLinguServiceManager.hpp" #if defined UNX #define GLYPH_FONT_HEIGHT 128 @@ -87,7 +88,7 @@ #define GLYPH_FONT_HEIGHT 256 #endif -#include <sal/alloca.h> +#include "sal/alloca.h" #include <cmath> #include <cstring> @@ -225,7 +226,7 @@ void OutputDevice::ImplUpdateFontData( bool bNewFontLists ) if( mpFontCache && mpFontCache != pSVData->maGDIData.mpScreenFontCache ) delete mpFontCache; mpFontList = mpPDFWriter->filterDevFontList( pSVData->maGDIData.mpScreenFontList ); - mpFontCache = new ImplFontCache( FALSE ); + mpFontCache = new ImplFontCache( sal_False ); } else { @@ -317,7 +318,7 @@ void ImplFreeOutDevFontData() void OutputDevice::BeginFontSubstitution() { ImplSVData* pSVData = ImplGetSVData(); - pSVData->maGDIData.mbFontSubChanged = FALSE; + pSVData->maGDIData.mbFontSubChanged = sal_False; } // ----------------------------------------------------------------------- @@ -333,7 +334,7 @@ void OutputDevice::EndFontSubstitution() DataChangedEvent aDCEvt( DATACHANGED_FONTSUBSTITUTION ); pApp->DataChanged( aDCEvt ); pApp->NotifyAllWindows( aDCEvt ); - pSVData->maGDIData.mbFontSubChanged = FALSE; + pSVData->maGDIData.mbFontSubChanged = sal_False; } } @@ -341,19 +342,19 @@ void OutputDevice::EndFontSubstitution() void OutputDevice::AddFontSubstitute( const XubString& rFontName, const XubString& rReplaceFontName, - USHORT nFlags ) + sal_uInt16 nFlags ) { ImplDirectFontSubstitution*& rpSubst = ImplGetSVData()->maGDIData.mpDirectFontSubst; if( !rpSubst ) rpSubst = new ImplDirectFontSubstitution(); rpSubst->AddFontSubstitute( rFontName, rReplaceFontName, nFlags ); - ImplGetSVData()->maGDIData.mbFontSubChanged = TRUE; + ImplGetSVData()->maGDIData.mbFontSubChanged = sal_True; } // ----------------------------------------------------------------------- void ImplDirectFontSubstitution::AddFontSubstitute( const String& rFontName, - const String& rSubstFontName, USHORT nFlags ) + const String& rSubstFontName, sal_uInt16 nFlags ) { maFontSubstList.push_back( ImplFontSubstEntry( rFontName, rSubstFontName, nFlags ) ); } @@ -361,7 +362,7 @@ void ImplDirectFontSubstitution::AddFontSubstitute( const String& rFontName, // ----------------------------------------------------------------------- ImplFontSubstEntry::ImplFontSubstEntry( const String& rFontName, - const String& rSubstFontName, USHORT nSubstFlags ) + const String& rSubstFontName, sal_uInt16 nSubstFlags ) : maName( rFontName ) , maReplaceName( rSubstFontName ) , mnFlags( nSubstFlags ) @@ -376,7 +377,7 @@ ImplFontSubstEntry::ImplFontSubstEntry( const String& rFontName, void OutputDevice::ImplAddDevFontSubstitute( const XubString& rFontName, const XubString& rReplaceFontName, - USHORT nFlags ) + sal_uInt16 nFlags ) { ImplInitOutDevData(); mpOutDevData->maDevFontSubst.AddFontSubstitute( rFontName, rReplaceFontName, nFlags ); @@ -384,7 +385,7 @@ void OutputDevice::ImplAddDevFontSubstitute( const XubString& rFontName, // ----------------------------------------------------------------------- -void OutputDevice::RemoveFontSubstitute( USHORT n ) +void OutputDevice::RemoveFontSubstitute( sal_uInt16 n ) { ImplDirectFontSubstitution* pSubst = ImplGetSVData()->maGDIData.mpDirectFontSubst; if( pSubst ) @@ -403,21 +404,21 @@ void ImplDirectFontSubstitution::RemoveFontSubstitute( int nIndex ) // ----------------------------------------------------------------------- -USHORT OutputDevice::GetFontSubstituteCount() +sal_uInt16 OutputDevice::GetFontSubstituteCount() { const ImplDirectFontSubstitution* pSubst = ImplGetSVData()->maGDIData.mpDirectFontSubst; if( !pSubst ) return 0; int nCount = pSubst->GetFontSubstituteCount(); - return (USHORT)nCount; + return (sal_uInt16)nCount; } // ----------------------------------------------------------------------- -void OutputDevice::GetFontSubstitute( USHORT n, +void OutputDevice::GetFontSubstitute( sal_uInt16 n, XubString& rFontName, XubString& rReplaceFontName, - USHORT& rFlags ) + sal_uInt16& rFlags ) { const ImplDirectFontSubstitution* pSubst = ImplGetSVData()->maGDIData.mpDirectFontSubst; if( pSubst ) @@ -427,7 +428,7 @@ void OutputDevice::GetFontSubstitute( USHORT n, // ----------------------------------------------------------------------- bool ImplDirectFontSubstitution::GetFontSubstitute( int nIndex, - String& rFontName, String& rSubstFontName, USHORT& rFlags ) const + String& rFontName, String& rSubstFontName, sal_uInt16& rFlags ) const { FontSubstList::const_iterator it = maFontSubstList.begin(); for( int nCount = 0; (it != maFontSubstList.end()) && (nCount++ != nIndex); ++it ) ; @@ -444,7 +445,7 @@ bool ImplDirectFontSubstitution::GetFontSubstitute( int nIndex, // ----------------------------------------------------------------------- bool ImplDirectFontSubstitution::FindFontSubstitute( String& rSubstName, - const String& rSearchName, USHORT nFlags ) const + const String& rSearchName, sal_uInt16 nFlags ) const { // TODO: get rid of O(N) searches FontSubstList::const_iterator it = maFontSubstList.begin(); @@ -465,7 +466,7 @@ bool ImplDirectFontSubstitution::FindFontSubstitute( String& rSubstName, // ----------------------------------------------------------------------- static void ImplFontSubstitute( String& rFontName, - USHORT nFlags, ImplDirectFontSubstitution* pDevSpecific ) + sal_uInt16 nFlags, ImplDirectFontSubstitution* pDevSpecific ) { #ifdef DBG_UTIL String aTempName = rFontName; @@ -496,8 +497,8 @@ static void ImplFontSubstitute( String& rFontName, // ----------------------------------------------------------------------- -Font OutputDevice::GetDefaultFont( USHORT nType, LanguageType eLang, - ULONG nFlags, const OutputDevice* pOutDev ) +Font OutputDevice::GetDefaultFont( sal_uInt16 nType, LanguageType eLang, + sal_uLong nFlags, const OutputDevice* pOutDev ) { DBG_TRACE( "OutputDevice::GetDefaultFont()" ); @@ -730,7 +731,7 @@ static unsigned ImplIsCJKFont( const String& rFontName ) // ----------------------------------------------------------------------- -static void ImplCalcType( ULONG& rType, FontWeight& rWeight, FontWidth& rWidth, +static void ImplCalcType( sal_uLong& rType, FontWeight& rWeight, FontWidth& rWidth, FontFamily eFamily, const FontNameAttr* pFontAttr ) { if ( eFamily != FAMILY_DONTKNOW ) @@ -1322,11 +1323,11 @@ void ImplDevFontList::InitGenericGlyphFallback( void ) const "msmincho", "fzmingti", "fzheiti", "ipamincho", "sazanamimincho", "kochimincho", "", "sunbatang", "sundotum", "baekmukdotum", "gulim", "batang", "dotum", "", "hgmincholightj", "msunglightsc", "msunglighttc", "hymyeongjolightk", "", - "tahoma", "dejavusans", "timesnewroman", "lucidatypewriter", "lucidasans", "nimbussansl", "", + "tahoma", "dejavusans", "timesnewroman", "liberationsans", "", "shree", "mangal", "", "raavi", "shruti", "tunga", "", "latha", "gautami", "kartika", "vrinda", "", - "shayyalmt", "naskmt", "", + "shayyalmt", "naskmt", "scheherazade", "", "david", "nachlieli", "lucidagrande", "", "norasi", "angsanaupc", "", "khmerossystem", "", @@ -1376,6 +1377,7 @@ void ImplDevFontList::InitGenericGlyphFallback( void ) const } } +#ifdef SAL_FONTENUM_STABLE_ON_PLATFORM // #i113472# // sort the list of fonts for glyph fallback by quality (highest first) // #i33947# keep the EUDC font at the front of the list // an insertion sort is good enough for this short list @@ -1391,6 +1393,7 @@ void ImplDevFontList::InitGenericGlyphFallback( void ) const break; pFallbackList[ j+1 ] = pTestFont; } +#endif mnFallbackCount = nMaxLevel; mpFallbackList = pFallbackList; @@ -1631,10 +1634,25 @@ ImplDevFontListData* ImplDevFontList::ImplFindBySubstFontAttr( const utl::FontNa pFoundData = ImplFindBySearchName( aSearchName ); if( pFoundData ) - break; + return pFoundData; } - return pFoundData; + // use known attributes from the configuration to find a matching substitute + const sal_uLong nSearchType = rFontAttr.Type; + if( nSearchType != 0 ) + { + const FontWeight eSearchWeight = rFontAttr.Weight; + const FontWidth eSearchWidth = rFontAttr.Width; + const FontItalic eSearchSlant = ITALIC_DONTKNOW; + const FontFamily eSearchFamily = FAMILY_DONTKNOW; + const String aSearchName; + pFoundData = ImplFindByAttributes( nSearchType, + eSearchWeight, eSearchWidth, eSearchFamily, eSearchSlant, aSearchName ); + if( pFoundData ) + return pFoundData; + } + + return NULL; } // ----------------------------------------------------------------------- @@ -1660,20 +1678,20 @@ void ImplDevFontList::InitMatchData() const } //---------------------------------------------------------------------------- -ImplDevFontListData* ImplDevFontList::ImplFindByLocale(com::sun::star::lang::Locale lc) const +ImplDevFontListData* ImplDevFontList::ImplFindByLocale( com::sun::star::lang::Locale& rLocale ) const { // get the default font for a specified locale const DefaultFontConfiguration& rDefaults = *DefaultFontConfiguration::get(); - String aDefault = rDefaults.getUserInterfaceFont( lc ); + const String aDefault = rDefaults.getUserInterfaceFont( rLocale ); ImplDevFontListData* pFontData = ImplFindByTokenNames( aDefault ); if( pFontData ) return pFontData; - return 0; + return NULL; } // ----------------------------------------------------------------------- -ImplDevFontListData* ImplDevFontList::ImplFindByAttributes( ULONG nSearchType, +ImplDevFontListData* ImplDevFontList::ImplFindByAttributes( sal_uLong nSearchType, FontWeight eSearchWeight, FontWidth eSearchWidth, FontFamily /*eSearchFamily*/, FontItalic eSearchItalic, const String& rSearchFamilyName ) const { @@ -1691,7 +1709,7 @@ ImplDevFontListData* ImplDevFontList::ImplFindByAttributes( ULONG nSearchType, long nTestMatch; long nBestMatch = 40000; - ULONG nBestType = 0; + sal_uLong nBestType = 0; DevFontList::const_iterator it = maDevFontList.begin(); for(; it != maDevFontList.end(); ++it ) @@ -1699,7 +1717,7 @@ ImplDevFontListData* ImplDevFontList::ImplFindByAttributes( ULONG nSearchType, ImplDevFontListData* pData = (*it).second; // Get all information about the matching font - ULONG nMatchType = pData->mnMatchType; + sal_uLong nMatchType = pData->mnMatchType; FontWeight eMatchWeight= pData->meMatchWeight; FontWidth eMatchWidth = pData->meMatchWidth; @@ -2410,7 +2428,7 @@ ImplDevFontListData* ImplDevFontList::ImplFindByFont( ImplFontSelectData& rFSD, // test if a font in the token list is available // substitute the font if this was requested - USHORT nSubstFlags = FONT_SUBSTITUTE_ALWAYS; + sal_uInt16 nSubstFlags = FONT_SUBSTITUTE_ALWAYS; if ( bPrinter ) nSubstFlags |= FONT_SUBSTITUTE_SCREENONLY; @@ -2539,7 +2557,7 @@ ImplDevFontListData* ImplDevFontList::ImplFindByFont( ImplFontSelectData& rFSD, String aSearchFamilyName; FontWeight eSearchWeight = rFSD.meWeight; FontWidth eSearchWidth = rFSD.meWidthType; - ULONG nSearchType = 0; + sal_uLong nSearchType = 0; FontSubstConfiguration::getMapName( aSearchName, aSearchShortName, aSearchFamilyName, eSearchWeight, eSearchWidth, nSearchType ); @@ -2611,7 +2629,7 @@ ImplDevFontListData* ImplDevFontList::ImplFindByFont( ImplFontSelectData& rFSD, String aTempShortName; String aTempFamilyName; - ULONG nTempType = 0; + sal_uLong nTempType = 0; FontWeight eTempWeight = rFSD.meWeight; FontWidth eTempWidth = WIDTH_DONTKNOW; FontSubstConfiguration::getMapName( aSearchName, aTempShortName, aTempFamilyName, @@ -2883,17 +2901,17 @@ FontEmphasisMark OutputDevice::ImplGetEmphasisMarkStyle( const Font& rFont ) // ----------------------------------------------------------------------- -BOOL OutputDevice::ImplIsUnderlineAbove( const Font& rFont ) +sal_Bool OutputDevice::ImplIsUnderlineAbove( const Font& rFont ) { if ( !rFont.IsVertical() ) - return FALSE; + return sal_False; if( (LANGUAGE_JAPANESE == rFont.GetLanguage()) || (LANGUAGE_JAPANESE == rFont.GetCJKContextLanguage()) ) // the underline is right for Japanese only - return TRUE; + return sal_True; - return FALSE; + return sal_False; } // ======================================================================= @@ -2908,6 +2926,18 @@ void OutputDevice::ImplInitFontList() const mpGraphics->GetDevFontList( mpFontList ); } } + if( meOutDevType == OUTDEV_WINDOW && ! mpFontList->Count() ) + { + String aError( RTL_CONSTASCII_USTRINGPARAM( "Application error: no fonts and no vcl resource found on your system" ) ); + ResMgr* pMgr = ImplGetResMgr(); + if( pMgr ) + { + String aResStr( ResId( SV_ACCESSERROR_NO_FONTS, *pMgr ) ); + if( aResStr.Len() ) + aError = aResStr; + } + Application::Abort( aError ); + } } // ======================================================================= @@ -2946,7 +2976,7 @@ void OutputDevice::ImplInitTextColor() if ( mbInitTextColor ) { mpGraphics->SetTextColor( ImplColorToSal( GetTextColor() ) ); - mbInitTextColor = FALSE; + mbInitTextColor = sal_False; } } @@ -3003,9 +3033,9 @@ bool OutputDevice::ImplNewFont() const ImplFontEntry* pFontEntry = mpFontEntry; // mark when lower layers need to get involved - mbNewFont = FALSE; + mbNewFont = sal_False; if( pFontEntry != pOldEntry ) - mbInitFont = TRUE; + mbInitFont = sal_True; // select font when it has not been initialized yet if ( !pFontEntry->mbInit ) @@ -3106,10 +3136,10 @@ bool OutputDevice::ImplNewFont() const { Size aOrigSize = maFont.GetSize(); const_cast<Font&>(maFont).SetSize( Size( nNewWidth, aSize.Height() ) ); - mbMap = FALSE; - mbNewFont = TRUE; + mbMap = sal_False; + mbNewFont = sal_True; ImplNewFont(); // recurse once using stretched width - mbMap = TRUE; + mbMap = sal_True; const_cast<Font&>(maFont).SetSize( aOrigSize ); } } @@ -3129,17 +3159,17 @@ long OutputDevice::ImplGetTextWidth( const SalLayout& rSalLayout ) const // ----------------------------------------------------------------------- void OutputDevice::ImplDrawTextRect( long nBaseX, long nBaseY, - long nX, long nY, long nWidth, long nHeight ) + long nDistX, long nDistY, long nWidth, long nHeight ) { + long nX = nDistX; + long nY = nDistY; + short nOrientation = mpFontEntry->mnOrientation; if ( nOrientation ) { // Rotate rect without rounding problems for 90 degree rotations if ( !(nOrientation % 900) ) { - nX -= nBaseX; - nY -= nBaseY; - if ( nOrientation == 900 ) { long nTemp = nX; @@ -3167,12 +3197,11 @@ void OutputDevice::ImplDrawTextRect( long nBaseX, long nBaseY, nHeight = nTemp; nX -= nWidth; } - - nX += nBaseX; - nY += nBaseY; } else { + nX += nBaseX; + nY += nBaseY; // inflate because polygons are drawn smaller Rectangle aRect( Point( nX, nY ), Size( nWidth+1, nHeight+1 ) ); Polygon aPoly( aRect ); @@ -3182,6 +3211,8 @@ void OutputDevice::ImplDrawTextRect( long nBaseX, long nBaseY, } } + nX += nBaseX; + nY += nBaseY; mpGraphics->DrawRect( nX, nY, nWidth, nHeight, this ); } @@ -3197,12 +3228,12 @@ void OutputDevice::ImplDrawTextBackground( const SalLayout& rSalLayout ) if ( mbLineColor || mbInitLineColor ) { mpGraphics->SetLineColor(); - mbInitLineColor = TRUE; + mbInitLineColor = sal_True; } mpGraphics->SetFillColor( ImplColorToSal( GetTextFillColor() ) ); - mbInitFillColor = TRUE; + mbInitFillColor = sal_True; - ImplDrawTextRect( nX, nY, nX, nY-mpFontEntry->maMetric.mnAscent-mnEmphasisAscent, + ImplDrawTextRect( nX, nY, 0, -(mpFontEntry->maMetric.mnAscent + mnEmphasisAscent), nWidth, mpFontEntry->mnLineHeight+mnEmphasisAscent+mnEmphasisDescent ); } @@ -3466,7 +3497,7 @@ static void ImplDrawWavePixel( long nOriginX, long nOriginY, short nOrientation, SalGraphics* pGraphics, OutputDevice* pOutDev, - BOOL bDrawPixAsRect, + sal_Bool bDrawPixAsRect, long nPixWidth, long nPixHeight ) { @@ -3487,7 +3518,7 @@ static void ImplDrawWavePixel( long nOriginX, long nOriginY, // ----------------------------------------------------------------------- void OutputDevice::ImplDrawWaveLine( long nBaseX, long nBaseY, - long nStartX, long nStartY, + long nDistX, long nDistY, long nWidth, long nHeight, long nLineWidth, short nOrientation, const Color& rColor ) @@ -3495,11 +3526,14 @@ void OutputDevice::ImplDrawWaveLine( long nBaseX, long nBaseY, if ( !nHeight ) return; + long nStartX = nBaseX + nDistX; + long nStartY = nBaseY + nDistY; + // Bei Hoehe von 1 Pixel reicht es, eine Linie auszugeben if ( (nLineWidth == 1) && (nHeight == 1) ) { mpGraphics->SetLineColor( ImplColorToSal( rColor ) ); - mbInitLineColor = TRUE; + mbInitLineColor = sal_True; long nEndX = nStartX+nWidth; long nEndY = nStartY; @@ -3509,7 +3543,6 @@ void OutputDevice::ImplDrawWaveLine( long nBaseX, long nBaseY, ImplRotatePos( nBaseX, nBaseY, nEndX, nEndY, nOrientation ); } mpGraphics->DrawLine( nStartX, nStartY, nEndX, nEndY, this ); - } else { @@ -3523,28 +3556,28 @@ void OutputDevice::ImplDrawWaveLine( long nBaseX, long nBaseY, long i; long nPixWidth; long nPixHeight; - BOOL bDrawPixAsRect; + sal_Bool bDrawPixAsRect; // Auf Druckern die Pixel per DrawRect() ausgeben if ( (GetOutDevType() == OUTDEV_PRINTER) || (nLineWidth > 1) ) { if ( mbLineColor || mbInitLineColor ) { mpGraphics->SetLineColor(); - mbInitLineColor = TRUE; + mbInitLineColor = sal_True; } mpGraphics->SetFillColor( ImplColorToSal( rColor ) ); - mbInitFillColor = TRUE; - bDrawPixAsRect = TRUE; + mbInitFillColor = sal_True; + bDrawPixAsRect = sal_True; nPixWidth = nLineWidth; nPixHeight = ((nLineWidth*mnDPIX)+(mnDPIY/2))/mnDPIY; } else { mpGraphics->SetLineColor( ImplColorToSal( rColor ) ); - mbInitLineColor = TRUE; + mbInitLineColor = sal_True; nPixWidth = 1; nPixHeight = 1; - bDrawPixAsRect = FALSE; + bDrawPixAsRect = sal_False; } if ( !nDiffY ) @@ -3609,10 +3642,10 @@ void OutputDevice::ImplDrawWaveLine( long nBaseX, long nBaseY, // ----------------------------------------------------------------------- void OutputDevice::ImplDrawWaveTextLine( long nBaseX, long nBaseY, - long nX, long nY, long nWidth, + long nDistX, long nDistY, long nWidth, FontUnderline eTextLine, Color aColor, - BOOL bIsAbove ) + sal_Bool bIsAbove ) { ImplFontEntry* pFontEntry = mpFontEntry; long nLineHeight; @@ -3635,7 +3668,7 @@ void OutputDevice::ImplDrawWaveTextLine( long nBaseX, long nBaseY, nLineWidth = 1; if ( eTextLine == UNDERLINE_BOLDWAVE ) nLineWidth *= 2; - nLinePos += nY - (nLineHeight / 2); + nLinePos += nDistY - (nLineHeight / 2); long nLineWidthHeight = ((nLineWidth*mnDPIX)+(mnDPIY/2))/mnDPIY; if ( eTextLine == UNDERLINE_DOUBLEWAVE ) { @@ -3656,16 +3689,16 @@ void OutputDevice::ImplDrawWaveTextLine( long nBaseX, long nBaseY, nLineDY2 = 1; nLinePos -= nLineWidthHeight-nLineDY2; - ImplDrawWaveLine( nBaseX, nBaseY, nX, nLinePos, nWidth, nLineHeight, + ImplDrawWaveLine( nBaseX, nBaseY, nDistX, nLinePos, nWidth, nLineHeight, nLineWidth, mpFontEntry->mnOrientation, aColor ); nLinePos += nLineWidthHeight+nLineDY; - ImplDrawWaveLine( nBaseX, nBaseY, nX, nLinePos, nWidth, nLineHeight, + ImplDrawWaveLine( nBaseX, nBaseY, nDistX, nLinePos, nWidth, nLineHeight, nLineWidth, mpFontEntry->mnOrientation, aColor ); } else { nLinePos -= nLineWidthHeight/2; - ImplDrawWaveLine( nBaseX, nBaseY, nX, nLinePos, nWidth, nLineHeight, + ImplDrawWaveLine( nBaseX, nBaseY, nDistX, nLinePos, nWidth, nLineHeight, nLineWidth, mpFontEntry->mnOrientation, aColor ); } } @@ -3673,16 +3706,18 @@ void OutputDevice::ImplDrawWaveTextLine( long nBaseX, long nBaseY, // ----------------------------------------------------------------------- void OutputDevice::ImplDrawStraightTextLine( long nBaseX, long nBaseY, - long nX, long nY, long nWidth, + long nDistX, long nDistY, long nWidth, FontUnderline eTextLine, Color aColor, - BOOL bIsAbove ) + sal_Bool bIsAbove ) { ImplFontEntry* pFontEntry = mpFontEntry; long nLineHeight = 0; long nLinePos = 0; long nLinePos2 = 0; + const long nY = nDistY; + if ( eTextLine > UNDERLINE_LAST ) eTextLine = UNDERLINE_SINGLE; @@ -3745,12 +3780,12 @@ void OutputDevice::ImplDrawStraightTextLine( long nBaseX, long nBaseY, if ( mbLineColor || mbInitLineColor ) { mpGraphics->SetLineColor(); - mbInitLineColor = TRUE; + mbInitLineColor = sal_True; } mpGraphics->SetFillColor( ImplColorToSal( aColor ) ); - mbInitFillColor = TRUE; + mbInitFillColor = sal_True; - long nLeft = nX; + long nLeft = nDistX; switch ( eTextLine ) { @@ -3903,7 +3938,7 @@ void OutputDevice::ImplDrawStraightTextLine( long nBaseX, long nBaseY, // ----------------------------------------------------------------------- void OutputDevice::ImplDrawStrikeoutLine( long nBaseX, long nBaseY, - long nX, long nY, long nWidth, + long nDistX, long nDistY, long nWidth, FontStrikeout eStrikeout, Color aColor ) { @@ -3912,6 +3947,8 @@ void OutputDevice::ImplDrawStrikeoutLine( long nBaseX, long nBaseY, long nLinePos = 0; long nLinePos2 = 0; + long nY = nDistY; + if ( eStrikeout > STRIKEOUT_LAST ) eStrikeout = STRIKEOUT_SINGLE; @@ -3939,12 +3976,12 @@ void OutputDevice::ImplDrawStrikeoutLine( long nBaseX, long nBaseY, if ( mbLineColor || mbInitLineColor ) { mpGraphics->SetLineColor(); - mbInitLineColor = TRUE; + mbInitLineColor = sal_True; } mpGraphics->SetFillColor( ImplColorToSal( aColor ) ); - mbInitFillColor = TRUE; + mbInitFillColor = sal_True; - long nLeft = nX; + const long& nLeft = nDistX; switch ( eStrikeout ) { @@ -3965,7 +4002,7 @@ void OutputDevice::ImplDrawStrikeoutLine( long nBaseX, long nBaseY, // ----------------------------------------------------------------------- void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY, - long nX, long nY, long nWidth, + long nDistX, long nDistY, long nWidth, FontStrikeout eStrikeout, Color aColor ) { @@ -3999,12 +4036,12 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY, // calculate acceptable strikeout length // allow the strikeout to be one pixel larger than the text it strikes out - long nMaxWidth = nStrikeoutWidth / 2; + long nMaxWidth = nStrikeoutWidth * 3 / 4; if ( nMaxWidth < 2 ) nMaxWidth = 2; nMaxWidth += nWidth + 1; - int nStrikeStrLen = (nMaxWidth + nStrikeoutWidth - 1) / nStrikeoutWidth; + int nStrikeStrLen = (nMaxWidth - 1) / nStrikeoutWidth; // if the text width is smaller than the strikeout text, then do not // strike out at all. This case requires user interaction, e.g. adding // a space to the text @@ -4019,10 +4056,12 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY, const String aStrikeoutText( aChars, xub_StrLen(nStrikeStrLen) ); if( mpFontEntry->mnOrientation ) - ImplRotatePos( nBaseX, nBaseY, nX, nY, mpFontEntry->mnOrientation ); + ImplRotatePos( 0, 0, nDistX, nDistY, mpFontEntry->mnOrientation ); + nBaseX += nDistX; + nBaseY += nDistY; // strikeout text has to be left aligned - ULONG nOrigTLM = mnTextLayoutMode; + sal_uLong nOrigTLM = mnTextLayoutMode; mnTextLayoutMode = TEXT_LAYOUT_BIDI_STRONG | TEXT_LAYOUT_COMPLEX_DISABLED; pLayout = ImplLayout( aStrikeoutText, 0, STRING_LEN ); mnTextLayoutMode = nOrigTLM; @@ -4035,7 +4074,7 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY, SetTextColor( aColor ); ImplInitTextColor(); - pLayout->DrawBase() = Point( nX+mnTextOffX, nY+mnTextOffY ); + pLayout->DrawBase() = Point( nBaseX+mnTextOffX, nBaseY+mnTextOffY ); pLayout->DrawText( *mpGraphics ); pLayout->Release(); @@ -4045,12 +4084,12 @@ void OutputDevice::ImplDrawStrikeoutChar( long nBaseX, long nBaseY, // ----------------------------------------------------------------------- -void OutputDevice::ImplDrawTextLine( long nBaseX, - long nX, long nY, long nWidth, +void OutputDevice::ImplDrawTextLine( long nX, long nY, + long nDistX, long nWidth, FontStrikeout eStrikeout, FontUnderline eUnderline, FontUnderline eOverline, - BOOL bUnderlineAbove ) + sal_Bool bUnderlineAbove ) { if ( !nWidth ) return; @@ -4058,14 +4097,18 @@ void OutputDevice::ImplDrawTextLine( long nBaseX, Color aStrikeoutColor = GetTextColor(); Color aUnderlineColor = GetTextLineColor(); Color aOverlineColor = GetOverlineColor(); - BOOL bStrikeoutDone = FALSE; - BOOL bUnderlineDone = FALSE; - BOOL bOverlineDone = FALSE; + sal_Bool bStrikeoutDone = sal_False; + sal_Bool bUnderlineDone = sal_False; + sal_Bool bOverlineDone = sal_False; - // TODO: fix rotated text if ( IsRTLEnabled() ) + { // --- RTL --- mirror at basex - nX = nBaseX - nWidth - (nX - nBaseX - 1); + long nXAdd = nWidth - nDistX; + if( mpFontEntry->mnOrientation ) + nXAdd = FRound( nXAdd * cos( mpFontEntry->mnOrientation * F_PI1800 ) ); + nX += nXAdd - 1; + } if ( !IsTextLineColor() ) aUnderlineColor = GetTextColor(); @@ -4078,70 +4121,85 @@ void OutputDevice::ImplDrawTextLine( long nBaseX, (eUnderline == UNDERLINE_DOUBLEWAVE) || (eUnderline == UNDERLINE_BOLDWAVE) ) { - ImplDrawWaveTextLine( nBaseX, nY, nX, nY, nWidth, eUnderline, aUnderlineColor, bUnderlineAbove ); - bUnderlineDone = TRUE; + ImplDrawWaveTextLine( nX, nY, nDistX, 0, nWidth, eUnderline, aUnderlineColor, bUnderlineAbove ); + bUnderlineDone = sal_True; } if ( (eOverline == UNDERLINE_SMALLWAVE) || (eOverline == UNDERLINE_WAVE) || (eOverline == UNDERLINE_DOUBLEWAVE) || (eOverline == UNDERLINE_BOLDWAVE) ) { - ImplDrawWaveTextLine( nBaseX, nY, nX, nY, nWidth, eOverline, aOverlineColor, TRUE ); - bOverlineDone = TRUE; + ImplDrawWaveTextLine( nX, nY, nDistX, 0, nWidth, eOverline, aOverlineColor, sal_True ); + bOverlineDone = sal_True; } if ( (eStrikeout == STRIKEOUT_SLASH) || (eStrikeout == STRIKEOUT_X) ) { - ImplDrawStrikeoutChar( nBaseX, nY, nX, nY, nWidth, eStrikeout, aStrikeoutColor ); - bStrikeoutDone = TRUE; + ImplDrawStrikeoutChar( nX, nY, nDistX, 0, nWidth, eStrikeout, aStrikeoutColor ); + bStrikeoutDone = sal_True; } if ( !bUnderlineDone ) - ImplDrawStraightTextLine( nBaseX, nY, nX, nY, nWidth, eUnderline, aUnderlineColor, bUnderlineAbove ); + ImplDrawStraightTextLine( nX, nY, nDistX, 0, nWidth, eUnderline, aUnderlineColor, bUnderlineAbove ); if ( !bOverlineDone ) - ImplDrawStraightTextLine( nBaseX, nY, nX, nY, nWidth, eOverline, aOverlineColor, TRUE ); + ImplDrawStraightTextLine( nX, nY, nDistX, 0, nWidth, eOverline, aOverlineColor, sal_True ); if ( !bStrikeoutDone ) - ImplDrawStrikeoutLine( nBaseX, nY, nX, nY, nWidth, eStrikeout, aStrikeoutColor ); + ImplDrawStrikeoutLine( nX, nY, nDistX, 0, nWidth, eStrikeout, aStrikeoutColor ); } // ----------------------------------------------------------------------- void OutputDevice::ImplDrawTextLines( SalLayout& rSalLayout, - FontStrikeout eStrikeout, FontUnderline eUnderline, FontUnderline eOverline, BOOL bWordLine, BOOL bUnderlineAbove ) + FontStrikeout eStrikeout, FontUnderline eUnderline, FontUnderline eOverline, sal_Bool bWordLine, sal_Bool bUnderlineAbove ) { if( bWordLine ) { - Point aPos, aStartPt; - sal_Int32 nWidth = 0, nAdvance=0; + // draw everything relative to the layout base point + const Point aStartPt = rSalLayout.DrawBase(); + // calculate distance of each word from the base point + Point aPos; + sal_Int32 nDist = 0, nWidth = 0, nAdvance=0; for( int nStart = 0;;) { + // iterate through the layouted glyphs sal_GlyphId nGlyphIndex; if( !rSalLayout.GetNextGlyphs( 1, &nGlyphIndex, aPos, nStart, &nAdvance ) ) break; + // calculate the boundaries of each word if( !rSalLayout.IsSpacingGlyph( nGlyphIndex ) ) { if( !nWidth ) { - aStartPt = aPos;//rSalLayout.DrawBase() - (aPos - rSalLayout.DrawOffset()); + // get the distance to the base point (as projected to baseline) + nDist = aPos.X() - aStartPt.X(); + if( mpFontEntry->mnOrientation ) + { + const long nDY = aPos.Y() - aStartPt.Y(); + const double fRad = mpFontEntry->mnOrientation * F_PI1800; + nDist = FRound( nDist*cos(fRad) - nDY*sin(fRad) ); + } } + // update the length of the textline nWidth += nAdvance; } else if( nWidth > 0 ) { - ImplDrawTextLine( rSalLayout.DrawBase().X(), aStartPt.X(), aStartPt.Y(), nWidth, + // draw the textline for each word + ImplDrawTextLine( aStartPt.X(), aStartPt.Y(), nDist, nWidth, eStrikeout, eUnderline, eOverline, bUnderlineAbove ); nWidth = 0; } } + // draw textline for the last word if( nWidth > 0 ) { - ImplDrawTextLine( rSalLayout.DrawBase().X(), aStartPt.X(), aStartPt.Y(), nWidth, + ImplDrawTextLine( aStartPt.X(), aStartPt.Y(), nDist, nWidth, eStrikeout, eUnderline, eOverline, bUnderlineAbove ); } } @@ -4149,7 +4207,7 @@ void OutputDevice::ImplDrawTextLines( SalLayout& rSalLayout, { Point aStartPt = rSalLayout.GetDrawPosition(); int nWidth = rSalLayout.GetTextWidth() / rSalLayout.GetUnitsPerPixel(); - ImplDrawTextLine( rSalLayout.DrawBase().X(), aStartPt.X(), aStartPt.Y(), nWidth, + ImplDrawTextLine( aStartPt.X(), aStartPt.Y(), 0, nWidth, eStrikeout, eUnderline, eOverline, bUnderlineAbove ); } } @@ -4168,18 +4226,18 @@ void OutputDevice::ImplDrawMnemonicLine( long nX, long nY, long nWidth ) nX = nBaseX - nWidth - (nX - nBaseX - 1); } - ImplDrawTextLine( nBaseX, nX, nY, nWidth, STRIKEOUT_NONE, UNDERLINE_SINGLE, UNDERLINE_NONE, FALSE ); + ImplDrawTextLine( nX, nY, 0, nWidth, STRIKEOUT_NONE, UNDERLINE_SINGLE, UNDERLINE_NONE, sal_False ); } // ----------------------------------------------------------------------- -void OutputDevice::ImplGetEmphasisMark( PolyPolygon& rPolyPoly, BOOL& rPolyLine, +void OutputDevice::ImplGetEmphasisMark( PolyPolygon& rPolyPoly, sal_Bool& rPolyLine, Rectangle& rRect1, Rectangle& rRect2, long& rYOff, long& rWidth, FontEmphasisMark eEmphasis, long nHeight, short /*nOrient*/ ) { - static const BYTE aAccentPolyFlags[24] = + static const sal_uInt8 aAccentPolyFlags[24] = { 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 2, 2, 0, 0, 2, 0, 2, 2 }; @@ -4214,7 +4272,7 @@ void OutputDevice::ImplGetEmphasisMark( PolyPolygon& rPolyPoly, BOOL& rPolyLine, rWidth = 0; rYOff = 0; - rPolyLine = FALSE; + rPolyLine = sal_False; if ( !nHeight ) return; @@ -4255,7 +4313,7 @@ void OutputDevice::ImplGetEmphasisMark( PolyPolygon& rPolyPoly, BOOL& rPolyLine, // BorderWidth is 15% long nBorder = (nDotSize*150)/1000; if ( nBorder <= 1 ) - rPolyLine = TRUE; + rPolyLine = sal_True; else { Polygon aPoly2( Point( nRad, nRad ), @@ -4329,7 +4387,7 @@ void OutputDevice::ImplGetEmphasisMark( PolyPolygon& rPolyPoly, BOOL& rPolyLine, // ----------------------------------------------------------------------- void OutputDevice::ImplDrawEmphasisMark( long nBaseX, long nX, long nY, - const PolyPolygon& rPolyPoly, BOOL bPolyLine, + const PolyPolygon& rPolyPoly, sal_Bool bPolyLine, const Rectangle& rRect1, const Rectangle& rRect2 ) { // TODO: pass nWidth as width of this mark @@ -4380,10 +4438,10 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout ) { Color aOldLineColor = GetLineColor(); Color aOldFillColor = GetFillColor(); - BOOL bOldMap = mbMap; + sal_Bool bOldMap = mbMap; GDIMetaFile* pOldMetaFile = mpMetaFile; mpMetaFile = NULL; - EnableMapMode( FALSE ); + EnableMapMode( sal_False ); FontEmphasisMark nEmphasisMark = ImplGetEmphasisMarkStyle( maFont ); PolyPolygon aPolyPoly; @@ -4392,7 +4450,7 @@ void OutputDevice::ImplDrawEmphasisMarks( SalLayout& rSalLayout ) long nEmphasisYOff; long nEmphasisWidth; long nEmphasisHeight; - BOOL bPolyLine; + sal_Bool bPolyLine; if ( nEmphasisMark & EMPHASISMARK_POS_BELOW ) nEmphasisHeight = mnEmphasisDescent; @@ -4516,12 +4574,12 @@ bool OutputDevice::ImplDrawRotateText( SalLayout& rSalLayout ) GDIMetaFile* pOldMetaFile = mpMetaFile; long nOldOffX = mnOutOffX; long nOldOffY = mnOutOffY; - BOOL bOldMap = mbMap; + sal_Bool bOldMap = mbMap; mnOutOffX = 0L; mnOutOffY = 0L; mpMetaFile = NULL; - EnableMapMode( FALSE ); + EnableMapMode( sal_False ); DrawMask( aPoint, aBmp, GetTextColor() ); @@ -4535,7 +4593,7 @@ bool OutputDevice::ImplDrawRotateText( SalLayout& rSalLayout ) // ----------------------------------------------------------------------- -void OutputDevice::ImplDrawTextDirect( SalLayout& rSalLayout, BOOL bTextLines ) +void OutputDevice::ImplDrawTextDirect( SalLayout& rSalLayout, sal_Bool bTextLines ) { if( mpFontEntry->mnOwnOrientation ) if( ImplDrawRotateText( rSalLayout ) ) @@ -4729,7 +4787,7 @@ void OutputDevice::ImplDrawText( SalLayout& rSalLayout ) long OutputDevice::ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo, long nWidth, const XubString& rStr, - USHORT nStyle, const ::vcl::ITextLayout& _rLayout ) + sal_uInt16 nStyle, const ::vcl::ITextLayout& _rLayout ) { DBG_ASSERTWARNING( nWidth >= 0, "ImplGetTextLines: nWidth <= 0!" ); @@ -4798,10 +4856,10 @@ long OutputDevice::ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo, // sal_uInt16 nWordStart = nBreakPos; // sal_uInt16 nBreakPos_OLD = nBreakPos; sal_uInt16 nWordStart = nPos; - sal_uInt16 nWordEnd = (USHORT) aBoundary.endPos; + sal_uInt16 nWordEnd = (sal_uInt16) aBoundary.endPos; DBG_ASSERT( nWordEnd > nWordStart, "ImpBreakLine: Start >= End?" ); - USHORT nWordLen = nWordEnd - nWordStart; + sal_uInt16 nWordLen = nWordEnd - nWordStart; if ( ( nWordEnd >= nSoftBreak ) && ( nWordLen > 3 ) ) { // #104415# May happen, because getLineBreak may differ from getWordBoudary with DICTIONARY_WORD @@ -4882,7 +4940,7 @@ long OutputDevice::ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo, else { // fallback to something really simple - USHORT nSpacePos = STRING_LEN; + sal_uInt16 nSpacePos = STRING_LEN; long nW = 0; do { @@ -4924,7 +4982,7 @@ long OutputDevice::ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo, } } #ifdef DBG_UTIL - for ( USHORT nL = 0; nL < rLineInfo.Count(); nL++ ) + for ( sal_uInt16 nL = 0; nL < rLineInfo.Count(); nL++ ) { ImplTextLineInfo* pLine = rLineInfo.GetLine( nL ); String aLine( rStr, pLine->GetIndex(), pLine->GetLen() ); @@ -4938,12 +4996,12 @@ long OutputDevice::ImplGetTextLines( ImplMultiTextLineInfo& rLineInfo, // ======================================================================= -void OutputDevice::SetAntialiasing( USHORT nMode ) +void OutputDevice::SetAntialiasing( sal_uInt16 nMode ) { if ( mnAntialiasing != nMode ) { mnAntialiasing = nMode; - mbInitFont = TRUE; + mbInitFont = sal_True; if(mpGraphics) { @@ -4977,7 +5035,7 @@ void OutputDevice::SetFont( const Font& rNewFont ) aTextColor = Color( COL_WHITE ); else if ( mnDrawMode & DRAWMODE_GRAYTEXT ) { - const UINT8 cLum = aTextColor.GetLuminance(); + const sal_uInt8 cLum = aTextColor.GetLuminance(); aTextColor = Color( cLum, cLum, cLum ); } else if ( mnDrawMode & DRAWMODE_SETTINGSTEXT ) @@ -4992,7 +5050,7 @@ void OutputDevice::SetFont( const Font& rNewFont ) aFont.SetColor( aTextColor ); - BOOL bTransFill = aFont.IsTransparent(); + sal_Bool bTransFill = aFont.IsTransparent(); if ( !bTransFill ) { Color aTextFillColor( aFont.GetFillColor() ); @@ -5003,7 +5061,7 @@ void OutputDevice::SetFont( const Font& rNewFont ) aTextFillColor = Color( COL_WHITE ); else if ( mnDrawMode & DRAWMODE_GRAYFILL ) { - const UINT8 cLum = aTextFillColor.GetLuminance(); + const sal_uInt8 cLum = aTextFillColor.GetLuminance(); aTextFillColor = Color( cLum, cLum, cLum ); } else if( mnDrawMode & DRAWMODE_SETTINGSFILL ) @@ -5011,7 +5069,7 @@ void OutputDevice::SetFont( const Font& rNewFont ) else if ( mnDrawMode & DRAWMODE_NOFILL ) { aTextFillColor = Color( COL_TRANSPARENT ); - bTransFill = TRUE; + bTransFill = sal_True; } if ( !bTransFill && (mnDrawMode & DRAWMODE_GHOSTEDFILL) ) @@ -5043,12 +5101,12 @@ void OutputDevice::SetFont( const Font& rNewFont ) && (aFont.GetColor() != maFont.GetColor() || aFont.GetColor() != maTextColor ) ) { maTextColor = aFont.GetColor(); - mbInitTextColor = TRUE; + mbInitTextColor = sal_True; if( mpMetaFile ) mpMetaFile->AddAction( new MetaTextColorAction( aFont.GetColor() ) ); } maFont = aFont; - mbNewFont = TRUE; + mbNewFont = sal_True; if( mpAlphaVDev ) { @@ -5069,7 +5127,7 @@ void OutputDevice::SetFont( const Font& rNewFont ) // ----------------------------------------------------------------------- -void OutputDevice::SetLayoutMode( ULONG nTextLayoutMode ) +void OutputDevice::SetLayoutMode( sal_uLong nTextLayoutMode ) { DBG_TRACE( "OutputDevice::SetTextLayoutMode()" ); @@ -5116,7 +5174,7 @@ void OutputDevice::SetTextColor( const Color& rColor ) aColor = Color( COL_WHITE ); else if ( mnDrawMode & DRAWMODE_GRAYTEXT ) { - const UINT8 cLum = aColor.GetLuminance(); + const sal_uInt8 cLum = aColor.GetLuminance(); aColor = Color( cLum, cLum, cLum ); } else if ( mnDrawMode & DRAWMODE_SETTINGSTEXT ) @@ -5136,7 +5194,7 @@ void OutputDevice::SetTextColor( const Color& rColor ) if ( maTextColor != aColor ) { maTextColor = aColor; - mbInitTextColor = TRUE; + mbInitTextColor = sal_True; } if( mpAlphaVDev ) @@ -5151,12 +5209,12 @@ void OutputDevice::SetTextFillColor() DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); if ( mpMetaFile ) - mpMetaFile->AddAction( new MetaTextFillColorAction( Color(), FALSE ) ); + mpMetaFile->AddAction( new MetaTextFillColorAction( Color(), sal_False ) ); if ( maFont.GetColor() != Color( COL_TRANSPARENT ) ) maFont.SetFillColor( Color( COL_TRANSPARENT ) ); if ( !maFont.IsTransparent() ) - maFont.SetTransparent( TRUE ); + maFont.SetTransparent( sal_True ); if( mpAlphaVDev ) mpAlphaVDev->SetTextFillColor(); @@ -5170,7 +5228,7 @@ void OutputDevice::SetTextFillColor( const Color& rColor ) DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); Color aColor( rColor ); - BOOL bTransFill = ImplIsColorTransparent( aColor ) ? TRUE : FALSE; + sal_Bool bTransFill = ImplIsColorTransparent( aColor ) ? sal_True : sal_False; if ( !bTransFill ) { @@ -5184,7 +5242,7 @@ void OutputDevice::SetTextFillColor( const Color& rColor ) aColor = Color( COL_WHITE ); else if ( mnDrawMode & DRAWMODE_GRAYFILL ) { - const UINT8 cLum = aColor.GetLuminance(); + const sal_uInt8 cLum = aColor.GetLuminance(); aColor = Color( cLum, cLum, cLum ); } else if( mnDrawMode & DRAWMODE_SETTINGSFILL ) @@ -5192,7 +5250,7 @@ void OutputDevice::SetTextFillColor( const Color& rColor ) else if ( mnDrawMode & DRAWMODE_NOFILL ) { aColor = Color( COL_TRANSPARENT ); - bTransFill = TRUE; + bTransFill = sal_True; } if ( !bTransFill && (mnDrawMode & DRAWMODE_GHOSTEDFILL) ) @@ -5205,7 +5263,7 @@ void OutputDevice::SetTextFillColor( const Color& rColor ) } if ( mpMetaFile ) - mpMetaFile->AddAction( new MetaTextFillColorAction( aColor, TRUE ) ); + mpMetaFile->AddAction( new MetaTextFillColorAction( aColor, sal_True ) ); if ( maFont.GetFillColor() != aColor ) maFont.SetFillColor( aColor ); @@ -5234,7 +5292,7 @@ void OutputDevice::SetTextLineColor() DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); if ( mpMetaFile ) - mpMetaFile->AddAction( new MetaTextLineColorAction( Color(), FALSE ) ); + mpMetaFile->AddAction( new MetaTextLineColorAction( Color(), sal_False ) ); maTextLineColor = Color( COL_TRANSPARENT ); @@ -5261,7 +5319,7 @@ void OutputDevice::SetTextLineColor( const Color& rColor ) aColor = Color( COL_WHITE ); else if ( mnDrawMode & DRAWMODE_GRAYTEXT ) { - const UINT8 cLum = aColor.GetLuminance(); + const sal_uInt8 cLum = aColor.GetLuminance(); aColor = Color( cLum, cLum, cLum ); } else if ( mnDrawMode & DRAWMODE_SETTINGSTEXT ) @@ -5277,7 +5335,7 @@ void OutputDevice::SetTextLineColor( const Color& rColor ) } if ( mpMetaFile ) - mpMetaFile->AddAction( new MetaTextLineColorAction( aColor, TRUE ) ); + mpMetaFile->AddAction( new MetaTextLineColorAction( aColor, sal_True ) ); maTextLineColor = aColor; @@ -5293,7 +5351,7 @@ void OutputDevice::SetOverlineColor() DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); if ( mpMetaFile ) - mpMetaFile->AddAction( new MetaOverlineColorAction( Color(), FALSE ) ); + mpMetaFile->AddAction( new MetaOverlineColorAction( Color(), sal_False ) ); maOverlineColor = Color( COL_TRANSPARENT ); @@ -5320,7 +5378,7 @@ void OutputDevice::SetOverlineColor( const Color& rColor ) aColor = Color( COL_WHITE ); else if ( mnDrawMode & DRAWMODE_GRAYTEXT ) { - const UINT8 cLum = aColor.GetLuminance(); + const sal_uInt8 cLum = aColor.GetLuminance(); aColor = Color( cLum, cLum, cLum ); } else if ( mnDrawMode & DRAWMODE_SETTINGSTEXT ) @@ -5336,7 +5394,7 @@ void OutputDevice::SetOverlineColor( const Color& rColor ) } if ( mpMetaFile ) - mpMetaFile->AddAction( new MetaOverlineColorAction( aColor, TRUE ) ); + mpMetaFile->AddAction( new MetaOverlineColorAction( aColor, sal_True ) ); maOverlineColor = aColor; @@ -5358,7 +5416,7 @@ void OutputDevice::SetTextAlign( TextAlign eAlign ) if ( maFont.GetAlign() != eAlign ) { maFont.SetAlign( eAlign ); - mbNewFont = TRUE; + mbNewFont = sal_True; } if( mpAlphaVDev ) @@ -5371,7 +5429,7 @@ void OutputDevice::DrawTextLine( const Point& rPos, long nWidth, FontStrikeout eStrikeout, FontUnderline eUnderline, FontUnderline eOverline, - BOOL bUnderlineAbove ) + sal_Bool bUnderlineAbove ) { DBG_TRACE( "OutputDevice::DrawTextLine()" ); DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); @@ -5406,7 +5464,7 @@ void OutputDevice::DrawTextLine( const Point& rPos, long nWidth, Point aPos = ImplLogicToDevicePixel( rPos ); nWidth = ImplLogicWidthToDevicePixel( nWidth ); aPos += Point( mnTextOffX, mnTextOffY ); - ImplDrawTextLine( aPos.X(), aPos.X(), aPos.Y(), nWidth, eStrikeout, eUnderline, eOverline, bUnderlineAbove ); + ImplDrawTextLine( aPos.X(), aPos.X(), 0, nWidth, eStrikeout, eUnderline, eOverline, bUnderlineAbove ); if( mpAlphaVDev ) mpAlphaVDev->DrawTextLine( rPos, nWidth, eStrikeout, eUnderline, eOverline, bUnderlineAbove ); @@ -5414,7 +5472,7 @@ void OutputDevice::DrawTextLine( const Point& rPos, long nWidth, // ------------------------------------------------------------------------ -BOOL OutputDevice::IsTextUnderlineAbove( const Font& rFont ) +sal_Bool OutputDevice::IsTextUnderlineAbove( const Font& rFont ) { return ImplIsUnderlineAbove( rFont ); } @@ -5422,7 +5480,7 @@ BOOL OutputDevice::IsTextUnderlineAbove( const Font& rFont ) // ------------------------------------------------------------------------ void OutputDevice::DrawWaveLine( const Point& rStartPos, const Point& rEndPos, - USHORT nStyle ) + sal_uInt16 nStyle ) { DBG_TRACE( "OutputDevice::DrawWaveLine()" ); DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); @@ -5483,7 +5541,7 @@ void OutputDevice::DrawWaveLine( const Point& rStartPos, const Point& rEndPos, if( nWaveHeight > pFontEntry->maMetric.mnWUnderlineSize ) nWaveHeight = pFontEntry->maMetric.mnWUnderlineSize; - ImplDrawWaveLine( nStartX, nStartY, nStartX, nStartY, + ImplDrawWaveLine( nStartX, nStartY, 0, 0, nEndX-nStartX, nWaveHeight, 1, nOrientation, GetLineColor() ); if( mpAlphaVDev ) @@ -5650,7 +5708,7 @@ long OutputDevice::GetTextArray( const String& rStr, sal_Int32* pDXAry, if( nIndex >= rStr.Len() ) return 0; - if( (ULONG)nIndex+nLen >= rStr.Len() ) + if( (sal_uLong)nIndex+nLen >= rStr.Len() ) nLen = rStr.Len() - nIndex; // do layout @@ -5692,14 +5750,14 @@ long OutputDevice::GetTextArray( const String& rStr, sal_Int32* pDXAry, bool OutputDevice::GetCaretPositions( const XubString& rStr, sal_Int32* pCaretXArray, xub_StrLen nIndex, xub_StrLen nLen, sal_Int32* pDXAry, long nLayoutWidth, - BOOL bCellBreaking ) const + sal_Bool bCellBreaking ) const { DBG_TRACE( "OutputDevice::GetCaretPositions()" ); DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); if( nIndex >= rStr.Len() ) return false; - if( (ULONG)nIndex+nLen >= rStr.Len() ) + if( (sal_uLong)nIndex+nLen >= rStr.Len() ) nLen = rStr.Len() - nIndex; // layout complex text @@ -5758,7 +5816,7 @@ bool OutputDevice::GetCaretPositions( const XubString& rStr, sal_Int32* pCaretXA // ----------------------------------------------------------------------- -void OutputDevice::DrawStretchText( const Point& rStartPt, ULONG nWidth, +void OutputDevice::DrawStretchText( const Point& rStartPt, sal_uLong nWidth, const String& rStr, xub_StrLen nIndex, xub_StrLen nLen ) { @@ -5790,7 +5848,7 @@ ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( String& rStr, { // get string length for calculating extents xub_StrLen nEndIndex = rStr.Len(); - if( (ULONG)nMinIndex + nLen < nEndIndex ) + if( (sal_uLong)nMinIndex + nLen < nEndIndex ) nEndIndex = nMinIndex + nLen; // don't bother if there is nothing to do @@ -5859,7 +5917,7 @@ ImplLayoutArgs OutputDevice::ImplPrepareLayoutArgs( String& rStr, sal_UCS4 cChar = GetLocalizedChar( *pStr, meTextLanguage ); if( cChar != *pStr ) // TODO: are the localized digit surrogates? - rStr.SetChar( static_cast<USHORT>(pStr - pBase), + rStr.SetChar( static_cast<sal_uInt16>(pStr - pBase), static_cast<sal_Unicode>(cChar) ); } } @@ -6036,8 +6094,9 @@ SalLayout* OutputDevice::ImplGlyphFallbackLayout( SalLayout* pSalLayout, ImplLay ImplFontSelectData aFontSelData = mpFontEntry->maFontSelData; - ImplFontMetricData aOrigMetric(aFontSelData); - mpGraphics->GetFontMetric(&aOrigMetric); + ImplFontMetricData aOrigMetric( aFontSelData ); + // TODO: use cached metric in fontentry + mpGraphics->GetFontMetric( &aOrigMetric ); // when device specific font substitution may have been performed for // the originally selected font then make sure that a fallback to that @@ -6072,21 +6131,27 @@ SalLayout* OutputDevice::ImplGlyphFallbackLayout( SalLayout* pSalLayout, ImplLay } } - ImplFontMetricData aSubstituteMetric(aFontSelData); - pFallbackFont->mnSetFontFlags = mpGraphics->SetFont( &aFontSelData, nFallbackLevel ); - mpGraphics->GetFontMetric(&aSubstituteMetric, nFallbackLevel); - long nOriginalHeight = aOrigMetric.mnAscent + aOrigMetric.mnDescent; - long nSubstituteHeight = aSubstituteMetric.mnAscent + aSubstituteMetric.mnDescent; - //Too tall, shrink it a bit. Need a better calculation to include extra - //factors and any extra wriggle room we might have available ? - if (nSubstituteHeight > nOriginalHeight) - { - float fScale = nOriginalHeight/(float)nSubstituteHeight; - long nOrigHeight = aFontSelData.mnHeight; - aFontSelData.mnHeight *= fScale; + // TODO: try to get the metric data from the GFB's mpFontEntry + ImplFontMetricData aSubstituteMetric( aFontSelData ); + pFallbackFont->mnSetFontFlags = mpGraphics->SetFont( &aFontSelData, nFallbackLevel ); + mpGraphics->GetFontMetric( &aSubstituteMetric, nFallbackLevel ); + + const long nOriginalHeight = aOrigMetric.mnAscent + aOrigMetric.mnDescent; + const long nSubstituteHeight = aSubstituteMetric.mnAscent + aSubstituteMetric.mnDescent; + // Too tall, shrink it a bit. Need a better calculation to include extra + // factors and any extra wriggle room we might have available? + // TODO: should we scale by max-ascent/max-descent instead of design height? + if( nSubstituteHeight > nOriginalHeight ) + { + const float fScale = nOriginalHeight / (float)nSubstituteHeight; + const float fOrigHeight = aFontSelData.mfExactHeight; + const int nOrigHeight = aFontSelData.mnHeight; + aFontSelData.mfExactHeight *= fScale; + aFontSelData.mnHeight = static_cast<int>(aFontSelData.mfExactHeight); pFallbackFont->mnSetFontFlags = mpGraphics->SetFont( &aFontSelData, nFallbackLevel ); aFontSelData.mnHeight = nOrigHeight; + aFontSelData.mfExactHeight = fOrigHeight; } // create and add glyph fallback layout to multilayout @@ -6129,7 +6194,7 @@ SalLayout* OutputDevice::ImplGlyphFallbackLayout( SalLayout* pSalLayout, ImplLay // ----------------------------------------------------------------------- -BOOL OutputDevice::GetTextIsRTL( +sal_Bool OutputDevice::GetTextIsRTL( const String& rString, xub_StrLen nIndex, xub_StrLen nLen ) const { @@ -6138,14 +6203,14 @@ BOOL OutputDevice::GetTextIsRTL( bool bRTL = false; int nCharPos = -1; aArgs.GetNextPos( &nCharPos, &bRTL ); - return (nCharPos != nIndex) ? TRUE : FALSE; + return (nCharPos != nIndex) ? sal_True : sal_False; } // ----------------------------------------------------------------------- xub_StrLen OutputDevice::GetTextBreak( const String& rStr, long nTextWidth, xub_StrLen nIndex, xub_StrLen nLen, - long nCharExtra, BOOL /*TODO: bCellBreaking*/ ) const + long nCharExtra, sal_Bool /*TODO: bCellBreaking*/ ) const { DBG_TRACE( "OutputDevice::GetTextBreak()" ); DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); @@ -6239,17 +6304,17 @@ xub_StrLen OutputDevice::GetTextBreak( const String& rStr, long nTextWidth, // ----------------------------------------------------------------------- void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const Rectangle& rRect, - const String& rOrigStr, USHORT nStyle, + const String& rOrigStr, sal_uInt16 nStyle, MetricVector* pVector, String* pDisplayText, ::vcl::ITextLayout& _rLayout ) { Color aOldTextColor; Color aOldTextFillColor; - BOOL bRestoreFillColor = false; + sal_Bool bRestoreFillColor = false; if ( (nStyle & TEXT_DRAW_DISABLE) && ! pVector ) { - BOOL bHighContrastBlack = FALSE; - BOOL bHighContrastWhite = FALSE; + sal_Bool bHighContrastBlack = sal_False; + sal_Bool bHighContrastWhite = sal_False; const StyleSettings& rStyleSettings( rTargetDevice.GetSettings().GetStyleSettings() ); if( rStyleSettings.GetHighContrastMode() ) { @@ -6269,7 +6334,7 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const Rectangle& r aOldTextColor = rTargetDevice.GetTextColor(); if ( rTargetDevice.IsTextFillColor() ) { - bRestoreFillColor = TRUE; + bRestoreFillColor = sal_True; aOldTextFillColor = rTargetDevice.GetTextFillColor(); } if( bHighContrastBlack ) @@ -6398,7 +6463,7 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const Rectangle& r long nMnemonicWidth; sal_Int32* pCaretXArray = (sal_Int32*) alloca( 2 * sizeof(sal_Int32) * nLineLen ); - /*BOOL bRet =*/ _rLayout.GetCaretPositions( aStr, pCaretXArray, + /*sal_Bool bRet =*/ _rLayout.GetCaretPositions( aStr, pCaretXArray, nIndex, nLineLen ); long lc_x1 = pCaretXArray[2*(nMnemonicPos - nIndex)]; long lc_x2 = pCaretXArray[2*(nMnemonicPos - nIndex)+1]; @@ -6469,7 +6534,7 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const Rectangle& r if ( nMnemonicPos != STRING_NOTFOUND ) { sal_Int32* pCaretXArray = (sal_Int32*) alloca( 2 * sizeof(sal_Int32) * aStr.Len() ); - /*BOOL bRet =*/ _rLayout.GetCaretPositions( aStr, pCaretXArray, 0, aStr.Len() ); + /*sal_Bool bRet =*/ _rLayout.GetCaretPositions( aStr, pCaretXArray, 0, aStr.Len() ); long lc_x1 = pCaretXArray[2*(nMnemonicPos)]; long lc_x2 = pCaretXArray[2*(nMnemonicPos)+1]; nMnemonicWidth = rTargetDevice.ImplLogicWidthToDevicePixel( ::abs((int)(lc_x1 - lc_x2)) ); @@ -6514,7 +6579,7 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const Rectangle& r void OutputDevice::AddTextRectActions( const Rectangle& rRect, const String& rOrigStr, - USHORT nStyle, + sal_uInt16 nStyle, GDIMetaFile& rMtf ) { DBG_TRACE( "OutputDevice::AddTextRectActions( const Rectangle& )" ); @@ -6531,11 +6596,11 @@ void OutputDevice::AddTextRectActions( const Rectangle& rRect, // temporarily swap in passed mtf for action generation, and // disable output generation. - const BOOL bOutputEnabled( IsOutputEnabled() ); + const sal_Bool bOutputEnabled( IsOutputEnabled() ); GDIMetaFile* pMtf = mpMetaFile; mpMetaFile = &rMtf; - EnableOutput( FALSE ); + EnableOutput( sal_False ); // #i47157# Factored out to ImplDrawTextRect(), to be shared // between us and DrawText() @@ -6549,7 +6614,7 @@ void OutputDevice::AddTextRectActions( const Rectangle& rRect, // ----------------------------------------------------------------------- -void OutputDevice::DrawText( const Rectangle& rRect, const String& rOrigStr, USHORT nStyle, +void OutputDevice::DrawText( const Rectangle& rRect, const String& rOrigStr, sal_uInt16 nStyle, MetricVector* pVector, String* pDisplayText, ::vcl::ITextLayout* _pTextLayout ) { @@ -6598,7 +6663,7 @@ void OutputDevice::DrawText( const Rectangle& rRect, const String& rOrigStr, USH // ----------------------------------------------------------------------- Rectangle OutputDevice::GetTextRect( const Rectangle& rRect, - const XubString& rStr, USHORT nStyle, + const XubString& rStr, sal_uInt16 nStyle, TextRectInfo* pInfo, const ::vcl::ITextLayout* _pTextLayout ) const { @@ -6628,7 +6693,7 @@ Rectangle OutputDevice::GetTextRect( const Rectangle& rRect, nFormatLines = aMultiLineInfo.Count(); if ( !nTextHeight ) nTextHeight = 1; - nLines = (USHORT)(aRect.GetHeight()/nTextHeight); + nLines = (sal_uInt16)(aRect.GetHeight()/nTextHeight); if ( pInfo ) pInfo->mnLineCount = nFormatLines; if ( !nLines ) @@ -6642,13 +6707,13 @@ Rectangle OutputDevice::GetTextRect( const Rectangle& rRect, else { if ( pInfo ) - pInfo->mbEllipsis = TRUE; + pInfo->mbEllipsis = sal_True; nMaxWidth = nWidth; } } if ( pInfo ) { - BOOL bMaxWidth = nMaxWidth == 0; + sal_Bool bMaxWidth = nMaxWidth == 0; pInfo->mnMaxWidth = 0; for ( i = 0; i < nLines; i++ ) { @@ -6683,7 +6748,7 @@ Rectangle OutputDevice::GetTextRect( const Rectangle& rRect, if ( (nMaxWidth > nWidth) && (nStyle & TEXT_DRAW_ELLIPSIS) ) { if ( pInfo ) - pInfo->mbEllipsis = TRUE; + pInfo->mbEllipsis = sal_True; nMaxWidth = nWidth; } } @@ -6714,22 +6779,22 @@ Rectangle OutputDevice::GetTextRect( const Rectangle& rRect, // ----------------------------------------------------------------------- -static BOOL ImplIsCharIn( xub_Unicode c, const sal_Char* pStr ) +static sal_Bool ImplIsCharIn( xub_Unicode c, const sal_Char* pStr ) { while ( *pStr ) { if ( *pStr == c ) - return TRUE; + return sal_True; pStr++; } - return FALSE; + return sal_False; } // ----------------------------------------------------------------------- String OutputDevice::GetEllipsisString( const String& rOrigStr, long nMaxWidth, - USHORT nStyle ) const + sal_uInt16 nStyle ) const { DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); DefaultTextLayout aTextLayout( *const_cast< OutputDevice* >( this ) ); @@ -6739,7 +6804,7 @@ String OutputDevice::GetEllipsisString( const String& rOrigStr, long nMaxWidth, // ----------------------------------------------------------------------- String OutputDevice::ImplGetEllipsisString( const OutputDevice& rTargetDevice, const XubString& rOrigStr, long nMaxWidth, - USHORT nStyle, const ::vcl::ITextLayout& _rLayout ) + sal_uInt16 nStyle, const ::vcl::ITextLayout& _rLayout ) { DBG_TRACE( "OutputDevice::ImplGetEllipsisString()" ); @@ -6749,7 +6814,20 @@ String OutputDevice::ImplGetEllipsisString( const OutputDevice& rTargetDevice, c if ( nIndex != STRING_LEN ) { - if ( nStyle & TEXT_DRAW_ENDELLIPSIS ) + if( (nStyle & TEXT_DRAW_CENTERELLIPSIS) == TEXT_DRAW_CENTERELLIPSIS ) + { + String aTmpStr( aStr ); + xub_StrLen nEraseChars = 4; + while( nEraseChars < aStr.Len() && _rLayout.GetTextWidth( aTmpStr, 0, aTmpStr.Len() ) > nMaxWidth ) + { + aTmpStr = aStr; + xub_StrLen i = (aTmpStr.Len() - nEraseChars)/2; + aTmpStr.Erase( i, nEraseChars++ ); + aTmpStr.InsertAscii( "...", i ); + } + aStr = aTmpStr; + } + else if ( nStyle & TEXT_DRAW_ENDELLIPSIS ) { aStr.Erase( nIndex ); if ( nIndex > 1 ) @@ -6795,7 +6873,7 @@ String OutputDevice::ImplGetEllipsisString( const OutputDevice& rTargetDevice, c aStr = OutputDevice::ImplGetEllipsisString( rTargetDevice, aStr, nMaxWidth, nStyle | TEXT_DRAW_ENDELLIPSIS, _rLayout ); else { - USHORT nFirstContent = 0; + sal_uInt16 nFirstContent = 0; while ( nFirstContent < nLastContent ) { nFirstContent++; @@ -6859,7 +6937,7 @@ String OutputDevice::ImplGetEllipsisString( const OutputDevice& rTargetDevice, c void OutputDevice::DrawCtrlText( const Point& rPos, const XubString& rStr, xub_StrLen nIndex, xub_StrLen nLen, - USHORT nStyle, MetricVector* pVector, String* pDisplayText ) + sal_uInt16 nStyle, MetricVector* pVector, String* pDisplayText ) { DBG_TRACE( "OutputDevice::DrawCtrlText()" ); DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); @@ -6878,7 +6956,7 @@ void OutputDevice::DrawCtrlText( const Point& rPos, const XubString& rStr, if( nIndex >= rStr.Len() ) return; - if( (ULONG)nIndex+nLen >= rStr.Len() ) + if( (sal_uLong)nIndex+nLen >= rStr.Len() ) nLen = rStr.Len() - nIndex; XubString aStr = rStr; @@ -6900,7 +6978,7 @@ void OutputDevice::DrawCtrlText( const Point& rPos, const XubString& rStr, --nLen; DBG_ASSERT( nMnemonicPos < (nIndex+nLen), "Mnemonic underline marker after last character" ); } - BOOL bInvalidPos = FALSE; + sal_Bool bInvalidPos = sal_False; if( nMnemonicPos >= nLen ) { @@ -6908,12 +6986,12 @@ void OutputDevice::DrawCtrlText( const Point& rPos, const XubString& rStr, // may occur in BiDi-Strings: the '~' is sometimes found behind the last char // due to some strange BiDi text editors // ->place the underline behind the string to indicate a failure - bInvalidPos = TRUE; + bInvalidPos = sal_True; nMnemonicPos = nLen-1; } sal_Int32* pCaretXArray = (sal_Int32*)alloca( 2 * sizeof(sal_Int32) * nLen ); - /*BOOL bRet =*/ GetCaretPositions( aStr, pCaretXArray, nIndex, nLen ); + /*sal_Bool bRet =*/ GetCaretPositions( aStr, pCaretXArray, nIndex, nLen ); long lc_x1 = pCaretXArray[ 2*(nMnemonicPos - nIndex) ]; long lc_x2 = pCaretXArray[ 2*(nMnemonicPos - nIndex)+1 ]; nMnemonicWidth = ::abs((int)(lc_x1 - lc_x2)); @@ -6933,9 +7011,9 @@ void OutputDevice::DrawCtrlText( const Point& rPos, const XubString& rStr, { Color aOldTextColor; Color aOldTextFillColor; - BOOL bRestoreFillColor; - BOOL bHighContrastBlack = FALSE; - BOOL bHighContrastWhite = FALSE; + sal_Bool bRestoreFillColor; + sal_Bool bHighContrastBlack = sal_False; + sal_Bool bHighContrastWhite = sal_False; const StyleSettings& rStyleSettings( GetSettings().GetStyleSettings() ); if( rStyleSettings.GetHighContrastMode() ) { @@ -6951,11 +7029,11 @@ void OutputDevice::DrawCtrlText( const Point& rPos, const XubString& rStr, aOldTextColor = GetTextColor(); if ( IsTextFillColor() ) { - bRestoreFillColor = TRUE; + bRestoreFillColor = sal_True; aOldTextFillColor = GetTextFillColor(); } else - bRestoreFillColor = FALSE; + bRestoreFillColor = sal_False; if( bHighContrastBlack ) SetTextColor( COL_GREEN ); @@ -6992,7 +7070,7 @@ void OutputDevice::DrawCtrlText( const Point& rPos, const XubString& rStr, long OutputDevice::GetCtrlTextWidth( const String& rStr, xub_StrLen nIndex, xub_StrLen nLen, - USHORT nStyle ) const + sal_uInt16 nStyle ) const { DBG_TRACE( "OutputDevice::GetCtrlTextSize()" ); DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); @@ -7006,7 +7084,7 @@ long OutputDevice::GetCtrlTextWidth( const String& rStr, if ( nMnemonicPos < nIndex ) nIndex--; else if ( (nLen < STRING_LEN) && - (nMnemonicPos >= nIndex) && (nMnemonicPos < (ULONG)(nIndex+nLen)) ) + (nMnemonicPos >= nIndex) && (nMnemonicPos < (sal_uLong)(nIndex+nLen)) ) nLen--; } return GetTextWidth( aStr, nIndex, nLen ); @@ -7095,7 +7173,7 @@ FontInfo OutputDevice::GetDevFont( int nDevFontIndex ) const // ----------------------------------------------------------------------- -BOOL OutputDevice::AddTempDevFont( const String& rFileURL, const String& rFontName ) +sal_Bool OutputDevice::AddTempDevFont( const String& rFileURL, const String& rFontName ) { DBG_TRACE( "OutputDevice::AddTempDevFont()" ); DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); @@ -7103,17 +7181,17 @@ BOOL OutputDevice::AddTempDevFont( const String& rFileURL, const String& rFontNa ImplInitFontList(); if( !mpGraphics && !ImplGetGraphics() ) - return FALSE; + return sal_False; bool bRC = mpGraphics->AddTempDevFont( mpFontList, rFileURL, rFontName ); if( !bRC ) - return FALSE; + return sal_False; if( mpAlphaVDev ) mpAlphaVDev->AddTempDevFont( rFileURL, rFontName ); mpFontCache->Invalidate(); - return TRUE; + return sal_True; } // ----------------------------------------------------------------------- @@ -7167,7 +7245,7 @@ Size OutputDevice::GetDevFontSize( const Font& rFont, int nSizeIndex ) const // ----------------------------------------------------------------------- -BOOL OutputDevice::IsFontAvailable( const String& rFontName ) const +sal_Bool OutputDevice::IsFontAvailable( const String& rFontName ) const { DBG_TRACE( "OutputDevice::IsFontAvailable()" ); DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); @@ -7387,7 +7465,7 @@ xub_StrLen OutputDevice::ValidateKashidas ( const String& rTxt, // TODO: best is to get rid of this method completely -ULONG OutputDevice::GetKerningPairCount() const +sal_uLong OutputDevice::GetKerningPairCount() const { DBG_TRACE( "OutputDevice::GetKerningPairCount()" ); DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); @@ -7413,7 +7491,7 @@ inline bool CmpKernData( const KerningPair& a, const KerningPair& b ) } // TODO: best is to get rid of this method completely -void OutputDevice::GetKerningPairs( ULONG nRequestedPairs, KerningPair* pKernPairs ) const +void OutputDevice::GetKerningPairs( sal_uLong nRequestedPairs, KerningPair* pKernPairs ) const { DBG_TRACE( "OutputDevice::GetKerningPairs()" ); DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); @@ -7435,7 +7513,7 @@ void OutputDevice::GetKerningPairs( ULONG nRequestedPairs, KerningPair* pKernPai // ----------------------------------------------------------------------- -BOOL OutputDevice::GetGlyphBoundRects( const Point& rOrigin, const String& rStr, +sal_Bool OutputDevice::GetGlyphBoundRects( const Point& rOrigin, const String& rStr, int nIndex, int nLen, int nBase, MetricVector& rVector ) { DBG_TRACE( "OutputDevice::GetGlyphBoundRect_CTL()" ); @@ -7460,14 +7538,14 @@ BOOL OutputDevice::GetGlyphBoundRects( const Point& rOrigin, const String& rStr, // ----------------------------------------------------------------------- -BOOL OutputDevice::GetTextBoundRect( Rectangle& rRect, +sal_Bool OutputDevice::GetTextBoundRect( Rectangle& rRect, const String& rStr, xub_StrLen nBase, xub_StrLen nIndex, xub_StrLen nLen, - ULONG nLayoutWidth, const sal_Int32* pDXAry ) const + sal_uLong nLayoutWidth, const sal_Int32* pDXAry ) const { DBG_TRACE( "OutputDevice::GetTextBoundRect()" ); DBG_CHKTHIS( OutputDevice, ImplDbgCheckOutputDevice ); - BOOL bRet = FALSE; + sal_Bool bRet = sal_False; rRect.SetEmpty(); SalLayout* pSalLayout = NULL; @@ -7531,8 +7609,8 @@ BOOL OutputDevice::GetTextBoundRect( Rectangle& rRect, // so we need a monochrome virtual device with matching font VirtualDevice aVDev( 1 ); Font aFont( GetFont() ); - aFont.SetShadow( FALSE ); - aFont.SetOutline( FALSE ); + aFont.SetShadow( sal_False ); + aFont.SetOutline( sal_False ); aFont.SetRelief( RELIEF_NONE ); aFont.SetOrientation( 0 ); aFont.SetSize( Size( mpFontEntry->maFontSelData.mnWidth, mpFontEntry->maFontSelData.mnHeight ) ); @@ -7565,7 +7643,7 @@ BOOL OutputDevice::GetTextBoundRect( Rectangle& rRect, Bitmap aBmp = aVDev.GetBitmap( Point(), aOutSize ); BitmapReadAccess* pAcc = aBmp.AcquireReadAccess(); if( !pAcc ) - return FALSE; + return sal_False; const BitmapColor aBlack( pAcc->GetBestMatchingColor( Color( COL_BLACK ) ) ); const long nW = pAcc->Width(); const long nH = pAcc->Height(); @@ -7630,17 +7708,17 @@ BOOL OutputDevice::GetTextBoundRect( Rectangle& rRect, aTopLeft.X() = ImplDevicePixelToLogicWidth( aTopLeft.X() ); aTopLeft.Y() = ImplDevicePixelToLogicHeight( aTopLeft.Y() ); rRect = Rectangle( aTopLeft, aSize ); - return TRUE; + return sal_True; } - return FALSE; + return sal_False; } // ----------------------------------------------------------------------- -BOOL OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, +sal_Bool OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, const String& rStr, xub_StrLen nBase, xub_StrLen nIndex, xub_StrLen nLen, - BOOL bOptimize, ULONG nTWidth, const sal_Int32* pDXArray ) const + sal_Bool bOptimize, sal_uLong nTWidth, const sal_Int32* pDXArray ) const { // the fonts need to be initialized if( mbNewFont ) @@ -7648,9 +7726,9 @@ BOOL OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, if( mbInitFont ) ImplInitFont(); if( !mpFontEntry ) - return FALSE; + return sal_False; - BOOL bRet = FALSE; + sal_Bool bRet = sal_False; rVector.clear(); if( nLen == STRING_LEN ) nLen = rStr.Len() - nIndex; @@ -7658,11 +7736,11 @@ BOOL OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, // we want to get the Rectangle in logical units, so to // avoid rounding errors we just size the font in logical units - BOOL bOldMap = mbMap; + sal_Bool bOldMap = mbMap; if( bOldMap ) { - const_cast<OutputDevice&>(*this).mbMap = FALSE; - const_cast<OutputDevice&>(*this).mbNewFont = TRUE; + const_cast<OutputDevice&>(*this).mbMap = sal_False; + const_cast<OutputDevice&>(*this).mbNewFont = sal_True; } SalLayout* pSalLayout = NULL; @@ -7722,7 +7800,7 @@ BOOL OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, { // restore original font size and map mode const_cast<OutputDevice&>(*this).mbMap = bOldMap; - const_cast<OutputDevice&>(*this).mbNewFont = TRUE; + const_cast<OutputDevice&>(*this).mbNewFont = sal_True; } if( bRet || (OUTDEV_PRINTER == meOutDevType) || !mpFontEntry ) @@ -7769,7 +7847,7 @@ BOOL OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, pSalLayout->Release(); if( !nWidth || !nHeight ) - return TRUE; + return sal_True; double fScaleX = static_cast< double >(nOrgWidth) / nWidth; double fScaleY = static_cast< double >(nOrgHeight) / nHeight; @@ -7826,10 +7904,10 @@ BOOL OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, else { // convert units to logical width - for (USHORT j = 0; j < aPolyPoly.Count(); ++j) + for (sal_uInt16 j = 0; j < aPolyPoly.Count(); ++j) { Polygon& rPoly = aPolyPoly[j]; - for (USHORT k = 0; k < rPoly.GetSize(); ++k) + for (sal_uInt16 k = 0; k < rPoly.GetSize(); ++k) { Point& rPt = rPoly[k]; rPt -= aOffset; @@ -7867,9 +7945,9 @@ BOOL OutputDevice::GetTextOutlines( ::basegfx::B2DPolyPolygonVector& rVector, // ----------------------------------------------------------------------- -BOOL OutputDevice::GetTextOutlines( PolyPolyVector& rResultVector, +sal_Bool OutputDevice::GetTextOutlines( PolyPolyVector& rResultVector, const String& rStr, xub_StrLen nBase, xub_StrLen nIndex, - xub_StrLen nLen, BOOL bOptimize, ULONG nTWidth, const sal_Int32* pDXArray ) const + xub_StrLen nLen, sal_Bool bOptimize, sal_uLong nTWidth, const sal_Int32* pDXArray ) const { rResultVector.clear(); @@ -7877,7 +7955,7 @@ BOOL OutputDevice::GetTextOutlines( PolyPolyVector& rResultVector, ::basegfx::B2DPolyPolygonVector aB2DPolyPolyVector; if( !GetTextOutlines( aB2DPolyPolyVector, rStr, nBase, nIndex, nLen, bOptimize, nTWidth, pDXArray ) ) - return FALSE; + return sal_False; // convert to a tool polypolygon vector rResultVector.reserve( aB2DPolyPolyVector.size() ); @@ -7885,14 +7963,14 @@ BOOL OutputDevice::GetTextOutlines( PolyPolyVector& rResultVector, for(; aIt != aB2DPolyPolyVector.end(); ++aIt ) rResultVector.push_back(PolyPolygon(*aIt)); // #i76339# - return TRUE; + return sal_True; } // ----------------------------------------------------------------------- -BOOL OutputDevice::GetTextOutline( PolyPolygon& rPolyPoly, +sal_Bool OutputDevice::GetTextOutline( PolyPolygon& rPolyPoly, const String& rStr, xub_StrLen nBase, xub_StrLen nIndex, xub_StrLen nLen, - BOOL bOptimize, ULONG nTWidth, const sal_Int32* pDXArray ) const + sal_Bool bOptimize, sal_uLong nTWidth, const sal_Int32* pDXArray ) const { rPolyPoly.Clear(); @@ -7900,7 +7978,7 @@ BOOL OutputDevice::GetTextOutline( PolyPolygon& rPolyPoly, ::basegfx::B2DPolyPolygonVector aB2DPolyPolyVector; if( !GetTextOutlines( aB2DPolyPolyVector, rStr, nBase, nIndex, nLen, bOptimize, nTWidth, pDXArray ) ) - return FALSE; + return sal_False; // convert and merge into a tool polypolygon ::basegfx::B2DPolyPolygonVector::const_iterator aIt = aB2DPolyPolyVector.begin(); @@ -7908,7 +7986,7 @@ BOOL OutputDevice::GetTextOutline( PolyPolygon& rPolyPoly, for( unsigned int i = 0; i < aIt->count(); ++i ) rPolyPoly.Insert(Polygon((*aIt).getB2DPolygon( i ))); // #i76339# - return TRUE; + return sal_True; } bool OutputDevice::GetFontCapabilities( FontCapabilities& rFontCapabilities ) const @@ -7929,22 +8007,22 @@ bool OutputDevice::GetFontCapabilities( FontCapabilities& rFontCapabilities ) co // ----------------------------------------------------------------------- -BOOL OutputDevice::GetFontCharMap( FontCharMap& rFontCharMap ) const +sal_Bool OutputDevice::GetFontCharMap( FontCharMap& rFontCharMap ) const { rFontCharMap.Reset(); // we need a graphics if( !mpGraphics && !ImplGetGraphics() ) - return FALSE; + return sal_False; if( mbNewFont ) ImplNewFont(); if( mbInitFont ) ImplInitFont(); if( !mpFontEntry ) - return FALSE; + return sal_False; - // a little font charmap cache helps considerably +#ifdef ENABLE_IFC_CACHE // a little font charmap cache helps considerably static const int NMAXITEMS = 16; static int nUsedItems = 0, nCurItem = 0; @@ -7962,10 +8040,12 @@ BOOL OutputDevice::GetFontCharMap( FontCharMap& rFontCharMap ) const rFontCharMap.Reset( aCache[i].maCharMap.mpImpl ); } else // need to cache +#endif // ENABLE_IFC_CACHE { - ImplFontCharMap* pNewMap = mpGraphics->GetImplFontCharMap(); + const ImplFontCharMap* pNewMap = mpGraphics->GetImplFontCharMap(); rFontCharMap.Reset( pNewMap ); +#ifdef ENABLE_IFC_CACHE // manage cache round-robin and insert data CharMapCacheItem& rItem = aCache[ nCurItem ]; rItem.mpFontData = pFontData; @@ -7976,11 +8056,12 @@ BOOL OutputDevice::GetFontCharMap( FontCharMap& rFontCharMap ) const if( ++nUsedItems >= NMAXITEMS ) nUsedItems = NMAXITEMS; +#endif // ENABLE_IFC_CACHE } if( rFontCharMap.IsDefaultMap() ) - return FALSE; - return TRUE; + return sal_False; + return sal_True; } // ----------------------------------------------------------------------- @@ -7991,7 +8072,7 @@ xub_StrLen OutputDevice::HasGlyphs( const Font& rTempFont, const String& rStr, if( nIndex >= rStr.Len() ) return nIndex; xub_StrLen nEnd = nIndex + nLen; - if( (ULONG)nIndex+nLen > rStr.Len() ) + if( (sal_uLong)nIndex+nLen > rStr.Len() ) nEnd = rStr.Len(); DBG_ASSERT( nIndex < nEnd, "StartPos >= EndPos?" ); @@ -8001,11 +8082,11 @@ xub_StrLen OutputDevice::HasGlyphs( const Font& rTempFont, const String& rStr, const Font aOrigFont = GetFont(); const_cast<OutputDevice&>(*this).SetFont( rTempFont ); FontCharMap aFontCharMap; - BOOL bRet = GetFontCharMap( aFontCharMap ); + sal_Bool bRet = GetFontCharMap( aFontCharMap ); const_cast<OutputDevice&>(*this).SetFont( aOrigFont ); // if fontmap is unknown assume it doesn't have the glyphs - if( bRet == FALSE ) + if( bRet == sal_False ) return nIndex; const sal_Unicode* pStr = rStr.GetBuffer(); |