[Libreoffice-commits] .: Branch 'feature/gtk3' - vcl/generic vcl/headless

Michael Meeks michael at kemper.freedesktop.org
Thu Sep 29 09:27:28 PDT 2011


 vcl/generic/print/printerjob.cxx |   53 +++++----------------------------------
 vcl/headless/svpdummies.cxx      |   17 +++---------
 vcl/headless/svpframe.cxx        |   13 +++------
 vcl/headless/svpgdi.cxx          |    2 +
 vcl/headless/svpprn.cxx          |    4 --
 5 files changed, 19 insertions(+), 70 deletions(-)

New commits:
commit 6736cf693f4afd93bbd043cef283eb45179e4ba7
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Thu Sep 29 17:27:46 2011 +0100

    misc cross-platform dependency / build issue redux

diff --git a/vcl/generic/print/printerjob.cxx b/vcl/generic/print/printerjob.cxx
index dc06e3b..7509259 100644
--- a/vcl/generic/print/printerjob.cxx
+++ b/vcl/generic/print/printerjob.cxx
@@ -34,7 +34,6 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <pwd.h>
 
 #include "psputil.hxx"
 #include "glyphset.hxx"
@@ -49,8 +48,9 @@
 #include "rtl/strbuf.hxx"
 #include "rtl/ustrbuf.hxx"
 
-#include "osl/thread.h"
-#include "sal/alloca.h"
+#include <osl/thread.h>
+#include <osl/security.hxx>
+#include <sal/alloca.h>
 #include <sal/macros.h>
 
 #include <algorithm>
@@ -215,44 +215,6 @@ PrinterJob::PrinterJob () :
 {
 }
 
-namespace psp
-{
-
-/* return the username in the given buffer */
-sal_Bool
-getUserName (char* pName, int nSize)
-{
-    struct passwd *pPWEntry;
-    struct passwd  aPWEntry;
-    sal_Char       pPWBuffer[256];
-
-    sal_Bool bSuccess = sal_False;
-
-#ifdef FREEBSD
-        pPWEntry = getpwuid( getuid());
-#else
-    if (getpwuid_r(getuid(), &aPWEntry, pPWBuffer, sizeof(pPWBuffer), &pPWEntry) != 0)
-        pPWEntry = NULL;
-#endif
-
-    if (pPWEntry != NULL && pPWEntry->pw_name != NULL)
-    {
-        sal_Int32 nLen = strlen(pPWEntry->pw_name);
-        if (nLen > 0 && nLen < nSize)
-        {
-            memcpy (pName, pPWEntry->pw_name, nLen);
-            pName[nLen] = '\0';
-
-            bSuccess = sal_True;
-        }
-    }
-
-    // wipe the passwd off the stack
-    memset (pPWBuffer, 0, sizeof(pPWBuffer));
-
-    return bSuccess;
-}
-
 /* remove all our temporary files, uses external program "rm", since
    osl functionality is inadequate */
 void
@@ -310,8 +272,6 @@ createSpoolDir ()
     return rtl::OUString();
 }
 
