A while back FreeBSD upgraded to Clang 6.0 which defaults to C++14
instead of GNU++98/C++98 like earlier versions of Clang and GCC.
This triggered some new compile errors in the OpenOffice source
that probably had just previously been warnings.

One of the new errors was a integer constant getting assigned to a
pointer in SvpGlyphPeer::RemovingGlyph(), which lives in
main/vcl/unx/headless/svptext.cxx.  When I looked more closely at
this code to try to figure out the proper fix, I discovered that
this code is more broken than is immediately obvious.

There are two classes defined in main/vcl/inc/glyphcache.hxx that
each have a pair of similar members.  The GlyphData class contains
the private struct ExtGlyphData, which in turn contains "int meInfo"
and "void* mpData".  The ServerFont class contains the private
members "int mnExtInfo" and "void* mpExtData".

The GlyphData members are set in X11GlyphPeer::RemovingGlyph(),
X11GlyphPeer::PrepareForMultiscreen(), X11GlyphPeer::SetRenderGlyph(),
X11GlyphPeer::SetRawBitmap(), and X11GlyphPeer::SetPixmap() in
main/vcl/unx/generic/gdi/gcach_xpeer.cxx, where the meInfo value
is one of the INFO_* enum values in gcach_xpeer.cxx, and mpData can
point to various different types of objects.

The ServerFont members are set in X11GlyphPeer::RemovingFont() and
X11GlyphPeer::GetGlyphSet() in main/vcl/unx/generic/gdi/gcach_xpeer.cxx,
where the mnExtInfo value is a subset of the enum containing INFO_*
values in gcach_xpeer.cxx, and the mpExtData value is a GlyphSet.

Over on the headless side, GlyphData meInfo and mpData values are
examined in in SvpGlyphPeer::GetGlyphBmp() and
SvpGlyphPeer::RemovingGlyph(), but they are never set.  The expected
meInfo values come from the basebmp Format values in
main/basebmp/inc/basebmp/scanlineformats.hxx.  Instead,the headless
code sets the ServerFont members in SvpGlyphPeer::GetGlyphBmp()
with the mnExtInfo value coming from the basebmp Format values and
the mpExtData value being a SvpGcpHelper* fetched from mpData.  The
ServerFont members are not examined on the headless side.

The attached patch is my attempt at a fix.  It builds, but I don't know
how to do a meaningful test of headless mode.
Index: vcl/unx/headless/svptext.cxx
===================================================================
--- vcl/unx/headless/svptext.cxx	(revision 1838294)
+++ vcl/unx/headless/svptext.cxx	(working copy)
@@ -136,7 +136,8 @@
             pGcpHelper->maBitmapDev = createBitmapDevice( aSize, true, nBmpFormat, aRawPtr, aDummyPAL );
         }
 
-        rServerFont.SetExtended( nBmpFormat, (void*)pGcpHelper );
+        rGlyphData.ExtDataRef().meInfo = sal::static_int_cast<int>(nBmpFormat);
+        rGlyphData.ExtDataRef().mpData = (void*)pGcpHelper;
     }
 
     rTargetPos += B2IPoint( pGcpHelper->maRawBitmap.mnXOffset, pGcpHelper->maRawBitmap.mnYOffset );
@@ -154,7 +155,7 @@
 
 void SvpGlyphPeer::RemovingGlyph( ServerFont&, GlyphData& rGlyphData, sal_GlyphId /*aGlyphId*/ )
 {
-    if( rGlyphData.ExtDataRef().mpData != Format::NONE )
+    if( rGlyphData.ExtDataRef().meInfo != Format::NONE )
     {
         // release the glyph related resources
         DBG_ASSERT( (rGlyphData.ExtDataRef().meInfo <= Format::MAX), "SVP::RG() invalid alpha format" ); 
@@ -161,6 +162,7 @@
         SvpGcpHelper* pGcpHelper = (SvpGcpHelper*)rGlyphData.ExtDataRef().mpData;
         delete[] pGcpHelper->maRawBitmap.mpBits;
         delete pGcpHelper;
+        rGlyphData.ExtDataRef().meInfo = Format::NONE;
     }
 }
 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@openoffice.apache.org
For additional commands, e-mail: dev-h...@openoffice.apache.org

Reply via email to