summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2003-03-26 13:28:44 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2003-03-26 13:28:44 +0000
commit74b5f16bfd6688a7771b97be25e894834931fbac (patch)
tree6a79ad2973c1583c1f930e088c07da2fbb9dd62b
parentdb83cf60ae3f512763d17be63148ccb3b4640b72 (diff)
MWS_SRX644: migrate branch mws_srx644 -> HEAD
-rw-r--r--psprint/inc/psprint/ppdparser.hxx80
-rw-r--r--psprint/inc/psprint/printergfx.hxx18
-rw-r--r--psprint/inc/psprint/printerjob.hxx33
-rw-r--r--psprint/prj/build.lst4
-rw-r--r--psprint/source/fontsubset/sft.c12
-rw-r--r--psprint/source/helper/helper.cxx34
-rw-r--r--psprint/source/helper/ppdparser.cxx81
-rw-r--r--psprint/source/printer/printerinfomanager.cxx10
-rw-r--r--psprint/source/printergfx/bitmap_gfx.cxx6
-rw-r--r--psprint/source/printergfx/common_gfx.cxx270
-rw-r--r--psprint/source/printergfx/glyphset.cxx14
-rw-r--r--psprint/source/printergfx/glyphset.hxx6
-rw-r--r--psprint/source/printergfx/printerjob.cxx147
-rw-r--r--psprint/source/printergfx/psheader.ps4
-rw-r--r--psprint/source/printergfx/text_gfx.cxx104
-rw-r--r--psprint/util/makefile.mk6
-rw-r--r--psprint_config/prj/d.lst10
17 files changed, 619 insertions, 220 deletions
diff --git a/psprint/inc/psprint/ppdparser.hxx b/psprint/inc/psprint/ppdparser.hxx
index 0e5d85305747..64a68b59ad2f 100644
--- a/psprint/inc/psprint/ppdparser.hxx
+++ b/psprint/inc/psprint/ppdparser.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ppdparser.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: pl $ $Date: 2002-11-13 20:15:38 $
+ * last change: $Author: hr $ $Date: 2003-03-26 14:24:02 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -61,9 +61,9 @@
#ifndef _PSPRINT_PPDPARSER_HXX_
#define _PSPRINT_PPDPARSER_HXX_
-#ifndef __SGI_STL_LIST
#include <list>
-#endif
+#include <vector>
+
#ifndef _PSPRINT_HELPER_HXX_
#include <psprint/helper.hxx> // hash_map and OUString hash
#endif
@@ -99,23 +99,28 @@ class PPDKey
{
friend class PPDParser;
- String m_aKey;
- ::std::hash_map< ::rtl::OUString, PPDValue, ::rtl::OUStringHash >
- m_aValues;
- const PPDValue* m_pDefaultValue;
- bool m_bQueryValue;
- PPDValue m_aQueryValue;
+ typedef ::std::hash_map< ::rtl::OUString, PPDValue, ::rtl::OUStringHash > hash_type;
+ typedef ::std::vector< PPDValue* > value_type;
+
+ String m_aKey;
+ hash_type m_aValues;
+ value_type m_aOrderedValues;
+ const PPDValue* m_pDefaultValue;
+ bool m_bQueryValue;
+ PPDValue m_aQueryValue;
public:
enum UIType { PickOne, PickMany, Boolean };
enum SetupType { ExitServer, Prolog, DocumentSetup, PageSetup, JCLSetup, AnySetup };
private:
- bool m_bUIOption;
- String m_aUITranslation;
- UIType m_eUIType;
- int m_nOrderDependency;
- SetupType m_eSetupType;
+ bool m_bUIOption;
+ String m_aUITranslation;
+ UIType m_eUIType;
+ int m_nOrderDependency;
+ SetupType m_eSetupType;
+
+ void eraseValue( const String& rOption );
public:
PPDKey( const String& rKey );
~PPDKey();
@@ -148,6 +153,11 @@ class PPDContext;
class PPDParser
{
friend class PPDContext;
+
+ typedef ::std::hash_map< ::rtl::OUString, PPDKey*, ::rtl::OUStringHash > hash_type;
+ typedef ::std::vector< PPDKey* > value_type;
+
+ void insertKey( const String& rKey, PPDKey* pKey );
public:
struct PPDConstraint
{
@@ -161,40 +171,40 @@ public:
static ::std::list< PPDParser* > aAllParsers;
- ::std::hash_map< ::rtl::OUString, PPDKey*, ::rtl::OUStringHash >
- m_aKeys;
- ::std::list< PPDConstraint > m_aConstraints;
+ hash_type m_aKeys;
+ value_type m_aOrderedKeys;
+ ::std::list< PPDConstraint > m_aConstraints;
// some identifying fields
- String m_aPrinterName;
- String m_aNickName;
+ String m_aPrinterName;
+ String m_aNickName;
// the full path of the PPD file
- String m_aFile;
+ String m_aFile;
// some basic attributes
- bool m_bColorDevice;
- bool m_bType42Capable;
- ULONG m_nLanguageLevel;
+ bool m_bColorDevice;
+ bool m_bType42Capable;
+ ULONG m_nLanguageLevel;
// shortcuts to important keys and their default values
// imageable area
- const PPDValue* m_pDefaultImageableArea;
- const PPDKey* m_pImageableAreas;
+ const PPDValue* m_pDefaultImageableArea;
+ const PPDKey* m_pImageableAreas;
// paper dimensions
- const PPDValue* m_pDefaultPaperDimension;
- const PPDKey* m_pPaperDimensions;
+ const PPDValue* m_pDefaultPaperDimension;
+ const PPDKey* m_pPaperDimensions;
// paper trays
- const PPDValue* m_pDefaultInputSlot;
- const PPDKey* m_pInputSlots;
+ const PPDValue* m_pDefaultInputSlot;
+ const PPDKey* m_pInputSlots;
// resolutions
- const PPDValue* m_pDefaultResolution;
- const PPDKey* m_pResolutions;
+ const PPDValue* m_pDefaultResolution;
+ const PPDKey* m_pResolutions;
// duplex commands
- const PPDValue* m_pDefaultDuplexType;
- const PPDKey* m_pDuplexTypes;
+ const PPDValue* m_pDefaultDuplexType;
+ const PPDKey* m_pDuplexTypes;
// fonts
- const PPDKey* m_pFontList;
+ const PPDKey* m_pFontList;
PPDParser( const String& rFile );
~PPDParser();
diff --git a/psprint/inc/psprint/printergfx.hxx b/psprint/inc/psprint/printergfx.hxx
index bf2b2116fd94..634082381fdd 100644
--- a/psprint/inc/psprint/printergfx.hxx
+++ b/psprint/inc/psprint/printergfx.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: printergfx.hxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.10 $
*
- * last change: $Author: pl $ $Date: 2002-11-13 20:15:39 $
+ * last change: $Author: hr $ $Date: 2003-03-26 14:24:02 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -342,10 +342,12 @@ public:
sal_Int16 nGlyphs, sal_Int16 nBytes,
const sal_Int32* pDeltaArray = NULL);
void PSComment (const sal_Char* pComment );
- void LicenceWarning (const Point& rPoint, const sal_Unicode* pStr,
+ void LicenseWarning (const Point& rPoint, const sal_Unicode* pStr,
sal_Int16 nLen, const sal_Int32* pDeltaArray);
void OnEndPage ();
+ void OnEndJob ();
+ void writeResources( osl::File* pFile, std::list< rtl::OString >& rSuppliedFonts, std::list< rtl::OString >& rNeededFonts );
PrintFontManager& GetFontMgr () { return mrFontMgr; }
void drawVerticalizedText (const Point& rPoint,
@@ -397,6 +399,16 @@ public:
void DrawPolyPolygon (sal_uInt32 nPoly,
const sal_uInt32 *pPolygonSize,
const Point** pPolygonList);
+ void DrawPolyLineBezier (sal_uInt32 nPoints,
+ const Point* pPath,
+ const BYTE* pFlgAry );
+ void DrawPolygonBezier (sal_uInt32 nPoints,
+ const Point* pPath,
+ const BYTE* pFlgAry);
+ void DrawPolyPolygonBezier (sal_uInt32 nPoly,
+ const sal_uInt32* pPoints,
+ const Point* const* pPtAry,
+ const BYTE* const* pFlgAry);
// eps
sal_Bool DrawEPS ( const Rectangle& rBoundingBox, void* pPtr, sal_uInt32 nSize);
diff --git a/psprint/inc/psprint/printerjob.hxx b/psprint/inc/psprint/printerjob.hxx
index cbc337e7cdcf..94ade789f58e 100644
--- a/psprint/inc/psprint/printerjob.hxx
+++ b/psprint/inc/psprint/printerjob.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: printerjob.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: pl $ $Date: 2002-11-13 20:15:41 $
+ * last change: $Author: hr $ $Date: 2003-03-26 14:24:02 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -75,11 +75,11 @@
#include <rtl/string.hxx>
#endif
-// forward declarations
-class SalGraphics;
-
namespace psp {
+// forward declarations
+class PrinterGfx;
+
class PrinterJob
{
@@ -87,6 +87,7 @@ private: // private data
rtl::OUString maSpoolDirName;
rtl::OUString maFileName; // empty: spool to command, else spool to named file
+ int mnFileMode;
osl::File* mpJobHeader;
osl::File* mpJobTrailer;
@@ -94,12 +95,16 @@ private: // private data
std::list< osl::File* > maPageList;
std::list< osl::File* > maHeaderList;
+ JobData m_aDocumentJobData;
JobData m_aLastJobData;
+ PrinterGfx* m_pGraphics;
sal_uInt32 mnResolution;
sal_uInt32 mnWidthPt;
sal_uInt32 mnHeightPt;
+ sal_uInt32 mnMaxWidthPt;
+ sal_uInt32 mnMaxHeightPt;
sal_uInt32 mnLMarginPt;
sal_uInt32 mnRMarginPt;
@@ -141,15 +146,29 @@ public:
PrinterJob ();
~PrinterJob ();
+ /* rFileName: if length is greater than 0 save resulting PostScript
+ * to named file.
+ * nMode: only meaningful when saving to file: if nonzero, try
+ * to impose the mode on the resulting file's inode; for nonexistant
+ * files use open, for existant files try a chmod
+ * rJobName: text to appear in the %%Title comment
+ * rAppName: text to appear in the %%Creator comment
+ * rSetupData: JobData that apply to this job
+ * pGraphics: the graphics used to print this job;
+ * this graphics must live until End/AbortJob has returned
+ */
sal_Bool StartJob (const rtl::OUString& rFileName,
+ int nMode,
const rtl::OUString& rJobName,
const rtl::OUString& rAppName,
- const JobData& rSetupData);
+ const JobData& rSetupData,
+ PrinterGfx* pGraphics
+ );
sal_Bool EndJob ();
sal_Bool AbortJob ();
- SalGraphics* StartPage (const JobData& rJobSetup, sal_Bool bNewJobData);
+ sal_Bool StartPage (const JobData& rJobSetup, sal_Bool bNewJobData);
sal_Bool EndPage ();
sal_uInt32 GetErrorCode ();
diff --git a/psprint/prj/build.lst b/psprint/prj/build.lst
index 31aa45950cb1..ac9b8e51b02c 100644
--- a/psprint/prj/build.lst
+++ b/psprint/prj/build.lst
@@ -1,8 +1,8 @@
-pp psprint : tools unotools NULL
+pp psprint : tools unotools cpputools jvmaccess NULL
pp psprint usr1 - all pp_mkout NULL
pp psprint\source\fontsubset nmake - all pp_fontsset NULL
pp psprint\source\printer nmake - u pp_printer NULL
pp psprint\source\fontmanager nmake - u pp_fontmgr NULL
pp psprint\source\helper nmake - u pp_helper NULL
pp psprint\source\printergfx nmake - u pp_printergfx NULL
-pp psprint\util nmake - all pp_util pp_fontmgr.u pp_fontsset.u pp_helper.u pp_printer.u pp_printergfx.u NULL
+pp psprint\util nmake - all pp_util pp_fontmgr.u pp_fontsset pp_helper.u pp_printer.u pp_printergfx.u NULL
diff --git a/psprint/source/fontsubset/sft.c b/psprint/source/fontsubset/sft.c
index ef1e87bd5c1f..aac3a06e7daa 100644
--- a/psprint/source/fontsubset/sft.c
+++ b/psprint/source/fontsubset/sft.c
@@ -2,9 +2,9 @@
*
* $RCSfile: sft.c,v $
*
- * $Revision: 1.18 $
+ * $Revision: 1.19 $
*
- * last change: $Author: pl $ $Date: 2002-12-09 17:44:39 $
+ * last change: $Author: hr $ $Date: 2003-03-26 14:24:04 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,7 +59,7 @@
*
************************************************************************/
-/* $Id: sft.c,v 1.18 2002-12-09 17:44:39 pl Exp $
+/* $Id: sft.c,v 1.19 2003-03-26 14:24:04 hr Exp $
* Sun Font Tools
*
* Author: Alexander Gelfenbain
@@ -1825,7 +1825,7 @@ int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, /*FO
"/FontType 3 def\n"
"/StrokeWidth 0 def\n";
- const char *h11 = "/FontName /%s def\n";
+ const char *h11 = "/FontName (%s) cvn def\n";
/*
const char *h12 = "%/UniqueID %d def\n";
@@ -1860,7 +1860,7 @@ int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, /*FO
"} bind def\n"
"currentdict end\n";
- const char *h41 = "/%s exch definefont pop\n";
+ const char *h41 = "(%s) cvn exch definefont pop\n";
if (!((nGlyphs > 0) && (nGlyphs <= 256))) return SF_GLYPHNUM;
@@ -2278,7 +2278,7 @@ int CreateT42FromTTGlyphs(TrueTypeFont *ttf,
fprintf(outf, "%%- Original font family: %s\n", ttf->family);
fprintf(outf, "%%- Original font sub-family: %s\n", ttf->subfamily);
fprintf(outf, "11 dict begin\n");
- fprintf(outf, "/FontName /%s def\n", psname);
+ fprintf(outf, "/FontName (%s) cvn def\n", psname);
fprintf(outf, "/PaintType 0 def\n");
fprintf(outf, "/FontMatrix [1 0 0 1 0 0] def\n");
fprintf(outf, "/FontBBox [%d %d %d %d] def\n", XUnits(UPEm, GetInt16(headP, 36, 1)), XUnits(UPEm, GetInt16(headP, 38, 1)), XUnits(UPEm, GetInt16(headP, 40, 1)), XUnits(UPEm, GetInt16(headP, 42, 1)));
diff --git a/psprint/source/helper/helper.cxx b/psprint/source/helper/helper.cxx
index 0efebd72d661..9908c7b25755 100644
--- a/psprint/source/helper/helper.cxx
+++ b/psprint/source/helper/helper.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: helper.cxx,v $
*
- * $Revision: 1.11 $
+ * $Revision: 1.12 $
*
- * last change: $Author: pl $ $Date: 2002-12-10 17:27:20 $
+ * last change: $Author: hr $ $Date: 2003-03-26 14:24:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -70,7 +70,7 @@
#include <tools/config.hxx>
#include <rtl/bootstrap.hxx>
#include <sal/config.h>
-#include <cpputools/jenv.hxx>
+#include "jvmaccess/javainfo.hxx"
namespace psp {
@@ -197,15 +197,30 @@ const ::rtl::OUString& psp::getFontPath()
// if no javarc (e.g. in setup) exists or it failed try the UDK method
if( ! aJREpath.getLength() )
{
- char* pJavaLib = getJavaRuntimeLib();
- if( pJavaLib && *pJavaLib )
+ rtl::OString aJavaLib;
+ try
+ {
+ rtl::OUString aLib;
+ if (osl::FileBase::getSystemPathFromFileURL(
+ jvmaccess::JavaInfo::createBestInfo(true).
+ getRuntimeLibLocation(),
+ aLib)
+ == osl::FileBase::E_None)
+ aLib.convertToString(
+ &aJavaLib, osl_getThreadTextEncoding(),
+ RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
+ | RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR);
+ }
+ catch (jvmaccess::JavaInfo::InitException &)
+ {}
+
+ if (aJavaLib.getLength() != 0)
{
- rtl::OString aTestPath( pJavaLib );
sal_Int32 nIndex;
- while( ( nIndex = aTestPath.lastIndexOf( '/' ) ) != -1 )
+ while( ( nIndex = aJavaLib.lastIndexOf( '/' ) ) != -1 )
{
- aTestPath = aTestPath.copy( 0, nIndex );
- rtl::OString aTmpPath = aTestPath;
+ aJavaLib = aJavaLib.copy( 0, nIndex );
+ rtl::OString aTmpPath = aJavaLib;
aTmpPath += "/lib/fonts";
if( access( aTmpPath.getStr(), R_OK ) == 0 )
{
@@ -214,7 +229,6 @@ const ::rtl::OUString& psp::getFontPath()
}
}
}
- free( pJavaLib );
}
if( aJREpath.getLength() )
diff --git a/psprint/source/helper/ppdparser.cxx b/psprint/source/helper/ppdparser.cxx
index 37ca7321e48f..ac6ed16ca1d4 100644
--- a/psprint/source/helper/ppdparser.cxx
+++ b/psprint/source/helper/ppdparser.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: ppdparser.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: pl $ $Date: 2002-11-13 20:15:43 $
+ * last change: $Author: hr $ $Date: 2003-03-26 14:24:05 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -273,7 +273,7 @@ PPDParser::PPDParser( const String& rFile ) :
parse( aLines );
#ifdef __DEBUG
fprintf( stderr, "acquired %d Keys from PPD %s:\n", m_aKeys.Count(), BSTRING( m_aFile ).GetBuffer() );
- for( ::std::hash_map< OUString, PPDKey*, OUStringHash >::const_iterator it = m_aKeys.begin(); it != m_aKeys.end(); ++it )
+ for( PPDParser::hash_type::const_iterator it = m_aKeys.begin(); it != m_aKeys.end(); ++it )
{
const PPDKey* pKey = it->second;
char* pSetupType = "<unknown>";
@@ -380,21 +380,24 @@ PPDParser::PPDParser( const String& rFile ) :
PPDParser::~PPDParser()
{
- for( ::std::hash_map< OUString, PPDKey*, OUStringHash >::iterator it = m_aKeys.begin(); it != m_aKeys.end(); ++it )
+ for( PPDParser::hash_type::iterator it = m_aKeys.begin(); it != m_aKeys.end(); ++it )
delete it->second;
}
+void PPDParser::insertKey( const String& rKey, PPDKey* pKey )
+{
+ m_aKeys[ rKey ] = pKey;
+ m_aOrderedKeys.push_back( pKey );
+}
+
const PPDKey* PPDParser::getKey( int n ) const
{
- ::std::hash_map< OUString, PPDKey*, OUStringHash >::const_iterator it;
- for( it = m_aKeys.begin(); it != m_aKeys.end() && n--; ++it )
- ;
- return it != m_aKeys.end() ? it->second : NULL;
+ return (n < m_aOrderedKeys.size() && n >= 0) ? m_aOrderedKeys[n] : NULL;
}
const PPDKey* PPDParser::getKey( const String& rKey ) const
{
- ::std::hash_map< OUString, PPDKey*, OUStringHash >::const_iterator it = m_aKeys.find( rKey );
+ PPDParser::hash_type::const_iterator it = m_aKeys.find( rKey );
return it != m_aKeys.end() ? it->second : NULL;
}
@@ -412,7 +415,7 @@ void PPDParser::parse( ::std::list< String >& rLines )
PPDKey* pKey = NULL;
::std::list< String >::iterator line = rLines.begin();
- ::std::hash_map< OUString, PPDKey*, OUStringHash >::const_iterator keyit;
+ PPDParser::hash_type::const_iterator keyit;
while( line != rLines.end() )
{
String aCurrentLine( *line );
@@ -443,6 +446,8 @@ void PPDParser::parse( ::std::list< String >& rLines )
}
else if( aKey.EqualsAscii( "UIConstraints" ) || aKey.EqualsAscii( "NonUIConstraints" ) )
continue; // parsed in pass 2
+ else if( aKey.EqualsAscii( "CustomPageSize" ) ) // currently not handled
+ continue;
// default values are parsed in pass 2
if( aKey.CompareToAscii( "Default", 7 ) == COMPARE_EQUAL )
@@ -459,7 +464,7 @@ void PPDParser::parse( ::std::list< String >& rLines )
if( keyit == m_aKeys.end() )
{
pKey = new PPDKey( aKey );
- m_aKeys[ aKey ] = pKey;
+ insertKey( aKey, pKey );
}
else
pKey = keyit->second;
@@ -482,7 +487,7 @@ void PPDParser::parse( ::std::list< String >& rLines )
{
pKey->m_aQueryValue = *pValue;
pKey->m_bQueryValue = true;
- pKey->m_aValues.erase( pValue->m_aOption );
+ pKey->eraseValue( pValue->m_aOption );
}
if( nPos == STRING_NOTFOUND )
@@ -582,7 +587,7 @@ void PPDParser::parse( ::std::list< String >& rLines )
pKey = new PPDKey( aKey );
PPDValue* pValue = pKey->insertValue( aOption );
pValue->m_eType = eInvocation; // or what ?
- m_aKeys[ aKey ] = pKey;
+ insertKey( aKey, pKey );
}
}
}
@@ -610,7 +615,7 @@ void PPDParser::parseOpenUI( const String& rLine )
aKey = GetCommandLineToken( 1, aKey );
aKey.Erase( 0, 1 );
- ::std::hash_map< OUString, PPDKey*, OUStringHash >::const_iterator keyit = m_aKeys.find( aKey );
+ PPDParser::hash_type::const_iterator keyit = m_aKeys.find( aKey );
PPDKey* pKey;
if( keyit == m_aKeys.end() )
{
@@ -647,11 +652,11 @@ void PPDParser::parseOrderDependency( const String& rLine )
aKey.Erase( 0, 1 );
PPDKey* pKey;
- ::std::hash_map< OUString, PPDKey*, OUStringHash >::const_iterator keyit = m_aKeys.find( aKey );
+ PPDParser::hash_type::const_iterator keyit = m_aKeys.find( aKey );
if( keyit == m_aKeys.end() )
{
pKey = new PPDKey( aKey );
- m_aKeys [ aKey ] = pKey;
+ insertKey( aKey, pKey );
}
else
pKey = keyit->second;
@@ -929,14 +934,19 @@ void PPDParser::getResolutionFromString(
{
int nPos = 0, nDPIPos;
+ rXRes = rYRes = 300;
+
nDPIPos = rString.SearchAscii( "dpi" );
- if( ( nPos = rString.Search( 'x' ) ) != STRING_NOTFOUND )
+ if( nDPIPos != STRING_NOTFOUND )
{
- rXRes = rString.Copy( 0, nPos ).ToInt32();
- rYRes = rString.GetToken( 1, 'x' ).Erase( nDPIPos - nPos - 1 ).ToInt32();
- return;
+ if( ( nPos = rString.Search( 'x' ) ) != STRING_NOTFOUND )
+ {
+ rXRes = rString.Copy( 0, nPos ).ToInt32();
+ rYRes = rString.GetToken( 1, 'x' ).Erase( nDPIPos - nPos - 1 ).ToInt32();
+ }
+ else
+ rXRes = rYRes = rString.Copy( 0, nDPIPos ).ToInt32();
}
- rXRes = rYRes = rString.Copy( 0, nDPIPos ).ToInt32();
}
void PPDParser::getDefaultResolution( int& rXRes, int& rYRes ) const
@@ -1101,9 +1111,7 @@ PPDKey::~PPDKey()
const PPDValue* PPDKey::getValue( int n ) const
{
- for( ::std::hash_map< OUString, PPDValue, OUStringHash >::const_iterator it = m_aValues.begin(); it != m_aValues.end() && n--; ++it )
- ;
- return it != m_aValues.end() ? &it->second : NULL;
+ return (n < m_aOrderedValues.size() && n >= 0) ? m_aOrderedValues[n] : NULL;
}
// -------------------------------------------------------------------
@@ -1111,12 +1119,31 @@ const PPDValue* PPDKey::getValue( int n ) const
const PPDValue* PPDKey::getValue( const String& rOption ) const
{
const PPDValue* pValue = NULL;
- ::std::hash_map< OUString, PPDValue, OUStringHash >::const_iterator it = m_aValues.find( rOption );
+ PPDKey::hash_type::const_iterator it = m_aValues.find( rOption );
return it != m_aValues.end() ? &it->second : NULL;
}
// -------------------------------------------------------------------
+void PPDKey::eraseValue( const String& rOption )
+{
+ PPDKey::hash_type::iterator it = m_aValues.find( rOption );
+ if( it == m_aValues.end() )
+ return;
+
+ for( PPDKey::value_type::iterator vit = m_aOrderedValues.begin(); vit != m_aOrderedValues.end(); ++vit )
+ {
+ if( *vit == &(it->second ) )
+ {
+ m_aOrderedValues.erase( vit );
+ break;
+ }
+ }
+ m_aValues.erase( it );
+}
+
+// -------------------------------------------------------------------
+
PPDValue* PPDKey::insertValue( const String& rOption )
{
if( m_aValues.find( rOption ) != m_aValues.end() )
@@ -1125,7 +1152,9 @@ PPDValue* PPDKey::insertValue( const String& rOption )
PPDValue aValue;
aValue.m_aOption = rOption;
m_aValues[ rOption ] = aValue;
- return &(m_aValues.find( rOption )->second);
+ PPDValue* pValue = &m_aValues[rOption];
+ m_aOrderedValues.push_back( pValue );
+ return pValue;
}
// -------------------------------------------------------------------
diff --git a/psprint/source/printer/printerinfomanager.cxx b/psprint/source/printer/printerinfomanager.cxx
index 059986b4e1be..2de170e6c422 100644
--- a/psprint/source/printer/printerinfomanager.cxx
+++ b/psprint/source/printer/printerinfomanager.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: printerinfomanager.cxx,v $
*
- * $Revision: 1.14 $
+ * $Revision: 1.15 $
*
- * last change: $Author: pl $ $Date: 2002-11-05 14:07:08 $
+ * last change: $Author: hr $ $Date: 2003-03-26 14:24:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -119,7 +119,7 @@ bool PrinterInfoManager::checkPrintersChanged()
}
else
{
- FileStatus aStatus( FileStatusMask_All );
+ FileStatus aStatus( FileStatusMask_ModifyTime );
if( aItem.getFileStatus( aStatus ) )
bChanged = true; // unlikely but not impossible
else
@@ -256,7 +256,7 @@ void PrinterInfoManager::initialize()
FileBase::getFileURLFromSystemPath( aFile.PathToFileName(), aUniPath );
- FileStatus aStatus( FileStatusMask_All );
+ FileStatus aStatus( FileStatusMask_ModifyTime );
DirectoryItem aItem;
// setup WatchFile list
@@ -915,7 +915,7 @@ struct SystemCommandParameters
static const struct SystemCommandParameters aParms[] =
{
-#ifdef LINUX
+#if defined(LINUX) || defined(NETBSD) || defined(FREEBSD)
{ "/usr/sbin/lpc status", "lpr -P \"(PRINTER)\"", "", ":", 0 },
{ "lpc status", "lpr -P \"(PRINTER)\"", "", ":", 0 },
{ "LANG=C;LC_ALL=C;export LANG LC_ALL;lpstat -s", "lp -d \"(PRINTER)\"", "system for ", ": ", 1 }
diff --git a/psprint/source/printergfx/bitmap_gfx.cxx b/psprint/source/printergfx/bitmap_gfx.cxx
index 7a9cd6acb83c..e3390a240860 100644
--- a/psprint/source/printergfx/bitmap_gfx.cxx
+++ b/psprint/source/printergfx/bitmap_gfx.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: bitmap_gfx.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: hr $ $Date: 2002-02-21 14:29:49 $
+ * last change: $Author: hr $ $Date: 2003-03-26 14:24:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -59,8 +59,6 @@
*
************************************************************************/
-#include <string.h>
-
#ifndef _PSPRINT_PRINTERGFX_HXX_
#include <psprint/printergfx.hxx>
#endif
diff --git a/psprint/source/printergfx/common_gfx.cxx b/psprint/source/printergfx/common_gfx.cxx
index e37cad17cc87..223e42b83021 100644
--- a/psprint/source/printergfx/common_gfx.cxx
+++ b/psprint/source/printergfx/common_gfx.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: common_gfx.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: pl $ $Date: 2002-11-14 12:25:45 $
+ * last change: $Author: hr $ $Date: 2003-03-26 14:24:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -83,6 +83,9 @@
#include <tools/debug.hxx>
#include <tools/color.hxx>
+#ifndef _POLY_HXX
+#include <tools/poly.hxx>
+#endif
using namespace psp ;
@@ -221,8 +224,6 @@ PrinterGfx::Clear()
mbColor = sal_True;
mnTextAngle = 0;
- maPS1Font.clear();
- maPS3Font.clear();
maClipRegion.clear();
maGraphicsStack.clear();
maGraphicsStack.push_back( GraphicsStatus() );
@@ -571,10 +572,201 @@ PrinterGfx::DrawPolyPolygon (sal_uInt32 nPoly, const sal_uInt32* pSizes, const P
}
/*
- * postscript generating routines
+ * Bezier Polygon Drawing methods.
*/
void
+PrinterGfx::DrawPolyLineBezier (sal_uInt32 nPoints, const Point* pPath, const BYTE* pFlgAry)
+{
+ const sal_uInt32 nBezString = 1024;
+ sal_Char pString[nBezString];
+
+ if ( maLineColor.Is() && nPoints && pPath )
+ {
+ PSSetColor (maLineColor);
+ PSSetColor ();
+ PSSetLineWidth ();
+
+ if (pFlgAry[0] != POLY_NORMAL) //There must be a starting point to moveto
+ {
+ return;
+ }
+ else
+ {
+ snprintf(pString, nBezString, "%i %i moveto\n", pPath[0].X(), pPath[0].Y());
+ WritePS(mpPageBody, pString);
+ }
+
+ // Handle the drawing of mixed lines mixed with curves
+ // - a normal point followed by a normal point is a line
+ // - a normal point followed by 2 control points and a normal point is a curve
+ for (int i=1; i<nPoints;)
+ {
+ if (pFlgAry[i+1] != POLY_CONTROL) //If the next point is a POLY_NORMAL, we're drawing a line
+ {
+ if (i+1 >= nPoints) return; //Make sure we don't pass the end of the array
+ snprintf(pString, nBezString, "%i %i lineto\n", pPath[i].X(), pPath[i].Y());
+ i++;
+ }
+ else //Otherwise we're drawing a spline
+ {
+ if (i+3 >= nPoints) return; //Make sure we don't pass the end of the array
+ snprintf(pString, nBezString, "%i %i %i %i %i %i curveto\n",
+ pPath[i+1].X(), pPath[i+1].Y(),
+ pPath[i+2].X(), pPath[i+2].Y(),
+ pPath[i+3].X(), pPath[i+3].Y());
+ i+=3;
+ }
+ WritePS(mpPageBody, pString);
+ }
+ }
+
+ // if eofill and stroke, save the current path
+ if( maFillColor.Is() && maLineColor.Is())
+ PSGSave();
+
+ // first draw area
+ if( maFillColor.Is() )
+ {
+ PSSetColor (maFillColor);
+ PSSetColor ();
+ WritePS (mpPageBody, "eofill\n");
+ }
+
+ // restore the current path
+ if( maFillColor.Is() && maLineColor.Is())
+ PSGRestore();
+
+ // now draw outlines
+ if( maLineColor.Is() )
+ {
+ PSSetColor (maLineColor);
+ PSSetColor ();
+ PSSetLineWidth ();
+ WritePS (mpPageBody, "stroke\n");
+ }
+}
+
+void
+PrinterGfx::DrawPolygonBezier (sal_uInt32 nPoints, const Point* pPath, const BYTE* pFlgAry)
+{
+ const sal_uInt32 nBezString = 1024;
+ sal_Char pString[nBezString];
+ // premature end of operation
+ if (!(nPoints > 1) || (pPath == NULL) || !(maFillColor.Is() || maLineColor.Is()))
+ return;
+
+ snprintf(pString, nBezString, "%i %i moveto\n", pPath[0].X(), pPath[0].Y());
+ WritePS(mpPageBody, pString); //Move to the starting point for the PolyPoygon
+ for (int i=1; i < nPoints;)
+ {
+ if (pFlgAry[i] != POLY_CONTROL)
+ {
+ snprintf(pString, nBezString, "%i %i lineto\n", pPath[i].X(), pPath[i].Y());
+ WritePS(mpPageBody, pString);
+ i++;
+ }
+ else
+ {
+ if (i+2 >= nPoints)
+ return; //Error: wrong sequence of contol/normal points somehow
+ if ((pFlgAry[i] == POLY_CONTROL) && (pFlgAry[i+1] == POLY_CONTROL) &&
+ (pFlgAry[i+2] != POLY_CONTROL))
+ {
+ snprintf(pString, nBezString, "%i %i %i %i %i %i curveto\n",
+ pPath[i].X(), pPath[i].Y(),
+ pPath[i+1].X(), pPath[i+1].Y(),
+ pPath[i+2].X(), pPath[i+2].Y());
+ WritePS(mpPageBody, pString);
+ }
+ else
+ {
+ fprintf(stderr, "Strange output\n");
+ }
+ i+=3;
+ }
+ }
+
+ // if fill and stroke, save the current path
+ if( maFillColor.Is() && maLineColor.Is())
+ PSGSave();
+
+ if (maFillColor.Is ())
+ {
+ PSSetColor (maFillColor);
+ PSSetColor ();
+ WritePS (mpPageBody, "eofill\n");
+ }
+
+ // restore the current path
+ if( maFillColor.Is() && maLineColor.Is())
+ PSGRestore();
+}
+
+void
+PrinterGfx::DrawPolyPolygonBezier (sal_uInt32 nPoly, const sal_uInt32 * pPoints, const Point* const * pPtAry, const BYTE* const* pFlgAry)
+{
+ const sal_uInt32 nBezString = 1024;
+ sal_Char pString[nBezString];
+ if ( !nPoly || !pPtAry || !pPoints || !(maFillColor.Is() || maLineColor.Is()))
+ return;
+
+
+ for (int i=0; i<nPoly;i++)
+ {
+ sal_uInt32 nPoints = pPoints[i];
+ snprintf(pString, nBezString, "%i %i moveto\n", pPtAry[i][0].X(), pPtAry[i][0].Y()); //Move to the starting point
+ WritePS(mpPageBody, pString);
+ for (int j=1; j < nPoints;)
+ {
+ if (pFlgAry[i][j] != POLY_CONTROL)
+ {
+ snprintf(pString, nBezString, "%i %i lineto\n", pPtAry[i][j].X(), pPtAry[i][j].Y());
+ WritePS(mpPageBody, pString);
+ j++;
+ }
+ else
+ {
+ if (j+2 >= nPoints)
+ return; //Error: wrong sequence of contol/normal points somehow
+ if ((pFlgAry[i][j] == POLY_CONTROL) && (pFlgAry[i][j+1] == POLY_CONTROL) && (pFlgAry[i][j+2] != POLY_CONTROL))
+ {
+ snprintf(pString, nBezString, "%i %i %i %i %i %i curveto\n",
+ pPtAry[i][j].X(), pPtAry[i][j].Y(),
+ pPtAry[i][j+1].X(), pPtAry[i][j+1].Y(),
+ pPtAry[i][j+2].X(), pPtAry[i][j+2].Y());
+ WritePS(mpPageBody, pString);
+ }
+ else
+ {
+ fprintf(stderr, "Strange output\n");
+ }
+ j+=3;
+ }
+ }
+ }
+
+ // if fill and stroke, save the current path
+ if( maFillColor.Is() && maLineColor.Is())
+ PSGSave();
+
+ if (maFillColor.Is ())
+ {
+ PSSetColor (maFillColor);
+ PSSetColor ();
+ WritePS (mpPageBody, "eofill\n");
+ }
+
+ // restore the current path
+ if( maFillColor.Is() && maLineColor.Is())
+ PSGRestore();
+}
+
+
+/*
+ * postscript generating routines
+ */
+void
PrinterGfx::PSGSave ()
{
WritePS (mpPageBody, "gsave\n" );
@@ -677,19 +869,21 @@ PrinterGfx::PSSetFont ()
psp::GlyphSet::GetReencodedFontName (rCurrent.maEncoding,
rCurrent.maFont);
- nChar += psp::appendStr ("/", pSetFont + nChar);
+ nChar += psp::appendStr ("(", pSetFont + nChar);
nChar += psp::appendStr (aReencodedFont.getStr(),
pSetFont + nChar);
- nChar += psp::appendStr (" ", pSetFont + nChar);
- nChar += psp::appendStr (" findfont ", pSetFont + nChar);
+ nChar += psp::appendStr (") cvn findfont ",
+ pSetFont + nChar);
}
else
// tt based fonts mustn't reencode, the encoding is implied by the fontname
// same for symbol type1 fonts, dont try to touch them
{
- nChar += psp::appendStr ("/", pSetFont + nChar);
- nChar += psp::appendStr (rCurrent.maFont.getStr(), pSetFont + nChar);
- nChar += psp::appendStr (" findfont ", pSetFont + nChar);
+ nChar += psp::appendStr ("(", pSetFont + nChar);
+ nChar += psp::appendStr (rCurrent.maFont.getStr(),
+ pSetFont + nChar);
+ nChar += psp::appendStr (") cvn findfont ",
+ pSetFont + nChar);
}
nChar += psp::getValueOf (nTextWidth, pSetFont + nChar);
@@ -1006,29 +1200,57 @@ PrinterGfx::PSComment( const sal_Char* pComment )
sal_Bool
PrinterGfx::DrawEPS( const Rectangle& rBoundingBox, void* pPtr, sal_uInt32 nSize )
{
+ if( nSize == 0 )
+ return sal_True;
+
sal_Bool bSuccess = sal_False;
// first search the BoundingBox of the EPS data
SvMemoryStream aStream( pPtr, nSize, STREAM_READ );
aStream.Seek( STREAM_SEEK_TO_BEGIN );
ByteString aLine;
+
+ ByteString aDocTitle;
double fLeft = 0, fRight = 0, fTop = 0, fBottom = 0;
- while( ! aStream.IsEof() && fLeft == 0 && fRight == 0 && fTop == 0 && fBottom == 0 )
+ bool bEndComments = false;
+ while( ! aStream.IsEof()
+ && ( ( fLeft == 0 && fRight == 0 && fTop == 0 && fBottom == 0 ) ||
+ ( aDocTitle.Len() == 0 && bEndComments == false ) )
+ )
{
aStream.ReadLine( aLine );
- if( aLine.CompareIgnoreCaseToAscii( "%%BoundingBox:", 14 ) == COMPARE_EQUAL )
+ if( aLine.Len() > 1 && aLine.GetChar( 0 ) == '%' )
{
- aLine = WhitespaceToSpace( aLine.GetToken( 1, ':' ) );
- if( aLine.Len() && aLine.Search( "atend" ) == STRING_NOTFOUND )
+ char cChar = aLine.GetChar(1);
+ if( cChar == '%' )
{
- fLeft = StringToDouble( GetCommandLineToken( 0, aLine ) );
- fBottom = StringToDouble( GetCommandLineToken( 1, aLine ) );
- fRight = StringToDouble( GetCommandLineToken( 2, aLine ) );
- fTop = StringToDouble( GetCommandLineToken( 3, aLine ) );
+ if( aLine.CompareIgnoreCaseToAscii( "%%BoundingBox:", 14 ) == COMPARE_EQUAL )
+ {
+ aLine = WhitespaceToSpace( aLine.GetToken( 1, ':' ) );
+ if( aLine.Len() && aLine.Search( "atend" ) == STRING_NOTFOUND )
+ {
+ fLeft = StringToDouble( GetCommandLineToken( 0, aLine ) );
+ fBottom = StringToDouble( GetCommandLineToken( 1, aLine ) );
+ fRight = StringToDouble( GetCommandLineToken( 2, aLine ) );
+ fTop = StringToDouble( GetCommandLineToken( 3, aLine ) );
+ }
+ }
+ else if( aLine.CompareIgnoreCaseToAscii( "%%Title:", 8 ) == COMPARE_EQUAL )
+ aDocTitle = WhitespaceToSpace( aLine.Copy( 8 ) );
+ else if( aLine.CompareIgnoreCaseToAscii( "%%EndComments", 13 ) == COMPARE_EQUAL )
+ bEndComments = true;
}
+ else if( cChar == ' ' || cChar == '\t' || cChar == '\r' || cChar == '\n' )
+ bEndComments = true;
}
+ else
+ bEndComments = true;
}
+ static sal_uInt16 nEps = 0;
+ if( ! aDocTitle.Len() )
+ aDocTitle = ByteString::CreateFromInt32( (sal_Int32)(nEps++) );
+
if( fLeft != fRight && fTop != fBottom )
{
double fScaleX = (double)rBoundingBox.GetWidth()/(fRight-fLeft);
@@ -1059,11 +1281,21 @@ PrinterGfx::DrawEPS( const Rectangle& rBoundingBox, void* pPtr, sal_uInt32 nSize
PSTranslate( aTranslatePoint );
PSScale( fScaleX, fScaleY );
+ // DSC requires BeginDocument
+ WritePS( mpPageBody, "%%BeginDocument: " );
+ WritePS( mpPageBody, aDocTitle );
+ WritePS( mpPageBody, "\n" );
+
// write the EPS data
sal_uInt64 nOutLength;
mpPageBody->write( pPtr, nSize, nOutLength );
bSuccess = nOutLength == nSize;
+ // corresponding EndDocument
+ if( ((char*)pPtr)[ nSize-1 ] != '\n' )
+ WritePS( mpPageBody, "\n" );
+ WritePS( mpPageBody, "%%EndDocument\n" );
+
// clean up EPS
WritePS( mpPageBody,
"count op_count sub {pop} repeat\n"
diff --git a/psprint/source/printergfx/glyphset.cxx b/psprint/source/printergfx/glyphset.cxx
index c551efb35ab2..f2966327f7e8 100644
--- a/psprint/source/printergfx/glyphset.cxx
+++ b/psprint/source/printergfx/glyphset.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: glyphset.cxx,v $
*
- * $Revision: 1.15 $
+ * $Revision: 1.16 $
*
- * last change: $Author: pl $ $Date: 2002-11-13 15:32:53 $
+ * last change: $Author: hr $ $Date: 2003-03-26 14:24:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -483,13 +483,13 @@ GlyphSet::PSDefineReencodedFont (osl::File* pOutFile, sal_Int32 nGlyphSetID)
sal_Char pEncodingVector [256];
sal_Int32 nSize = 0;
- nSize += psp::appendStr ("/", pEncodingVector + nSize);
+ nSize += psp::appendStr ("(", pEncodingVector + nSize);
nSize += psp::appendStr (GetReencodedFontName(nGlyphSetID),
pEncodingVector + nSize);
- nSize += psp::appendStr (" /", pEncodingVector + nSize);
+ nSize += psp::appendStr (") cvn (", pEncodingVector + nSize);
nSize += psp::appendStr (maBaseName.getStr(),
pEncodingVector + nSize);
- nSize += psp::appendStr (" ", pEncodingVector + nSize);
+ nSize += psp::appendStr (") cvn ", pEncodingVector + nSize);
nSize += psp::appendStr (GetGlyphSetEncodingName(nGlyphSetID),
pEncodingVector + nSize);
nSize += psp::appendStr (" psp_definefont\n",
@@ -804,7 +804,7 @@ GlyphSet::PSUploadEncoding(osl::File* pOutFile, PrinterGfx &rGfx)
}
sal_Bool
-GlyphSet::PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAsType42 )
+GlyphSet::PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAsType42, std::list< rtl::OString >& rSuppliedFonts )
{
// only for truetype fonts
if (meBaseType != fonttype::TrueType)
@@ -862,6 +862,7 @@ GlyphSet::PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAsType42 )
pTTGlyphMapping, pEncoding, (*aCharSet).size(),
0 /* 0 = horizontal, 1 = vertical */ );
fprintf( pTmpFile, "%%%%EndResource\n" );
+ rSuppliedFonts.push_back( aCharSetName );
}
// loop thru all the font glyph subsets
@@ -895,6 +896,7 @@ GlyphSet::PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAsType42 )
pTTGlyphMapping, pEncoding, (*aGlyphSet).size(),
0 /* 0 = horizontal, 1 = vertical */ );
fprintf( pTmpFile, "%%%%EndResource\n" );
+ rSuppliedFonts.push_back( aGlyphSetName );
}
// copy the file into the page header
diff --git a/psprint/source/printergfx/glyphset.hxx b/psprint/source/printergfx/glyphset.hxx
index 813c5ffe8c77..fed76ed06d6b 100644
--- a/psprint/source/printergfx/glyphset.hxx
+++ b/psprint/source/printergfx/glyphset.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: glyphset.hxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: cp $ $Date: 2002-07-22 13:52:03 $
+ * last change: $Author: hr $ $Date: 2003-03-26 14:24:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -166,7 +166,7 @@ public:
sal_Int16 nLen,
const sal_Int32* pDeltaArray );
sal_Bool PSUploadEncoding(osl::File* pOutFile, PrinterGfx &rGfx);
- sal_Bool PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAsType42 );
+ sal_Bool PSUploadFont (osl::File& rOutFile, PrinterGfx &rGfx, bool bAsType42, std::list< rtl::OString >& rSuppliedFonts );
};
diff --git a/psprint/source/printergfx/printerjob.cxx b/psprint/source/printergfx/printerjob.cxx
index eaae5ac20546..06c90ce9903b 100644
--- a/psprint/source/printergfx/printerjob.cxx
+++ b/psprint/source/printergfx/printerjob.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: printerjob.cxx,v $
*
- * $Revision: 1.20 $
+ * $Revision: 1.21 $
*
- * last change: $Author: pl $ $Date: 2002-11-13 20:15:46 $
+ * last change: $Author: hr $ $Date: 2003-03-26 14:24:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -74,12 +74,18 @@
#ifndef _PSPRINT_PRINTERINFOMANAGER_HXX_
#include <psprint/printerinfomanager.hxx>
#endif
+#ifndef _PSPRINT_PRINTERGFX_HXX_
+#include <psprint/printergfx.hxx>
+#endif
#ifndef _PSPRINT_PRINTERUTIL_HXX_
#include <psputil.hxx>
#endif
#ifndef _RTL_USTRING_HXX_
#include <rtl/ustring.hxx>
#endif
+#ifndef _RTL_STRBUF_HXX_
+#include <rtl/strbuf.hxx>
+#endif
#ifndef _OSL_THREAD_H_
#include <osl/thread.h>
#endif
@@ -93,6 +99,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <fcntl.h>
#include <unistd.h>
#include <pwd.h>
@@ -280,8 +287,12 @@ getUserName (char* pName, int nSize)
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)
{
@@ -405,14 +416,20 @@ getLocalTime(sal_Char* pBuffer, sal_uInt32 nBufSize)
sal_Bool
PrinterJob::StartJob (
const rtl::OUString& rFileName,
+ int nMode,
const rtl::OUString& rJobName,
const rtl::OUString& rAppName,
- const JobData& rSetupData)
+ const JobData& rSetupData,
+ PrinterGfx* pGraphics
+ )
{
+ mnMaxWidthPt = mnMaxHeightPt = 0;
+ m_pGraphics = pGraphics;
InitPaperSize (rSetupData);
// create file container for document header and trailer
maFileName = rFileName;
+ mnFileMode = nMode;
maSpoolDirName = createSpoolDir ();
rtl::OUString aExt = rtl::OUString::createFromAscii (".ps");
@@ -420,27 +437,16 @@ PrinterJob::StartJob (
mpJobTrailer = CreateSpoolFile (rtl::OUString::createFromAscii("psp_tail"), aExt);
// write document header according to Document Structuring Conventions (DSC)
- WritePS (mpJobHeader, "%!PS-Adobe-3.0\n");
+ WritePS (mpJobHeader,
+ "%!PS-Adobe-3.0\n"
+ "%%BoundingBox: (atend)\n" );
- // BoundingBox
- sal_Char pBBox [256];
- sal_Int32 nChar = 0;
-
- nChar = psp::appendStr ("%%BoundingBox: ", pBBox);
- nChar += psp::getValueOf (0, pBBox + nChar);
- nChar += psp::appendStr (" ", pBBox + nChar);
- nChar += psp::getValueOf (0, pBBox + nChar);
- nChar += psp::appendStr (" ", pBBox + nChar);
- nChar += psp::getValueOf (mnWidthPt, pBBox + nChar);
- nChar += psp::appendStr (" ", pBBox + nChar);
- nChar += psp::getValueOf (mnHeightPt, pBBox + nChar);
- nChar += psp::appendStr ("\n", pBBox + nChar);
-
- WritePS (mpJobHeader, pBBox);
+ rtl::OUString aFilterWS;
// Creator (this application)
+ aFilterWS = WhitespaceToSpace( rAppName, FALSE );
WritePS (mpJobHeader, "%%Creator: ");
- WritePS (mpJobHeader, rAppName);
+ WritePS (mpJobHeader, aFilterWS);
WritePS (mpJobHeader, "\n");
// For (user name)
@@ -458,8 +464,9 @@ PrinterJob::StartJob (
WritePS (mpJobHeader, getLocalTime(pCreationDate, sizeof(pCreationDate)));
// Document Title
+ aFilterWS = WhitespaceToSpace( rJobName, FALSE );
WritePS (mpJobHeader, "%%Title: ");
- WritePS (mpJobHeader, rJobName);
+ WritePS (mpJobHeader, aFilterWS);
WritePS (mpJobHeader, "\n");
// Language Level
@@ -476,30 +483,35 @@ PrinterJob::StartJob (
WritePS (mpJobHeader, "%%PageOrder: Ascend\n");
WritePS (mpJobHeader, "%%EndComments\n");
+ // write Prolog
writeProlog (mpJobHeader);
// mark last job setup as not set
m_aLastJobData.m_pParser = NULL;
m_aLastJobData.m_aContext.setParser( NULL );
-// writeSetup( mpJobHeader, rSetupData );
-
return sal_True;
}
sal_Bool
PrinterJob::EndJob ()
{
- // write document trailer according to Document Structuring Conventions (DSC)
- sal_Char pPageNr [16];
- sal_Int32 nSz = getValueOf((sal_Int32)maPageList.size(), pPageNr);
- pPageNr [nSz] = '\0';
+ // write document setup (done here because it
+ // includes the accumulated fonts
+ writeSetup( mpJobHeader, m_aDocumentJobData );
+ m_pGraphics->OnEndJob();
- WritePS (mpJobTrailer, "%%Trailer\n");
- WritePS (mpJobTrailer, "%%Pages: ");
- WritePS (mpJobTrailer, pPageNr);
- WritePS (mpJobTrailer, "\n");
- WritePS (mpJobTrailer, "%%EOF\n");
+ // write document trailer according to Document Structuring Conventions (DSC)
+ rtl::OStringBuffer aTrailer(512);
+ aTrailer.append( "%%Trailer\n" );
+ aTrailer.append( "%%BoundingBox: 0 0 " );
+ aTrailer.append( (sal_Int32)mnMaxWidthPt );
+ aTrailer.append( " " );
+ aTrailer.append( (sal_Int32)mnMaxHeightPt );
+ aTrailer.append( "\n%%Pages: " );
+ aTrailer.append( (sal_Int32)maPageList.size() );
+ aTrailer.append( "\n%%EOF\n" );
+ WritePS (mpJobTrailer, aTrailer.getStr());
/*
* spool the set of files to their final destination, this is U**X dependent
@@ -514,8 +526,25 @@ PrinterJob::EndJob ()
{
const rtl::OString aFileName = rtl::OUStringToOString (maFileName,
osl_getThreadTextEncoding());
+ if( mnFileMode )
+ {
+ int nFile = open( aFileName.getStr(), O_CREAT | O_EXCL | O_RDWR, mnFileMode );
+ if( nFile != -1 )
+ {
+ pDestFILE = fdopen( nFile, "w" );
+ if( pDestFILE == NULL )
+ {
+ close( nFile );
+ unlink( aFileName.getStr() );
+ return sal_False;
+ }
+ }
+ else
+ chmod( aFileName.getStr(), mnFileMode );
+ }
+ if (pDestFILE == NULL)
+ pDestFILE = fopen (aFileName.getStr(), "w");
- pDestFILE = fopen (aFileName.getStr(), "w");
if (pDestFILE == NULL)
return sal_False;
}
@@ -577,6 +606,7 @@ PrinterJob::EndJob ()
sal_Bool
PrinterJob::AbortJob ()
{
+ m_pGraphics->OnEndJob();
return sal_False;
}
@@ -599,6 +629,11 @@ PrinterJob::InitPaperSize (const JobData& rJobSetup)
mnWidthPt = nWidth;
mnHeightPt = nHeight;
+ if( mnWidthPt > mnMaxWidthPt )
+ mnMaxWidthPt = mnWidthPt;
+ if( mnHeightPt > mnMaxHeightPt )
+ mnMaxHeightPt = mnHeightPt;
+
mnLMarginPt = nLeft;
mnRMarginPt = nRight;
mnTMarginPt = nUpper;
@@ -609,12 +644,12 @@ PrinterJob::InitPaperSize (const JobData& rJobSetup)
}
-SalGraphics*
+sal_Bool
PrinterJob::StartPage (const JobData& rJobSetup, sal_Bool bNewJobData)
{
InitPaperSize (rJobSetup);
- rtl::OUString aPageNo = rtl::OUString::valueOf ((sal_Int32)maPageList.size());
+ rtl::OUString aPageNo = rtl::OUString::valueOf ((sal_Int32)maPageList.size()+1); // sequential page number must start with 1
rtl::OUString aExt = aPageNo + rtl::OUString::createFromAscii (".ps");
osl::File* pPageHeader = CreateSpoolFile (
@@ -625,19 +660,19 @@ PrinterJob::StartPage (const JobData& rJobSetup, sal_Bool bNewJobData)
maHeaderList.push_back (pPageHeader);
maPageList.push_back (pPageBody);
- /* #i7262# write setup only befor first page
+ /* #i7262# write setup only before first page
* don't do this in StartJob since the jobsetup there may be
* different.
*/
bool bSuccess = true;
if( 1 == maPageList.size() )
- bSuccess = writeSetup ( pPageHeader, rJobSetup );
+ m_aDocumentJobData = rJobSetup;
// write page header according to Document Structuring Conventions (DSC)
WritePS (pPageHeader, "%%Page: ");
WritePS (pPageHeader, aPageNo);
WritePS (pPageHeader, " ");
- WritePS (pPageHeader, aPageNo+1); // sequential page number must start with 1
+ WritePS (pPageHeader, aPageNo);
WritePS (pPageHeader, "\n");
sal_Char pBBox [256];
@@ -661,12 +696,14 @@ PrinterJob::StartPage (const JobData& rJobSetup, sal_Bool bNewJobData)
m_aLastJobData = rJobSetup;
- return NULL;
+ return bSuccess;
}
sal_Bool
PrinterJob::EndPage ()
{
+ m_pGraphics->OnEndPage();
+
osl::File* pPageHeader = maHeaderList.back();
osl::File* pPageBody = maPageList.back();
@@ -835,6 +872,7 @@ bool PrinterJob::writeProlog (osl::File* pFile)
{
const sal_Char pProlog[] = {
"%%BeginProlog\n"
+ "%%BeginResource: procset PSPrint-Prolog 1.0 0\n"
"/ISO1252Encoding [\n"
"/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n"
"/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n"
@@ -911,6 +949,7 @@ bool PrinterJob::writeProlog (osl::File* pFile)
"/ImageMatrix [1 0 0 1 0 0] dup 5 8 -1 roll put put dup\n"
"/DataSource 4 -1 roll 1 eq { psp_lzwfilter } { psp_ascii85filter } ifelse put\n"
"} def\n"
+ "%%EndResource\n"
"%%EndProlog\n"
};
WritePS (pFile, pProlog);
@@ -921,6 +960,36 @@ bool PrinterJob::writeProlog (osl::File* pFile)
bool PrinterJob::writeSetup( osl::File* pFile, const JobData& rJob )
{
WritePS (pFile, "%%BeginSetup\n%\n");
+
+ // download fonts
+ std::list< rtl::OString > aFonts[2];
+ m_pGraphics->writeResources( pFile, aFonts[0], aFonts[1] );
+
+ for( int i = 0; i < 2; i++ )
+ {
+ if( !aFonts[i].empty() )
+ {
+ std::list< rtl::OString >::const_iterator it = aFonts[i].begin();
+ rtl::OStringBuffer aLine( 256 );
+ if( i == 0 )
+ aLine.append( "%%DocumentSuppliedResources: font " );
+ else
+ aLine.append( "%%DocumentNeededResources: font " );
+ aLine.append( *it );
+ aLine.append( "\n" );
+ WritePS ( pFile, aLine.getStr() );
+ while( (++it) != aFonts[i].end() )
+ {
+ aLine.setLength(0);
+ aLine.append( "%%+ font " );
+ aLine.append( *it );
+ aLine.append( "\n" );
+ WritePS ( pFile, aLine.getStr() );
+ }
+ }
+ }
+
+ // setup code
ByteString aLine( "/#copies " );
aLine += ByteString::CreateFromInt32( rJob.m_nCopies );
aLine += " def\n";
diff --git a/psprint/source/printergfx/psheader.ps b/psprint/source/printergfx/psheader.ps
index 0b2de0105907..b7a35f2d6c5b 100644
--- a/psprint/source/printergfx/psheader.ps
+++ b/psprint/source/printergfx/psheader.ps
@@ -2,9 +2,9 @@
%
% $RCSfile: psheader.ps,v $
%
-% $Revision: 1.3 $
+% $Revision: 1.4 $
%
-% last change: $Author: cp $ $Date: 2002-04-08 16:32:40 $
+% last change: $Author: hr $ $Date: 2003-03-26 14:24:09 $
%
% The Contents of this file are made available subject to the terms of
% either of the following licenses
diff --git a/psprint/source/printergfx/text_gfx.cxx b/psprint/source/printergfx/text_gfx.cxx
index 87d11b838b44..e08ced275a83 100644
--- a/psprint/source/printergfx/text_gfx.cxx
+++ b/psprint/source/printergfx/text_gfx.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: text_gfx.cxx,v $
*
- * $Revision: 1.18 $
+ * $Revision: 1.19 $
*
- * last change: $Author: pl $ $Date: 2002-08-29 15:19:59 $
+ * last change: $Author: hr $ $Date: 2003-03-26 14:24:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -157,43 +157,13 @@ PrinterGfx::PSUploadPS1Font (sal_Int32 nFontID)
{
std::list< sal_Int32 >::iterator aFont;
// already in the document header ?
- for (aFont = maPS1Font.begin();
- aFont != maPS1Font.end() && *aFont != nFontID;
- aFont++)
- ;
- // not yet downloaded, do now
- if (aFont == maPS1Font.end())
- {
- const rtl::OString& rSysPath (mrFontMgr.getFontFileSysPath(nFontID) );
- rtl::OUString aUNCPath;
- osl::File::getFileURLFromSystemPath (OStringToOUString (rSysPath, osl_getThreadTextEncoding()), aUNCPath);
- osl::File aFontFile (aUNCPath);
-
- // provide the pfb or pfa font as a (pfa-)font resource
- rtl::OString aPostScriptName = rtl::OUStringToOString (
- mrFontMgr.getPSName(mnFontID),
- RTL_TEXTENCODING_ASCII_US);
+ for (aFont = maPS1Font.begin(); aFont != maPS1Font.end(); ++aFont )
+ if( nFontID == *aFont )
+ return;
- sal_Char pFontResource [256];
- sal_Int32 nChar = 0;
-
- nChar = psp::appendStr ("%%BeginResource: font ", pFontResource);
- nChar += psp::appendStr (aPostScriptName.getStr(), pFontResource + nChar);
- nChar += psp::appendStr ("\n", pFontResource + nChar);
-
- WritePS (mpPageHeader, pFontResource);
-
- osl::File::RC nError = aFontFile.open (OpenFlag_Read);
- if (nError == osl::File::E_None)
- {
- convertPfbToPfa (aFontFile, *mpPageHeader);
- aFontFile.close ();
- }
- WritePS (mpPageHeader, "%%EndResource\n");
-
- // add the fontid to the list
- maPS1Font.push_back (nFontID);
- }
+ // no occurrenc yet, mark for download
+ // add the fontid to the list
+ maPS1Font.push_back (nFontID);
}
/*
@@ -270,7 +240,7 @@ void PrinterGfx::DrawGlyphs(
if ( !mrFontMgr.isFontDownloadingAllowed( mnFontID ) )
{
- LicenceWarning(rPoint, pUnicodes, nLen, pDeltaArray);
+ LicenseWarning(rPoint, pUnicodes, nLen, pDeltaArray);
return;
}
@@ -605,7 +575,7 @@ void PrinterGfx::drawVerticalizedText(
}
void
-PrinterGfx::LicenceWarning(const Point& rPoint, const sal_Unicode* pStr,
+PrinterGfx::LicenseWarning(const Point& rPoint, const sal_Unicode* pStr,
sal_Int16 nLen, const sal_Int32* pDeltaArray)
{
// treat it like a builtin font in case a user has that font also in the
@@ -657,7 +627,7 @@ PrinterGfx::drawText(
if ( eType == fonttype::TrueType
&& !mrFontMgr.isFontDownloadingAllowed(mnFontID))
{
- LicenceWarning(rPoint, pStr, nLen, pDeltaArray);
+ LicenseWarning(rPoint, pStr, nLen, pDeltaArray);
return;
}
@@ -792,19 +762,65 @@ PrinterGfx::GetGlyphOutline (sal_Unicode c,
void
PrinterGfx::OnEndPage ()
{
+}
+
+void
+PrinterGfx::OnEndJob ()
+{
+ maPS3Font.clear();
+ maPS1Font.clear();
+}
+
+void
+PrinterGfx::writeResources( osl::File* pFile, std::list< rtl::OString >& rSuppliedFonts, std::list< rtl::OString >& rNeededFonts )
+{
+ // write all type 1 fonts
+ std::list< sal_Int32 >::iterator aFont;
+ // already in the document header ?
+ for (aFont = maPS1Font.begin(); aFont != maPS1Font.end(); ++aFont)
+ {
+ const rtl::OString& rSysPath (mrFontMgr.getFontFileSysPath(*aFont) );
+ rtl::OUString aUNCPath;
+ osl::File::getFileURLFromSystemPath (OStringToOUString (rSysPath, osl_getThreadTextEncoding()), aUNCPath);
+ osl::File aFontFile (aUNCPath);
+
+ // provide the pfb or pfa font as a (pfa-)font resource
+ rtl::OString aPostScriptName =
+ rtl::OUStringToOString ( mrFontMgr.getPSName(*aFont),
+ RTL_TEXTENCODING_ASCII_US );
+
+ WritePS (pFile, "%%BeginResource: font ");
+ WritePS (pFile, aPostScriptName.getStr());
+ WritePS (pFile, "\n");
+
+ osl::File::RC nError = aFontFile.open (OpenFlag_Read);
+ if (nError == osl::File::E_None)
+ {
+ convertPfbToPfa (aFontFile, *pFile);
+ aFontFile.close ();
+ }
+ WritePS (pFile, "%%EndResource\n");
+ rSuppliedFonts.push_back( aPostScriptName );
+ }
+
+ // write glyphsets and reencodings
std::list< GlyphSet >::iterator aIter;
for (aIter = maPS3Font.begin(); aIter != maPS3Font.end(); ++aIter)
{
if (aIter->GetFontType() == fonttype::TrueType)
{
- aIter->PSUploadFont (*mpPageHeader, *this, mbUploadPS42Fonts ? true : false );
+ aIter->PSUploadFont (*pFile, *this, mbUploadPS42Fonts ? true : false, rSuppliedFonts );
}
else
// ( aIter->GetFontType() == fonttype::Type1
// || aIter->GetFontType() == fonttype::Builtin )
{
- aIter->PSUploadEncoding (mpPageHeader, *this);
+ aIter->PSUploadEncoding (pFile, *this);
+ if( aIter->GetFontType() == fonttype::Builtin )
+ rNeededFonts.push_back(
+ rtl::OUStringToOString(
+ mrFontMgr.getPSName( aIter->GetFontID() ),
+ RTL_TEXTENCODING_ASCII_US ) );
}
}
}
-
diff --git a/psprint/util/makefile.mk b/psprint/util/makefile.mk
index 64b6450e46db..c3fb7425afd3 100644
--- a/psprint/util/makefile.mk
+++ b/psprint/util/makefile.mk
@@ -2,9 +2,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.7 $
+# $Revision: 1.8 $
#
-# last change: $Author: pl $ $Date: 2002-09-23 13:28:52 $
+# last change: $Author: hr $ $Date: 2003-03-26 14:24:11 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
@@ -94,7 +94,7 @@ SHL1VERSIONMAP=libpsp_linux.map
SHL1STDLIBS=$(UNOTOOLSLIB) \
$(TOOLSLIB) \
$(VOSLIB) \
- $(JENVLIB) \
+ $(JVMACCESSLIB) \
$(CPPUHELPERLIB) \
$(CPPULIB) \
$(SALLIB) \
diff --git a/psprint_config/prj/d.lst b/psprint_config/prj/d.lst
index 671c3930fe37..761b4ef98362 100644
--- a/psprint_config/prj/d.lst
+++ b/psprint_config/prj/d.lst
@@ -1,8 +1,6 @@
-mkdir: %_DEST%\pck%_EXT%
-mkdir: %_DEST%\pck%_EXT%\letter
+mkdir: %COMMON_DEST%\pck%_EXT%
+mkdir: %COMMON_DEST%\pck%_EXT%\letter
-..\common.pro\bin\*.zip %_DEST%\pck%_EXT%\*.zip
-..\common\bin\*.zip %_DEST%\pck%_EXT%\*.zip
+..\%__SRC%\bin\*.zip %_DEST%\pck%_EXT%\*.zip
+..\%__SRC%\bin\fontunxpsprint_letter.zip %_DEST%\pck%_EXT%\letter\fontunxpsprint.zip
-..\common.pro\bin\fontunxpsprint_letter.zip %_DEST%\pck%_EXT%\letter\fontunxpsprint.zip
-..\common\bin\fontunxpsprint_letter.zip %_DEST%\pck%_EXT%\letter\fontunxpsprint.zip