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

Michael Meeks michael at kemper.freedesktop.org
Fri Oct 7 09:54:55 PDT 2011


 vcl/generic/print/genprnpsp.cxx      |   31 ++++++++++++++++++++-----
 vcl/generic/print/genpspgraphics.cxx |   32 ++++++++++----------------
 vcl/generic/print/glyphset.cxx       |    6 +++++
 vcl/generic/print/printerjob.cxx     |   42 +++++++++++++++--------------------
 vcl/headless/svpgdi.cxx              |    6 -----
 vcl/inc/vcl/sysdata.hxx              |   31 +++++++++++++++++++++++++
 vcl/win/source/gdi/salgdi3.cxx       |    8 ------
 7 files changed, 95 insertions(+), 61 deletions(-)

New commits:
commit 212534810d168558bb1039b8421744b9efeaa2bd
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Fri Oct 7 17:29:49 2011 +0100

    generic: more unix conditional compilation pieces and win32 porting

diff --git a/vcl/generic/print/genprnpsp.cxx b/vcl/generic/print/genprnpsp.cxx
index 9783652..9e5e2c6 100644
--- a/vcl/generic/print/genprnpsp.cxx
+++ b/vcl/generic/print/genprnpsp.cxx
@@ -41,9 +41,12 @@
   printer job functions.
  */
 
-#include <unistd.h>
-#include <sys/wait.h>
-#include <sys/stat.h>
+// For spawning PDF and FAX generation
+#if defined( UNX )
+#  include <unistd.h>
+#  include <sys/wait.h>
+#  include <sys/stat.h>
+#endif
 
 #include "rtl/ustring.hxx"
 
@@ -106,6 +109,7 @@ static String getPdfDir( const PrinterInfo& rInfo )
 
 static void getPaLib()
 {
+#if defined( UNX )
     if( ! driverLib )
     {
         OUString aLibName( RTL_CONSTASCII_USTRINGPARAM( _XSALSET_LIBNAME ) );
@@ -123,6 +127,7 @@ static void getPaLib()
         if ( !pFaxNrFunction )
             fprintf( stderr, "could not resolve Sal_queryFaxNumber\n" );
     }
+#endif
 }
 
 inline int PtTo10Mu( int nPoints ) { return (int)((((double)nPoints)*35.27777778)+0.5); }
@@ -225,6 +230,8 @@ static void copyJobDataToJobSetup( ImplJobSetup* pJobSetup, JobData& rData )
     }
 }
 
