summaryrefslogtreecommitdiff
path: root/vcl/generic
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2011-10-07 17:29:49 +0100
committerMichael Meeks <michael.meeks@suse.com>2011-10-25 13:41:54 +0100
commita53082c7c856eb5cf076ee8c14fd92939d6952b2 (patch)
tree6cf1548d54352b71e414386b77767788acebf505 /vcl/generic
parent8d068d15b2dae039600aaa7bac7299055ce7aea8 (diff)
generic: more unix conditional compilation pieces and win32 porting
Diffstat (limited to 'vcl/generic')
-rw-r--r--vcl/generic/print/genprnpsp.cxx31
-rw-r--r--vcl/generic/print/genpspgraphics.cxx32
-rw-r--r--vcl/generic/print/glyphset.cxx6
-rw-r--r--vcl/generic/print/printerjob.cxx42
4 files changed, 62 insertions, 49 deletions
diff --git a/vcl/generic/print/genprnpsp.cxx b/vcl/generic/print/genprnpsp.cxx
index 9783652ca4e8..9e5e2c6e355b 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 b9b82a08763e..823d46ac28b9 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 b040e631e766..139cf069c77f 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 d8a5d7196ecf..3c1280fc5076 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