[Libreoffice-commits] core.git: canvas/source drawinglayer/source include/vcl vcl/source

Khaled Hosny khaledhosny at eglug.org
Wed Dec 14 00:28:47 UTC 2016


 canvas/source/opengl/ogl_canvashelper.cxx            |    1 
 canvas/source/vcl/textlayout.cxx                     |    1 
 drawinglayer/source/primitive2d/textlayoutdevice.cxx |    1 
 include/vcl/outdev.hxx                               |    2 
 vcl/source/outdev/text.cxx                           |  259 -------------------
 5 files changed, 5 insertions(+), 259 deletions(-)

New commits:
commit d538d3d84172a74dfe97d59a6d3daf9a45459cab
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Mon Dec 12 15:00:05 2016 +0200

    This fallback code makes no sense any more
    
    Ito probably made sense only with bitmap fonts which we no longer
    support, and if we don’t need the fallback for printer devices then we
    don’t need it on screen either (that whole printer/screen distinction
    needs to die someday).
    
    Change-Id: Icf77cd70f0f1b2c186a3c856900295caba72e903
    Reviewed-on: https://gerrit.libreoffice.org/31914
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Khaled Hosny <khaledhosny at eglug.org>

diff --git a/canvas/source/opengl/ogl_canvashelper.cxx b/canvas/source/opengl/ogl_canvashelper.cxx
index 175a02b..a82e73d 100644
--- a/canvas/source/opengl/ogl_canvashelper.cxx
+++ b/canvas/source/opengl/ogl_canvashelper.cxx
@@ -774,7 +774,6 @@ namespace oglcanvas
                                           0,
                                           rTxt.StartPosition,
                                           rTxt.Length,
-                                          true,
                                           0,
                                           pDXArray.get() );
                 }
diff --git a/canvas/source/vcl/textlayout.cxx b/canvas/source/vcl/textlayout.cxx
index 089af45..67520a3 100644
--- a/canvas/source/vcl/textlayout.cxx
+++ b/canvas/source/vcl/textlayout.cxx
@@ -130,7 +130,6 @@ namespace vclcanvas
             maText.StartPosition,
             maText.StartPosition,
             maText.Length,
-            false,
             0,
             aOffsets.get()))
         {
diff --git a/drawinglayer/source/primitive2d/textlayoutdevice.cxx b/drawinglayer/source/primitive2d/textlayoutdevice.cxx
index 3c64903..50eae8b 100644
--- a/drawinglayer/source/primitive2d/textlayoutdevice.cxx
+++ b/drawinglayer/source/primitive2d/textlayoutdevice.cxx
@@ -261,7 +261,6 @@ namespace drawinglayer
                     nIndex,
                     nIndex,
                     nLength,
-                    true,
                     0,
                     &(aIntegerDXArray[0]));
             }
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 7cdda54..0766de4 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1082,7 +1082,7 @@ public:
 
     bool                        GetTextOutlines( basegfx::B2DPolyPolygonVector &rVector,
                                                  const OUString& rStr, sal_Int32 nBase, sal_Int32 nIndex = 0,
-                                                 sal_Int32 nLen = -1, bool bOptimize = true,
+                                                 sal_Int32 nLen = -1,
                                                  sal_uLong nLayoutWidth = 0, const long* pDXArray = nullptr ) const;
 
 
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 73fc0a0..d096d22 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -2434,125 +2434,13 @@ bool OutputDevice::GetTextBoundRect( Rectangle& rRect,
         pSalLayout->Release();
     }
 