-} // namespace psp
-
 PrinterJob::~PrinterJob ()
 {
     std::list< osl::File* >::iterator pPage;
@@ -406,11 +366,12 @@ PrinterJob::StartJob (
     WritePS (mpJobHeader, ")\n");
 
     // For (user name)
-    sal_Char pUserName[64];
-    if (getUserName(pUserName, sizeof(pUserName)))
+    osl::Security aSecurity;
+    rtl::OUString aUserName;
+    if( aSecurity.getUserName( aUserName ) )
     {
         WritePS (mpJobHeader, "%%For: (");
-        WritePS (mpJobHeader, pUserName);
+        WritePS (mpJobHeader, aUserName);
         WritePS (mpJobHeader, ")\n");
     }
 
diff --git a/vcl/headless/svpdummies.cxx b/vcl/headless/svpdummies.cxx
index 272f06c..32646b8 100644
--- a/vcl/headless/svpdummies.cxx
+++ b/vcl/headless/svpdummies.cxx
@@ -26,24 +26,17 @@
  *
  ************************************************************************/
 
+#include <string.h>
+#include <rtl/ustrbuf.hxx>
 #include "headless/svpdummies.hxx"
 #include "headless/svpinst.hxx"
-#include <rtl/ustrbuf.hxx>
 
 // SalObject
 SvpSalObject::SvpSalObject()
 {
-    m_aSystemChildData.nSize        = sizeof( SystemChildData );
-    m_aSystemChildData.pDisplay     = NULL;
-    m_aSystemChildData.aWindow      = 0;
-    m_aSystemChildData.pSalFrame    = 0;
-    m_aSystemChildData.pWidget      = 0;
-    m_aSystemChildData.pVisual      = 0;
-    m_aSystemChildData.nDepth       = 0;
-    m_aSystemChildData.aColormap    = 0;
-    m_aSystemChildData.pAppContext  = NULL;
-    m_aSystemChildData.aShellWindow = 0;
-    m_aSystemChildData.pShellWidget = NULL;
+    // fast and easy cross-platform wiping of the data
+    memset( (void *)&m_aSystemChildData, 0, sizeof( SystemChildData ) );
+    m_aSystemChildData.nSize = sizeof( SystemChildData );
 }
 
 SvpSalObject::~SvpSalObject()
diff --git a/vcl/headless/svpframe.cxx b/vcl/headless/svpframe.cxx
index 8ff0e5e..864dd2c 100644
--- a/vcl/headless/svpframe.cxx
+++ b/vcl/headless/svpframe.cxx
@@ -26,6 +26,7 @@
  *
  ************************************************************************/
 
+#include <string.h>
 #include "headless/svpframe.hxx"
 #include "headless/svpinst.hxx"
 #include "headless/svpgdi.hxx"
@@ -51,17 +52,13 @@ SvpSalFrame::SvpSalFrame( SvpSalInstance* pInstance,
     m_nMaxWidth( 0 ),
     m_nMaxHeight( 0 )
 {
+    // fast and easy cross-platform wiping of the data
+    memset( (void *)&m_aSystemChildData, 0, sizeof( SystemChildData ) );
     m_aSystemChildData.nSize        = sizeof( SystemChildData );
-    m_aSystemChildData.pDisplay     = NULL;
-    m_aSystemChildData.aWindow      = 0;
+#if defined( UNX ) // FIXME: prolly redundant
     m_aSystemChildData.pSalFrame    = this;
-    m_aSystemChildData.pWidget      = NULL;
-    m_aSystemChildData.pVisual      = NULL;
     m_aSystemChildData.nDepth       = 24;
-    m_aSystemChildData.aColormap    = 0;
-    m_aSystemChildData.pAppContext  = NULL;
-    m_aSystemChildData.aShellWindow = 0;
-    m_aSystemChildData.pShellWidget = NULL;
+#endif
 
     if( m_pParent )
         m_pParent->m_aChildren.push_back( this );
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index c415774..8912acc 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -228,7 +228,9 @@ SvpSalGraphics::ClipUndoHandle SvpSalGraphics::ensureClipFor( const basegfx::B2I
     if( nHit == 0 )
     {
         // degenerate case - we're all clipped ... hmm.
+#if defined( UNX )
         fprintf (stderr, "FIXME: denegerate case detected ...\n");
+#endif
     }
     else if( nHit == 1 )
     {
diff --git a/vcl/headless/svpprn.cxx b/vcl/headless/svpprn.cxx
index 452f8ab..ded175a 100644
--- a/vcl/headless/svpprn.cxx
+++ b/vcl/headless/svpprn.cxx
@@ -29,10 +29,6 @@
 // MARKER(update_precomp.py): autogen include statement, do not remove
 #include "precompiled_vcl.hxx"
 
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-
 #include "vcl/svapp.hxx"
 #include "vcl/timer.hxx"
 #include "vcl/printerinfomanager.hxx"


More information about the Libreoffice-commits mailing list