+// Needs a cleaner abstraction ...
+#if defined( UNX )
 static bool passFileToCommandLine( const String& rFilename, const String& rCommandLine, bool bRemoveFile = true )
 {
     bool bSuccess = false;
@@ -308,9 +315,11 @@ static bool passFileToCommandLine( const String& rFilename, const String& rComma
 
     return bSuccess;
 }
+#endif
 
 static bool sendAFax( const String& rFaxNumber, const String& rFileName, const String& rCommand )
 {
+#if defined( UNX )
     std::list< OUString > aFaxNumbers;
 
     if( ! rFaxNumber.Len() )
@@ -368,14 +377,23 @@ static bool sendAFax( const String& rFaxNumber, const String& rFileName, const S
     unlink( ByteString( rFileName, osl_getThreadTextEncoding() ).GetBuffer() );
 
     return bSuccess;
+#else
+    (void)rFaxNumber; (void)rFileName; (void)rCommand;
+    return false;
+#endif
 }
 
 static bool createPdf( const String& rToFile, const String& rFromFile, const String& rCommandLine )
 {
+#if defined( UNX )
     String aCommandLine( rCommandLine );
     while( aCommandLine.SearchAndReplace( String( RTL_CONSTASCII_USTRINGPARAM( "(OUTFILE)" ) ), rToFile ) != STRING_NOTFOUND )
         ;
     return passFileToCommandLine( rFromFile, aCommandLine );
+#else
+    (void)rToFile; (void)rFromFile; (void)rCommandLine;
+    return false;
+#endif
 }
 
 /*
@@ -929,10 +947,11 @@ sal_Bool PspSalPrinter::StartJob(
         m_aJobData.setCollate( bCollate );
     }
 
-    // check wether this printer is configured as fax
     int nMode = 0;
-    const PrinterInfo& rInfo( PrinterInfoManager::get().getPrinterInfo( m_aJobData.m_aPrinterName ) );
+#if defined( UNX )
+    // check whether this printer is configured as fax
     sal_Int32 nIndex = 0;
+    const PrinterInfo& rInfo( PrinterInfoManager::get().getPrinterInfo( m_aJobData.m_aPrinterName ) );
     while( nIndex != -1 )
     {
         OUString aToken( rInfo.m_aFeatures.getToken( 0, ',', nIndex ) );
@@ -968,6 +987,7 @@ sal_Bool PspSalPrinter::StartJob(
             break;
         }
     }
+#endif
     m_aPrinterGfx.Init( m_aJobData );
 
     // set/clear backwards compatibility flag
@@ -999,7 +1019,6 @@ sal_Bool PspSalPrinter::EndJob()
             // check for fax
             if( m_bFax )
             {
-
                 const PrinterInfo& rInfo( PrinterInfoManager::get().getPrinterInfo( m_aJobData.m_aPrinterName ) );
                 // sendAFax removes the file after use
                 bSuccess = sendAFax( m_aFaxNr, m_aTmpFile, rInfo.m_aCommand );
diff --git a/vcl/generic/print/genpspgraphics.cxx b/vcl/generic/print/genpspgraphics.cxx
index b9b82a0..823d46a 100644
--- a/vcl/generic/print/genpspgraphics.cxx
+++ b/vcl/generic/print/genpspgraphics.cxx
@@ -1317,27 +1317,15 @@ bool GenPspGraphics::drawAlphaRect( long, long, long, long, sal_uInt8 )
 
 SystemGraphicsData GenPspGraphics::GetGraphicsData() const
 {
-    SystemGraphicsData aRes;
-    aRes.nSize = sizeof(aRes);
-        aRes.hDrawable = 0;
-        aRes.pXRenderFormat = 0;
-    return aRes;
+    return SystemGraphicsData();
 }
 
 SystemFontData GenPspGraphics::GetSysFontData( int nFallbacklevel ) const
 {
-    SystemFontData aSysFontData;
-
     if (nFallbacklevel >= MAX_FALLBACK) nFallbacklevel = MAX_FALLBACK - 1;
     if (nFallbacklevel < 0 ) nFallbacklevel = 0;
 
-    aSysFontData.nSize = sizeof( SystemFontData );
-    aSysFontData.nFontId = 0;
-    aSysFontData.nFontFlags = 0;
-    aSysFontData.bFakeBold = false;
-    aSysFontData.bFakeItalic = false;
-    aSysFontData.bAntialias = true;
-    return aSysFontData;
+    return SystemFontData();
 }
 
 bool GenPspGraphics::supportsOperation( OutDevSupportType ) const
@@ -1351,7 +1339,8 @@ void GenPspGraphics::DoFreeEmbedFontData( const void* pData, long nLen )
     if( pData )
         munmap( (char*)pData, nLen );
 #else
-    rtl_freeMemory( pData );
+    (void)nLen;
+    rtl_freeMemory( (void *)pData );
 #endif
 }
 
@@ -1400,15 +1389,20 @@ const void* GenPspGraphics::DoGetEmbedFontData( psp::fontID aFont, const sal_Ucs
 #else
     // FIXME: test me ! ...
     rtl::OUString aURL;
-    if( !getFileURLFromSystemPath( rtl::OStringToOUString( aSysPath, osl_getThreadTextEncoding(), aURL ) ) )
+    if( !osl::File::getFileURLFromSystemPath( rtl::OStringToOUString( aSysPath, osl_getThreadTextEncoding() ), aURL ) )
         return NULL;
     osl::File aFile( aURL );
-    if( aFile.open( osl_File_OpenFlag_Read | osl_File_OpenFlag_NoLock ) != osl_File_E_None )
+    if( aFile.open( osl_File_OpenFlag_Read | osl_File_OpenFlag_NoLock ) != osl::File::E_None )
         return NULL;
 
-    pFile = rtl_allocMemory( aFile.getFileSize() );
+    osl::DirectoryItem aItem;
+    osl::DirectoryItem::get( aURL, aItem );
+    osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileSize );
+    aItem.getFileStatus( aFileStatus );
+
+    void *pFile = rtl_allocateMemory( aFileStatus.getFileSize() );
     sal_uInt64 nRead = 0;
-    aFile.read( pFile, aFile.getFileSize(), nRead );
+    aFile.read( pFile, aFileStatus.getFileSize(), nRead );
     *pDataLen = (long) nRead;
 #endif
 
diff --git a/vcl/generic/print/glyphset.cxx b/vcl/generic/print/glyphset.cxx
index b040e63..139cf06 100644
--- a/vcl/generic/print/glyphset.cxx
+++ b/vcl/generic/print/glyphset.cxx
@@ -845,6 +845,7 @@ GlyphSet::PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAllowType42
     if (meBaseType != fonttype::TrueType)
         return sal_False;
 
+#if defined( UNX )
     TrueTypeFont *pTTFont;
     OString aTTFileName (rGfx.GetFontMgr().getFontFileSysPath(mnFontID));
     int nFace = rGfx.GetFontMgr().getFontFaceNumber(mnFontID);
@@ -944,6 +945,11 @@ GlyphSet::PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAllowType42
     fclose (pTmpFile);
 
     return sal_True;
+#else
+    (void)rOutFile; (void)rGfx; (void)bAllowType42; (void)rSuppliedFonts;
+#  warning FIXME: Missing OpenTTFontFile outside of Unix ...
+    return sal_False;
+#endif
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/generic/print/printerjob.cxx b/vcl/generic/print/printerjob.cxx
index d8a5d71..3c1280f 100644
--- a/vcl/generic/print/printerjob.cxx
+++ b/vcl/generic/print/printerjob.cxx
@@ -297,20 +297,24 @@ PrinterJob::~PrinterJob ()
     // osl::Directory::remove (maSpoolDirName);
 }
 
-namespace psp
-{
-
-// get locale invariant, 7bit clean current local time string
-sal_Char*
-getLocalTime(sal_Char* pBuffer)
+static void WriteLocalTimePS( osl::File *rFile )
 {
-    time_t nTime = time (NULL);
-    struct tm aTime;
-    struct tm *pLocalTime = localtime_r (&nTime, &aTime);
-
-    return asctime_r(pLocalTime, pBuffer);
-}
-
+    TimeValue m_start_time, tLocal;
+    oslDateTime date_time;
+    if (osl_getSystemTime( &m_start_time ) &&
+        osl_getLocalTimeFromSystemTime( &m_start_time, &tLocal ) &&
+        osl_getDateTimeFromTimeValue( &tLocal, &date_time ))
+    {
+        char ar[ 256 ];
+        snprintf(
+            ar, sizeof (ar),
+            "%04d-%02d-%02d %02d:%02d:%02d ",
+            date_time.Year, date_time.Month, date_time.Day,
+            date_time.Hours, date_time.Minutes, date_time.Seconds );
+        WritePS( rFile, ar );
+    }
+    else
+        WritePS( rFile, "Unknown-Time" );
 }
 
 static bool isAscii( const rtl::OUString& rStr )
@@ -375,18 +379,8 @@ PrinterJob::StartJob (
     }
 
     // Creation Date (locale independent local time)
-    sal_Char pCreationDate [256];
     WritePS (mpJobHeader, "%%CreationDate: (");
-    getLocalTime(pCreationDate);
-    for( unsigned int i = 0; i < SAL_N_ELEMENTS(pCreationDate); i++ )
-    {
-        if( pCreationDate[i] == '\n' )
-        {
-            pCreationDate[i] = 0;
-            break;
-        }
-    }
-    WritePS (mpJobHeader, pCreationDate );
+    WriteLocalTimePS (mpJobHeader);
     WritePS (mpJobHeader, ")\n");
 
     // Document Title
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx
index 8912acc..3609bd9 100644
--- a/vcl/headless/svpgdi.cxx
+++ b/vcl/headless/svpgdi.cxx
@@ -689,11 +689,7 @@ SystemFontData SvpSalGraphics::GetSysFontData( int nFallbacklevel ) const
 
 SystemGraphicsData SvpSalGraphics::GetGraphicsData() const
 {
-    SystemGraphicsData aRes;
-    aRes.nSize = sizeof(aRes);
-    aRes.hDrawable = 0;
-    aRes.pXRenderFormat = 0;
-    return aRes;
+    return SystemGraphicsData();
 }
 
 bool SvpSalGraphics::supportsOperation( OutDevSupportType ) const
diff --git a/vcl/inc/vcl/sysdata.hxx b/vcl/inc/vcl/sysdata.hxx
index b5daf28..2e00618 100644
--- a/vcl/inc/vcl/sysdata.hxx
+++ b/vcl/inc/vcl/sysdata.hxx
@@ -143,6 +143,20 @@ struct SystemGraphicsData
     long            aColormap;      // the colormap being used
     void*           pXRenderFormat;  // render format for drawable
 #endif
+    SystemGraphicsData()
+        : nSize( sizeof( SystemGraphicsData ) )
+#if defined( WNT )
+        , hDC( 0 )
+#elif defined( UNX )
+        , pDisplay( NULL )
+        , hDrawable( 0 )
+        , pVisual( NULL )
+        , nScreen( 0 )
+        , nDepth( 0 )
+        , aColormap( 0 )
+        , pXRenderFormat( NULL )
+#endif
+    { }
 };
 
 
@@ -196,6 +210,23 @@ struct SystemFontData
     bool            bFakeItalic;    // Does this font need faking the italic style
     bool            bAntialias;     // Should this font be antialiased
     bool            bVerticalCharacterType;      // Is the font using vertical character type
+
+    SystemFontData()
+        : nSize( sizeof( SystemFontData ) )
+#if defined( WNT )
+        , hFont( 0 )
+#elif defined( QUARTZ )
+        , aATSUFontID( NULL )
+#elif defined( UNX )
+        , nFontId( NULL )
+        , nFontFlags( 0 )
+#endif
+        , bFakeBold( false )
+        , bFakeItalic( false )
+        , bAntialias( true )
+        , bVerticalCharacterType( false )
+    {
+    }
 };
 
 // --------------------
diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx
index db072f6..6bcc58e 100644
--- a/vcl/win/source/gdi/salgdi3.cxx
+++ b/vcl/win/source/gdi/salgdi3.cxx
@@ -3132,16 +3132,10 @@ SystemFontData WinSalGraphics::GetSysFontData( int nFallbacklevel ) const
     if (nFallbacklevel >= MAX_FALLBACK) nFallbacklevel = MAX_FALLBACK - 1;
     if (nFallbacklevel < 0 ) nFallbacklevel = 0;
 
-    aSysFontData.nSize = sizeof( SystemFontData );
     aSysFontData.hFont = mhFonts[nFallbacklevel];
-    aSysFontData.bFakeBold = false;
-    aSysFontData.bFakeItalic = false;
-    aSysFontData.bAntialias = true;
-    aSysFontData.bVerticalCharacterType = false;
 
     OSL_TRACE("\r\n:WinSalGraphics::GetSysFontData(): FontID: %p, Fallback level: %d",
-              aSysFontData.hFont,
-              nFallbacklevel);
+              aSysFontData.hFont, nFallbacklevel);
 
     return aSysFontData;
 }


More information about the Libreoffice-commits mailing list