-    if( bRet || (OUTDEV_PRINTER == meOutDevType) || !mpFontInstance )
-        return bRet;
-
-    // fall back to bitmap method to get the bounding rectangle,
-    // so we need a monochrome virtual device with matching font
-    ScopedVclPtrInstance< VirtualDevice > aVDev(DeviceFormat::BITMASK);
-    vcl::Font aFont( GetFont() );
-    aFont.SetShadow( false );
-    aFont.SetOutline( false );
-    aFont.SetRelief( FontRelief::NONE );
-    aFont.SetOrientation( 0 );
-    aFont.SetFontSize( Size( mpFontInstance->maFontSelData.mnWidth, mpFontInstance->maFontSelData.mnHeight ) );
-    aVDev->SetFont( aFont );
-    aVDev->SetTextAlign( ALIGN_TOP );
-
-    // layout the text on the virtual device
-    pSalLayout = aVDev->ImplLayout( rStr, nIndex, nLen, aPoint, nLayoutWidth, pDXAry );
-    if( !pSalLayout )
-        return false;
-
-    // make the bitmap big enough
-    // TODO: use factors when it would get too big
-    long nWidth = pSalLayout->GetTextWidth();
-    long nHeight = mpFontInstance->mnLineHeight + mnEmphasisAscent + mnEmphasisDescent;
-    Point aOffset( nWidth/2, 8 );
-    Size aOutSize( nWidth + 2*aOffset.X(), nHeight + 2*aOffset.Y() );
-    if( !nWidth || !aVDev->SetOutputSizePixel( aOutSize ) )
-    {
-        pSalLayout->Release();
-        return false;
-    }
-
-    // draw text in black
-    pSalLayout->DrawBase() = aOffset;
-    aVDev->SetTextColor( Color( COL_BLACK ) );
-    aVDev->SetTextFillColor();
-    aVDev->ImplInitTextColor();
-    aVDev->ImplDrawText( *pSalLayout );
-    pSalLayout->Release();
-
-    // find extents using the bitmap
-    Bitmap aBmp = aVDev->GetBitmap( Point(), aOutSize );
-    Bitmap::ScopedReadAccess pAcc(aBmp);
-    if( !pAcc )
-        return false;
-    const BitmapColor aBlack( pAcc->GetBestMatchingColor( Color( COL_BLACK ) ) );
-    const long nW = pAcc->Width();
-    const long nH = pAcc->Height();
-    long nLeft = 0;
-    long nRight = 0;
-
-    // find top left point
-    long nTop = 0;
-    for(; nTop < nH; ++nTop )
-    {
-        for( nLeft = 0; nLeft < nW; ++nLeft )
-            if( pAcc->GetPixel( nTop, nLeft ) == aBlack )
-                break;
-        if( nLeft < nW )
-            break;
-    }
-
-    // find bottom right point
-    long nBottom = nH;
-    while( --nBottom >= nTop )
-    {
-        for( nRight = nW; --nRight >= 0; )
-            if( pAcc->GetPixel( nBottom, nRight ) == aBlack )
-                break;
-        if( nRight >= 0 )
-            break;
-    }
-    if( nRight < nLeft )
-    {
-        long nX = nRight;
-        nRight = nLeft;
-        nLeft  = nX;
-    }
-
-    for( long nY = nTop; nY <= nBottom; ++nY )
-    {
-        // find leftmost point
-        long nX;
-        for( nX = 0; nX < nLeft; ++nX )
-            if( pAcc->GetPixel( nY, nX ) == aBlack )
-                break;
-        nLeft = nX;
-
-        // find rightmost point
-        for( nX = nW; --nX > nRight; )
-            if( pAcc->GetPixel( nY, nX ) == aBlack )
-                break;
-        nRight = nX;
-    }
-
-    pAcc.reset();
-
-    if( nTop <= nBottom )
-    {
-        Size aSize( nRight - nLeft + 1, nBottom - nTop + 1 );
-        Point aTopLeft( nLeft, nTop );
-        aTopLeft -= aOffset;
-        // adjust to text alignment
-        aTopLeft.Y()+= mnTextOffY - (mpFontInstance->mxFontMetric->GetAscent() + mnEmphasisAscent);
-        // convert to logical coordinates
-        aSize = PixelToLogic( aSize );
-        aTopLeft.X() = ImplDevicePixelToLogicWidth( aTopLeft.X() );
-        aTopLeft.Y() = ImplDevicePixelToLogicHeight( aTopLeft.Y() );
-        rRect = Rectangle( aTopLeft, aSize );
-        return true;
-    }
-
-    return false;
+    return bRet;
 }
 
 bool OutputDevice::GetTextOutlines( basegfx::B2DPolyPolygonVector& rVector,
                                         const OUString& rStr, sal_Int32 nBase,
                                         sal_Int32 nIndex, sal_Int32 nLen,
-                                        bool bOptimize, sal_uLong nLayoutWidth, const long* pDXArray ) const
+                                        sal_uLong nLayoutWidth, const long* pDXArray ) const
 {
     if(nLen == 0x0FFFF)
     {
@@ -2644,145 +2532,6 @@ bool OutputDevice::GetTextOutlines( basegfx::B2DPolyPolygonVector& rVector,
         const_cast<OutputDevice&>(*this).mbNewFont = true;
     }
 
-    if( bRet || (OUTDEV_PRINTER == meOutDevType) || !mpFontInstance )
-        return bRet;
-
-    // reset work done (tdf#81876)
-    rVector.clear();
-
-    // fall back to bitmap conversion
-    // Here, we can safely assume that the mapping between characters and glyphs
-    // is one-to-one. This is most probably valid for the old bitmap fonts.
-    // fall back to bitmap method to get the bounding rectangle,
-    // so we need a monochrome virtual device with matching font
-    pSalLayout = ImplLayout( rStr, nIndex, nLen, Point(0,0), nLayoutWidth, pDXArray );
-    if (pSalLayout == nullptr)
-        return false;
-    long nOrgWidth = pSalLayout->GetTextWidth();
-    long nOrgHeight = mpFontInstance->mnLineHeight + mnEmphasisAscent
-        + mnEmphasisDescent;
-    pSalLayout->Release();
-
-    ScopedVclPtrInstance< VirtualDevice > aVDev(DeviceFormat::BITMASK);
-
-    vcl::Font aFont(GetFont());
-    aFont.SetShadow(false);
-    aFont.SetOutline(false);
-    aFont.SetRelief(FontRelief::NONE);
-    aFont.SetOrientation(0);
-    if( bOptimize )
-    {
-        aFont.SetFontSize( Size( 0, GLYPH_FONT_HEIGHT ) );
-        aVDev->SetMapMode( MapUnit::MapPixel );
-    }
-    aVDev->SetFont( aFont );
-    aVDev->SetTextAlign( ALIGN_TOP );
-    aVDev->SetTextColor( Color(COL_BLACK) );
-    aVDev->SetTextFillColor();
-
-    pSalLayout = aVDev->ImplLayout( rStr, nIndex, nLen, Point(0,0), nLayoutWidth, pDXArray );
-    if (pSalLayout == nullptr)
-        return false;
-    long nWidth = pSalLayout->GetTextWidth();
-    long nHeight = aVDev->mpFontInstance->mnLineHeight + aVDev->mnEmphasisAscent +
-                   aVDev->mnEmphasisDescent;
-    pSalLayout->Release();
-
-    if( !nWidth || !nHeight )
-        return true;
-    double fScaleX = static_cast< double >(nOrgWidth) / nWidth;
-    double fScaleY = static_cast< double >(nOrgHeight) / nHeight;
-
-    // calculate offset when nBase!=nIndex
-    // TODO: fix offset calculation for Bidi case
-    nXOffset = 0;
-    if( nBase != nIndex )
-    {
-        sal_Int32 nStart  = ((nBase < nIndex) ? nBase : nIndex);
-        sal_Int32 nLength = ((nBase > nIndex) ? nBase : nIndex) - nStart;
-        pSalLayout = aVDev->ImplLayout( rStr, nStart, nLength, Point(0,0), nLayoutWidth, pDXArray );
-        if( pSalLayout )
-        {
-            nXOffset = pSalLayout->GetTextWidth();
-            pSalLayout->Release();
-            if( nBase > nIndex)
-                nXOffset = -nXOffset;
-        }
-    }
-
-    bRet = true;
-    bool bRTL = false;
-    OUString aStr( rStr ); // prepare for e.g. localized digits
-    sal_Int32 nIndex2 = nIndex; // only needed until nIndex is sal_Int32
-    sal_Int32 nLen2 = nLen; // only needed until nLen is sal_Int32
-    ImplLayoutArgs aLayoutArgs = ImplPrepareLayoutArgs( aStr, nIndex2, nLen2, 0, nullptr );
-    for( int nCharPos = -1; aLayoutArgs.GetNextPos( &nCharPos, &bRTL);)
-    {
-        bool bSuccess = false;
-
-        // draw character into virtual device
-        pSalLayout = aVDev->ImplLayout( rStr, nCharPos, 1, Point(0,0), nLayoutWidth, pDXArray );
-        if (pSalLayout == nullptr)
-            return false;
-        long nCharWidth = pSalLayout->GetTextWidth();
-
-        Point aOffset(nCharWidth / 2, 8);
-        Size aSize(nCharWidth + 2 * aOffset.X(), nHeight + 2 * aOffset.Y());
-        bSuccess = (bool)aVDev->SetOutputSizePixel(aSize);
-        if( bSuccess )
-        {
-            // draw glyph into virtual device
-            aVDev->Erase();
-            pSalLayout->DrawBase() += aOffset;
-            pSalLayout->DrawBase() += Point( aVDev->mnTextOffX, aVDev->mnTextOffY );
-            pSalLayout->DrawText( *aVDev->mpGraphics );
-            pSalLayout->Release();
-
-            // convert character image into outline
-            Bitmap aBmp( aVDev->GetBitmap(Point(0, 0), aSize));
-
-            tools::PolyPolygon aPolyPoly;
-            bool bVectorized = aBmp.Vectorize(aPolyPoly);
-            if( !bVectorized )
-                bSuccess = false;
-            else
-            {
-                // convert units to logical width
-                for (sal_uInt16 j = 0; j < aPolyPoly.Count(); ++j)
-                {
-                    tools::Polygon& rPoly = aPolyPoly[j];
-                    for (sal_uInt16 k = 0; k < rPoly.GetSize(); ++k)
-                    {
-                        Point& rPt = rPoly[k];
-                        rPt -= aOffset;
-                        int nPixelX = rPt.X() - static_cast<OutputDevice*>(aVDev.get())->mnTextOffX + nXOffset;
-                        int nPixelY = rPt.Y() - static_cast<OutputDevice*>(aVDev.get())->mnTextOffY;
-                        rPt.X() = ImplDevicePixelToLogicWidth( nPixelX );
-                        rPt.Y() = ImplDevicePixelToLogicHeight( nPixelY );
-                    }
-                }
-
-                // ignore "empty" glyphs:
-                if( aPolyPoly.Count() > 0 )
-                {
-                    // convert  to B2DPolyPolygon
-                    // TODO: get rid of intermediate tool's PolyPolygon
-                    basegfx::B2DPolyPolygon aB2DPolyPoly = aPolyPoly.getB2DPolyPolygon();
-                    basegfx::B2DHomMatrix aMatrix;
-                    aMatrix.scale( fScaleX, fScaleY );
-                    int nAngle = GetFont().GetOrientation();
-                    if( nAngle )
-                        aMatrix.rotate( nAngle * F_PI1800 );
-                    aB2DPolyPoly.transform( aMatrix );
-                    rVector.push_back( aB2DPolyPoly );
-                }
-            }
-        }
-
-        nXOffset += nCharWidth;
-        bRet = bRet && bSuccess;
-    }
-
     return bRet;
 }
 
@@ -2802,7 +2551,7 @@ bool OutputDevice::GetTextOutlines( PolyPolyVector& rResultVector,
     // get the basegfx polypolygon vector
     basegfx::B2DPolyPolygonVector aB2DPolyPolyVector;
     if( !GetTextOutlines( aB2DPolyPolyVector, rStr, nBase, nIndex, nLen,
-                         true/*bOptimize*/, nTWidth, pDXArray ) )
+                         nTWidth, pDXArray ) )
         return false;
 
     // convert to a tool polypolygon vector
@@ -2828,7 +2577,7 @@ bool OutputDevice::GetTextOutline( tools::PolyPolygon& rPolyPoly, const OUString
     // get the basegfx polypolygon vector
     basegfx::B2DPolyPolygonVector aB2DPolyPolyVector;
     if( !GetTextOutlines( aB2DPolyPolyVector, rStr, 0/*nBase*/, 0/*nIndex*/, nLen,
-                         true/*bOptimize*/, nTWidth, pDXArray ) )
+                         nTWidth, pDXArray ) )
         return false;
 
     // convert and merge into a tool polypolygon


More information about the Libreoffice-commits mailing list