summaryrefslogtreecommitdiff
path: root/psprint/inc
diff options
context:
space:
mode:
Diffstat (limited to 'psprint/inc')
-rw-r--r--psprint/inc/psprint/fontmanager.hxx513
-rw-r--r--psprint/inc/psprint/helper.hxx88
-rw-r--r--psprint/inc/psprint/jobdata.hxx116
-rw-r--r--psprint/inc/psprint/ppdparser.hxx336
-rw-r--r--psprint/inc/psprint/printergfx.hxx408
-rw-r--r--psprint/inc/psprint/printerinfomanager.hxx211
-rw-r--r--psprint/inc/psprint/printerjob.hxx161
-rw-r--r--psprint/inc/psprint/strhelper.hxx101
8 files changed, 1934 insertions, 0 deletions
diff --git a/psprint/inc/psprint/fontmanager.hxx b/psprint/inc/psprint/fontmanager.hxx
new file mode 100644
index 000000000000..e454849863fb
--- /dev/null
+++ b/psprint/inc/psprint/fontmanager.hxx
@@ -0,0 +1,513 @@
+/*************************************************************************
+ *
+ * $RCSfile: fontmanager.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: pl $ $Date: 2001-05-08 11:45:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _PSPRINT_FONTMANAGER_HXX_
+#define _PSPRINT_FONTMANAGER_HXX_
+
+#ifndef __SGI_STL_HASH_MAP
+#include <hash_map>
+#endif
+#ifndef __SGI_STL_LIST
+#include <list>
+#endif
+#ifndef _PSPRINT_HELPER_HXX_
+#include <psprint/helper.hxx>
+#endif
+
+#define ATOM_FAMILYNAME 2
+#define ATOM_PSNAME 3
+
+/*
+ * some words on metrics: every length returned by PrintFontManager and
+ * friends are PostScript afm style, that is they are 1/1000 font height
+ */
+
+// forward declarations
+
+namespace utl { class MultiAtomProvider; } // see unotools/atom.hxx
+
+namespace psp {
+class PPDParser; // see ppdparser.hxx
+
+namespace italic
+{
+enum type {
+ Upright = 0,
+ Oblique = 1,
+ Italic = 2,
+ Unknown = 3
+};
+}
+
+namespace width
+{
+enum type {
+ Unknown = 0,
+ UltraCondensed = 1,
+ ExtraCondensed = 2,
+ Condensed = 3,
+ SemiCondensed = 4,
+ Normal = 5,
+ SemiExpanded = 6,
+ Expanded = 7,
+ ExtraExpanded = 8,
+ UltraExpanded = 9
+};
+}
+
+namespace pitch
+{
+enum type {
+ Unknown = 0,
+ Fixed = 1,
+ Variable = 2
+};
+}
+
+namespace weight
+{
+enum type {
+ Unknown = 0,
+ Thin = 1,
+ UltraLight = 2,
+ Light = 3,
+ SemiLight = 4,
+ Normal = 5,
+ Medium = 6,
+ SemiBold = 7,
+ Bold = 8,
+ UltraBold = 9,
+ Black = 10
+};
+}
+
+namespace family
+{
+enum type {
+ Unknown = 0,
+ Decorative = 1,
+ Modern = 2,
+ Roman = 3,
+ Script = 4,
+ Swiss = 5,
+ System = 6
+};
+}
+
+namespace fonttype
+{
+enum type {
+ Unknown = 0,
+ Type1 = 1,
+ TrueType = 2,
+ Builtin = 3
+};
+}
+
+/*
+ * the difference between FastPrintFontInfo and PrintFontInfo
+ * is that the information in FastPrintFontInfo can usually
+ * be gathered without openening either the font file or
+ * an afm metric file. they are gathered from fonts.dir alone.
+ * if only FastPrintFontInfo is gathered and PrintFontInfo
+ * on demand and for less fonts, then performance in startup
+ * increases considerably
+ */
+
+struct FastPrintFontInfo
+{
+ fontID m_nID; // FontID
+ fonttype::type m_eType;
+
+ // font attributes
+ ::rtl::OUString m_aFamilyName;
+ family::type m_eFamilyStyle;
+ italic::type m_eItalic;
+ width::type m_eWidth;
+ weight::type m_eWeight;
+ pitch::type m_ePitch;
+ rtl_TextEncoding m_aEncoding;
+};
+
+struct PrintFontInfo : public FastPrintFontInfo
+{
+ int m_nAscend;
+ int m_nDescend;
+ int m_nLeading;
+ int m_nWidth;
+};
+
+// the values are per thousand of the font size
+// note: width, height contain advances, not bounding box
+struct CharacterMetric
+{
+ short int width, height;
+
+ CharacterMetric() : width( 0 ), height( 0 ) {}
+};
+
+struct KernPair
+{
+ sal_Unicode first, second;
+ short int kern_x, kern_y;
+
+ KernPair() : first( 0 ), second( 0 ), kern_x( 0 ), kern_y( 0 ) {}
+};
+
+// a class to manage printable fonts
+// aims are type1 and truetype fonts
+
+class PrintFontManager
+{
+ struct PrintFont;
+ struct TrueTypeFontFile;
+ struct Type1FontFile;
+ struct BuiltinFont;
+ friend class PrintFont;
+ friend class TrueTypeFontFile;
+ friend class Type1FontFile;
+ friend class BuiltinFont;
+
+ struct PrintFontMetrics
+ {
+ // character metrics are stored by the following keys:
+ // lower two bytes contain a sal_Unicode (a UCS2 character)
+ // upper byte contains: 0 for horizontal metric
+ // 1 for vertical metric
+ // highest byte: 0 for now
+ ::std::hash_map< int, CharacterMetric > m_aMetrics;
+ // contains the unicode blocks for which metrics were queried
+ // this implies that metrics should be queried in terms of
+ // unicode blocks. here a unicode block is identified
+ // by the upper byte of the UCS2 encoding.
+ // note that the corresponding bit should be set even
+ // if the font does not support a single character of that page
+ // this map shows, which pages were queried already
+ // if (like in AFM metrics) all metrics are queried in
+ // a single pass, then all bits should be set
+ char m_aPages[32];
+
+ bool m_bKernPairsQueried;
+ ::std::list< KernPair > m_aXKernPairs;
+ ::std::list< KernPair > m_aYKernPairs;
+
+ PrintFontMetrics() : m_bKernPairsQueried( false ) {}
+ };
+
+ struct PrintFont
+ {
+ fonttype::type m_eType;
+
+ // font attributes
+ int m_nFamilyName; // atom
+ int m_nPSName; // atom
+ italic::type m_eItalic;
+ width::type m_eWidth;
+ weight::type m_eWeight;
+ pitch::type m_ePitch;
+ rtl_TextEncoding m_aEncoding;
+ CharacterMetric m_aGlobalMetricX;
+ CharacterMetric m_aGlobalMetricY;
+ PrintFontMetrics* m_pMetrics;
+ int m_nAscend;
+ int m_nDescend;
+ int m_nLeading;
+
+ PrintFont( fonttype::type eType );
+ virtual ~PrintFont();
+ virtual bool queryMetricPage( int nPage, ::utl::MultiAtomProvider* pProvider ) = 0;
+
+ bool readAfmMetrics( const ::rtl::OString& rFileName, ::utl::MultiAtomProvider* pProvider );
+ };
+
+ struct Type1FontFile : public PrintFont
+ {
+ int m_nDirectory; // atom containing system dependent path
+ ::rtl::OString m_aFontFile; // relative to directory
+ ::rtl::OString m_aMetricFile; // dito
+ ::rtl::OString m_aXLFD; // mainly for administration, contains the XLFD from fonts.dir
+
+ /* note: m_aFontFile and Metric file are not atoms
+ because they should be fairly unique */
+
+ Type1FontFile() : PrintFont( fonttype::Type1 ) {}
+ virtual ~Type1FontFile();
+ virtual bool queryMetricPage( int nPage, ::utl::MultiAtomProvider* pProvider );
+ };
+
+ struct TrueTypeFontFile : public PrintFont
+ {
+ int m_nDirectory; // atom containing system dependent path
+ ::rtl::OString m_aFontFile; // relative to directory
+ ::rtl::OString m_aXLFD; // mainly for administration, contains the XLFD from fonts.dir
+ int m_nCollectionEntry; // -1 for regular fonts, 0 to ... for fonts stemming from collections
+
+ TrueTypeFontFile() : PrintFont( fonttype::TrueType ) {}
+ virtual ~TrueTypeFontFile();
+ virtual bool queryMetricPage( int nPage, ::utl::MultiAtomProvider* pProvider );
+ };
+
+ struct BuiltinFont : public PrintFont
+ {
+ int m_nDirectory; // atom containing system dependent path
+ ::rtl::OString m_aMetricFile;
+
+ BuiltinFont() : PrintFont( fonttype::Builtin ) {}
+ virtual ~BuiltinFont();
+ virtual bool queryMetricPage( int nPage, ::utl::MultiAtomProvider* pProvider );
+ };
+
+ fontID m_nNextFontID;
+ ::std::hash_map< fontID, PrintFont* > m_aFonts;
+ ::std::hash_map< int, family::type > m_aFamilyTypes;
+ ::std::list< ::rtl::OUString > m_aPrinterDrivers;
+ ::std::list< ::rtl::OString > m_aFontDirectories;
+ ::utl::MultiAtomProvider* m_pAtoms;
+
+ ::std::hash_map< ::rtl::OString, int, ::rtl::OStringHash >
+ m_aDirToAtom;
+ ::std::hash_map< int, ::rtl::OString > m_aAtomToDir;
+ int m_nNextDirAtom;
+
+
+ ::rtl::OString getAfmFile( PrintFont* pFont ) const;
+ ::rtl::OString getFontFile( PrintFont* pFont ) const;
+
+ void getFontAttributesFromXLFD( PrintFont* pFont, const ByteString& rXLFD ) const;
+
+ bool analyzeFontFile( int nDirID, const ::rtl::OString& rFileName, bool bReadFile, const ::rtl::OString& rXLFD, ::std::list< PrintFont* >& rNewFonts ) const;
+ bool analyzeTrueTypeFile( PrintFont* pFont ) const;
+ // finds the FIRST id for this font file; there may be more
+ // for TrueType collections
+ fontID findFontFileID( int nDirID, const ::rtl::OString& rFile ) const;
+ fontID findFontBuiltinID( int nPSNameAtom ) const;
+
+ family::type matchFamilyName( const ::rtl::OUString& rFamily ) const;
+
+ PrintFont* getFont( fontID nID ) const
+ {
+ ::std::hash_map< int, PrintFont* >::const_iterator it;
+ it = m_aFonts.find( nID );
+ return it == m_aFonts.end() ? NULL : it->second;
+ }
+ ByteString getXLFD( PrintFont* pFont ) const;
+ void fillPrintFontInfo( PrintFont* pFont, FastPrintFontInfo& rInfo ) const;
+ void fillPrintFontInfo( PrintFont* pFont, PrintFontInfo& rInfo ) const;
+
+ const ::rtl::OString& getDirectory( int nAtom ) const;
+ int getDirectoryAtom( const ::rtl::OString& rDirectory, bool bCreate = false );
+
+ PrintFontManager();
+ ~PrintFontManager();
+public:
+ static PrintFontManager& get(); // one instance only
+
+ int addFontFile( const ::rtl::OString& rFileName, int nFaceNum );
+
+ // initialize takes an X Display*
+ // if NULL then an XOpendDisplay( NULL ) is performed
+ // the Display connection is used to get the font path
+ void initialize( void* pDisplay = NULL );
+
+ // returns the number of managed fonts
+ int getFontCount() const { return m_aFonts.size(); }
+ // returns the ids of all managed fonts. on pParser != NULL
+ // all fonttype::Builtin type fonts are not listed
+ // which do not occur in the PPD of pParser
+ void getFontList( ::std::list< fontID >& rFontIDs, const PPDParser* pParser = NULL ) const;
+ // get the font list and detailed font info. see getFontList for pParser
+ void getFontListWithInfo( ::std::list< PrintFontInfo >& rFonts, const PPDParser* pParser = NULL ) const;
+ // get the font list and fast font info. see getFontList for pParser
+ void getFontListWithFastInfo( ::std::list< FastPrintFontInfo >& rFonts, const PPDParser* pParser = NULL ) const;
+
+ // get font info for a specific font
+ bool getFontInfo( fontID nFontID, PrintFontInfo& rInfo ) const;
+ // get fast font info for a specific font
+ bool getFontFastInfo( fontID nFontID, FastPrintFontInfo& rInfo ) const;
+
+ // routines to get font info in small pieces
+
+ // get a specific fonts family name
+ const ::rtl::OUString& getFontFamily( fontID nFontID ) const;
+ // get a specific fonts PSName name
+ const ::rtl::OUString& getPSName( fontID nFontID ) const;
+
+ // get a specific fonts style family
+ family::type PrintFontManager::getFontFamilyType( fontID nFontID ) const;
+
+ // get a specific fonts type
+ fonttype::type getFontType( fontID nFontID ) const
+ {
+ PrintFont* pFont = getFont( nFontID );
+ return pFont ? pFont->m_eType : fonttype::Unknown;
+ }
+
+ // get a specific fonts italic type
+ italic::type getFontItalic( fontID nFontID ) const
+ {
+ PrintFont* pFont = getFont( nFontID );
+ return pFont ? pFont->m_eItalic : italic::Unknown;
+ }
+
+ // get a specific fonts width type
+ width::type getFontWidth( fontID nFontID ) const
+ {
+ PrintFont* pFont = getFont( nFontID );
+ return pFont ? pFont->m_eWidth : width::Unknown;
+ }
+
+ // get a specific fonts weight type
+ weight::type getFontWeight( fontID nFontID ) const
+ {
+ PrintFont* pFont = getFont( nFontID );
+ return pFont ? pFont->m_eWeight : weight::Unknown;
+ }
+
+ // get a specific fonts pitch type
+ pitch::type getFontPitch( fontID nFontID ) const
+ {
+ PrintFont* pFont = getFont( nFontID );
+ return pFont ? pFont->m_ePitch : pitch::Unknown;
+ }
+
+ // get a specific fonts encoding
+ rtl_TextEncoding getFontEncoding( fontID nFontID ) const
+ {
+ PrintFont* pFont = getFont( nFontID );
+ return pFont ? pFont->m_aEncoding : RTL_TEXTENCODING_DONTKNOW;
+ }
+
+ // get a specific fonts system dependent filename
+ ::rtl::OString getFontFileSysPath( fontID nFontID ) const
+ {
+ return getFontFile( getFont( nFontID ) );
+ }
+
+ // get the ttc face number
+ int getFontFaceNumber( fontID nFontID ) const
+ {
+ int nRet = -1;
+ PrintFont* pFont = getFont( nFontID );
+ if( pFont->m_eType == fonttype::TrueType )
+ nRet = static_cast< TrueTypeFontFile* >(pFont)->m_nCollectionEntry;
+ return nRet;
+ }
+
+ // get a specific fonts global metrics
+ const CharacterMetric& getGlobalFontMetric( fontID nFontID, bool bHorizontal ) const;
+
+ // get a specific fonts ascend
+ int getFontAscend( fontID nFontID ) const;
+
+ // get a specific fonts descent
+ int getFontDescend( fontID nFontID ) const;
+
+ // get a specific fonts leading
+ int getFontLeading( fontID nFontID ) const;
+
+ // get the XLFD for a font that originated from the X fontpath
+ // note: this may not be the original line that was in the fonts.dir
+ // returns a string for every font, but only TrueType and Type1
+ // fonts originated from the X font path, so check for the font type
+ ::rtl::OUString getFontXLFD( fontID nFontID ) const;
+
+ // get a specific fonts metrics
+
+ // get metrics for a sal_Unicode range
+ // the user is responsible to allocate pArray large enough
+ bool getMetrics( fontID nFontID, sal_Unicode minCharacter, sal_Unicode maxCharacter, CharacterMetric* pArray, bool bVertical = false ) const;
+ // get metrics for an array of sal_Unicode characters
+ // the user is responsible to allocate pArray large enough
+ bool getMetrics( fontID nFontID, const sal_Unicode* pString, int nLen, CharacterMetric* pArray, bool bVertical = false ) const;
+
+ // to get font substitution transparently use the
+ // getKernPairs method of PrinterGfx
+ const ::std::list< KernPair >& getKernPairs( fontID nFontID, bool bVertical = false ) const;
+
+ // font administration functions
+
+ // for importFonts to provide the user feedback
+ class ImportFontCallback
+ {
+ public:
+ enum FailCondition { NoWritableDirectory, NoAfmMetric, AfmCopyFailed, FontCopyFailed };
+ virtual void importFontsFailed( FailCondition eReason ) = 0;
+ virtual void progress( const ::rtl::OUString& rFile ) = 0;
+ virtual bool queryOverwriteFile( const ::rtl::OUString& rFile ) = 0;
+ virtual void importFontFailed( const ::rtl::OUString& rFile, FailCondition ) = 0;
+ virtual bool isCanceled() = 0;
+ };
+
+ // checks wether font import would fail due to no writeable directory
+ bool checkImportPossible() const;
+ // expects system paths not UNC paths
+ // returns the number of fonts successfully imported
+ int importFonts( const ::std::list< ::rtl::OUString >& rFiles, ImportFontCallback* pCallback = NULL );
+
+ // check wether changeFontProperties would fail due to not writable fonts.dir
+ bool checkChangeFontPropertiesPossible( fontID nFont ) const;
+ // change fonts.dir entry for font
+ bool changeFontProperties( fontID nFont, const ::rtl::OUString& rXLFD );
+};
+
+} // namespace
+
+#endif // _PSPRINT_FONTMANAGER_HXX_
diff --git a/psprint/inc/psprint/helper.hxx b/psprint/inc/psprint/helper.hxx
new file mode 100644
index 000000000000..99b4cd9e58fa
--- /dev/null
+++ b/psprint/inc/psprint/helper.hxx
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * $RCSfile: helper.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: pl $ $Date: 2001-05-08 11:45:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _PSPRINT_HELPER_HXX_
+#define _PSPRINT_HELPER_HXX_
+
+#ifndef __SGI_STL_HASH_MAP
+#include <hash_map>
+#endif
+#ifndef _RTL_USTRING_
+#include <rtl/ustring>
+#endif
+
+
+// forwards
+namespace osl { class File; }
+
+#ifndef _RTL_USTRING_
+#include <rtl/ustring>
+#endif
+
+namespace psp {
+typedef int fontID;
+
+const ::rtl::OUString& getPrinterPath();
+
+bool convertPfbToPfa( ::osl::File& rInFile, ::osl::File& rOutFile );
+} // namespace
+
+#endif // _PSPRINT_HELPER_HXX_
diff --git a/psprint/inc/psprint/jobdata.hxx b/psprint/inc/psprint/jobdata.hxx
new file mode 100644
index 000000000000..8e6b6597e118
--- /dev/null
+++ b/psprint/inc/psprint/jobdata.hxx
@@ -0,0 +1,116 @@
+/*************************************************************************
+ *
+ * $RCSfile: jobdata.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: pl $ $Date: 2001-05-08 11:45:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _PSPRINT_JOBDATA_HXX_
+#define _PSPRINT_JOBDATA_HXX_
+
+#ifndef _PSPRINT_PPDPARSER_HXX_
+#include <psprint/ppdparser.hxx>
+#endif
+
+namespace psp {
+
+namespace orientation {
+enum type {
+ Portrait,
+ Landscape
+};
+}
+
+struct JobData
+{
+ int m_nCopies;
+ int m_nScale; // in percent
+ int m_nLeftMarginAdjust;
+ int m_nRightMarginAdjust;
+ int m_nTopMarginAdjust;
+ int m_nBottomMarginAdjust;
+ // user overrides for PPD
+ int m_nColorDepth;
+ int m_nPSLevel; // 0: no override, else languaglevel to use
+ int m_nColorDevice; // 0: no override, -1 grey scale, +1 color
+ orientation::type m_eOrientation;
+ ::rtl::OUString m_aPrinterName;
+ const PPDParser* m_pParser;
+ PPDContext m_aContext;
+
+ JobData() :
+ m_nCopies( 1 ),
+ m_nScale( 100 ),
+ m_nLeftMarginAdjust( 0 ),
+ m_nRightMarginAdjust( 0 ),
+ m_nTopMarginAdjust( 0 ),
+ m_nBottomMarginAdjust( 0 ),
+ m_nColorDepth( 24 ),
+ m_nPSLevel( 0 ),
+ m_nColorDevice( 0 ),
+ m_eOrientation( orientation::Portrait ),
+ m_pParser( NULL ) {}
+
+ // creates a new buffer using new
+ // it is up to the user to delete it again
+ bool getStreamBuffer( void*& pData, int& bytes );
+ static bool constructFromStreamBuffer( void* pData, int bytes, JobData& rJobData );
+};
+
+} // namespace
+
+#endif // PSPRINT_JOBDATA_HXX
diff --git a/psprint/inc/psprint/ppdparser.hxx b/psprint/inc/psprint/ppdparser.hxx
new file mode 100644
index 000000000000..bdee073180d5
--- /dev/null
+++ b/psprint/inc/psprint/ppdparser.hxx
@@ -0,0 +1,336 @@
+/*************************************************************************
+ *
+ * $RCSfile: ppdparser.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: pl $ $Date: 2001-05-08 11:45:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _PSPRINT_PPDPARSER_HXX_
+#define _PSPRINT_PPDPARSER_HXX_
+
+#ifndef __SGI_STL_LIST
+#include <list>
+#endif
+#ifndef _PSPRINT_HELPER_HXX_
+#include <psprint/helper.hxx> // hash_map and OUString hash
+#endif
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+#ifndef _STREAM_HXX
+#include <tools/stream.hxx>
+#endif
+
+namespace psp {
+
+class PPDParser;
+
+enum PPDValueType { eInvocation, eQuoted, eSymbol, eString, eNo };
+
+struct PPDValue
+{
+ PPDValueType m_eType;
+ String m_aOption;
+ String m_aOptionTranslation;
+ String m_aValue;
+ String m_aValueTranslation;
+};
+
+// ----------------------------------------------------------------------
+
+/*
+ * PPDKey - a container for the available options (=values) of a PPD keyword
+ */
+
+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;
+
+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;
+public:
+ PPDKey( const String& rKey );
+ ~PPDKey();
+
+ PPDValue* insertValue( const String& rOption );
+ int countValues() const
+ { return m_aValues.size(); }
+ // neither getValue will return the query option
+ const PPDValue* getValue( int n ) const;
+ const PPDValue* getValue( const String& rOption ) const;
+ const PPDValue* getDefaultValue() const { return m_pDefaultValue; }
+ const PPDValue* getQueryValue() const { return m_bQueryValue ? &m_aQueryValue : NULL; }
+
+ const String& getKey() const { return m_aKey; }
+ bool isUIKey() const { return m_bUIOption; }
+ const String& getUITranslation() const { return m_aUITranslation; }
+ UIType getUIType() const { return m_eUIType; }
+ SetupType getSetupType() const { return m_eSetupType; }
+ int getOrderDependency() const { return m_nOrderDependency; }
+};
+
+// ----------------------------------------------------------------------
+
+/*
+ * PPDParser - parses a PPD file and contains all available keys from it
+ */
+
+class PPDContext;
+
+class PPDParser
+{
+ friend class PPDContext;
+public:
+ struct PPDConstraint
+ {
+ const PPDKey* m_pKey1;
+ const PPDValue* m_pOption1;
+ const PPDKey* m_pKey2;
+ const PPDValue* m_pOption2;
+
+ PPDConstraint() : m_pKey1( NULL ), m_pOption1( NULL ), m_pKey2( NULL ), m_pOption2( NULL ) {}
+ };
+
+ static ::std::list< PPDParser* > aAllParsers;
+
+ ::std::hash_map< ::rtl::OUString, PPDKey*, ::rtl::OUStringHash >
+ m_aKeys;
+ ::std::list< PPDConstraint > m_aConstraints;
+
+ // some identifying fields
+ String m_aPrinterName;
+ String m_aNickName;
+ // the full path of the PPD file
+ String m_aFile;
+ // some basic attributes
+ 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;
+ // paper dimensions
+ const PPDValue* m_pDefaultPaperDimension;
+ const PPDKey* m_pPaperDimensions;
+ // paper trays
+ const PPDValue* m_pDefaultInputSlot;
+ const PPDKey* m_pInputSlots;
+ // resolutions
+ const PPDValue* m_pDefaultResolution;
+ const PPDKey* m_pResolutions;
+ // duplex commands
+ const PPDValue* m_pDefaultDuplexType;
+ const PPDKey* m_pDuplexTypes;
+
+ // fonts
+ const PPDKey* m_pFontList;
+
+ PPDParser( const String& rFile );
+ ~PPDParser();
+
+ void parseOrderDependency( const String& rLine );
+ void parseOpenUI( const String& rLine );
+ void parseConstraint( const String& rLine );
+ void parse( ::std::list< String >& rLines );
+public:
+ static const PPDParser* getParser( String aFile );
+ static String getPPDPrinterName( const String& rFile );
+ static void freeAll();
+
+ const String& getFilename() const { return m_aFile; }
+
+ const PPDKey* getKey( int n ) const;
+ const PPDKey* getKey( const String& rKey ) const;
+ int getKeys() const { return m_aKeys.size(); }
+ bool hasKey( const PPDKey* ) const;
+
+ const ::std::list< PPDConstraint >& getConstraints() const { return m_aConstraints; }
+
+ const String& getPrinterName() const
+ { return m_aPrinterName.Len() ? m_aPrinterName : m_aNickName; }
+ const String& getNickName() const
+ { return m_aNickName.Len() ? m_aNickName : m_aPrinterName; }
+
+ bool isColorDevice() const { return m_bColorDevice; }
+ bool isType42Capable() const { return m_bType42Capable; }
+ ULONG getLanguageLevel() const { return m_nLanguageLevel; }
+
+ const String& getDefaultPaperDimension() const;
+ const void getDefaultPaperDimension( int& rWidth, int& rHeight ) const
+ { getPaperDimension( getDefaultPaperDimension(), rWidth, rHeight ); }
+ bool getPaperDimension( const String& rPaperName,
+ int& rWidth, int& rHeight ) const;
+ // width and height in pt
+ // returns false if paper not found
+ int getPaperDimensions() const
+ { return m_pPaperDimensions ? m_pPaperDimensions->countValues() : 0; }
+ const String& getPaperDimension( int ) const;
+ const String& getPaperDimensionCommand( int ) const;
+ const String& getPaperDimensionCommand( const String & ) const;
+
+ // match the best paper for width and height
+ const String& matchPaper( int nWidth, int nHeight ) const;
+
+ bool getMargins( const String& rPaperName,
+ int &rLeft, int& rRight,
+ int &rUpper, int& rLower ) const;
+ // values in pt
+ // returns true if paper found
+
+ // values int pt
+
+ const String& getDefaultInputSlot() const;
+ int getInputSlots() const
+ { return m_pInputSlots ? m_pInputSlots->countValues() : 0; }
+ const String& getSlot( int ) const;
+ const String& getSlotCommand( int ) const;
+ const String& getSlotCommand( const String& ) const;
+
+ void getDefaultResolution( int& rXRes, int& rYRes ) const;
+ int getResolutions() const;
+ void getResolution( int, int& rXRes, int& rYRes ) const;
+ const String& getResolutionCommand( int nXRes, int nYRes ) const;
+ // values in dpi
+ void getResolutionFromString( const String&, int&, int& ) const;
+ // helper function
+
+ const String& getDefaultDuplexType() const;
+ int getDuplexTypes() const
+ { return m_pDuplexTypes ? m_pDuplexTypes->countValues() : 0; }
+ const String& getDuplex( int ) const;
+ const String& getDuplexCommand( int ) const;
+ const String& getDuplexCommand( const String& ) const;
+
+ int getFonts() const
+ { return m_pFontList ? m_pFontList->countValues() : 0; }
+ void getFontAttributes( int,
+ String& rEncoding,
+ String& rCharset ) const;
+ void getFontAttributes( const String&,
+ String& rEncoding,
+ String& rCharset ) const;
+ const String& getFont( int ) const;
+};
+
+// ----------------------------------------------------------------------
+
+/*
+ * PPDContext - a class to manage user definable states based on the
+ * contents of a PPDParser.
+ */
+
+class PPDContext
+{
+ ::std::hash_map< const PPDKey*, const PPDValue* > m_aCurrentValues;
+ const PPDParser* m_pParser;
+
+ // returns false: check failed, new value is constrained
+ // true: check succeded, new value can be set
+ bool checkConstraints( const PPDKey*, const PPDValue*, bool bDoReset );
+ bool resetValue( const PPDKey*, bool bDefaultable = false );
+public:
+ PPDContext( const PPDParser* pParser = NULL );
+ PPDContext( const PPDContext& rContext ) { operator=( rContext ); }
+ PPDContext& operator=( const PPDContext& rContext );
+ ~PPDContext();
+
+ void setParser( const PPDParser* );
+ const PPDParser* getParser() const { return m_pParser; }
+
+ const PPDValue* getValue( const PPDKey* ) const;
+ const PPDValue* setValue( const PPDKey*, const PPDValue*, bool bDontCareForConstraints = false );
+
+ int countValuesModified() const { return m_aCurrentValues.size(); }
+ const PPDKey* getModifiedKey( int n ) const;
+
+ // public wrapper for the private method
+ bool checkConstraints( const PPDKey*, const PPDValue* );
+
+ void getUnconstrainedValues( const PPDKey*, ::std::list< const PPDValue* >& rValues );
+
+ // for printer setup
+ void* getStreamableBuffer( ULONG& rBytes ) const;
+ void rebuildFromStreamBuffer( void* pBuffer, ULONG nBytes );
+
+ // convenience
+ void getResolution( int& rDPIx, int& rDPIy ) const;
+
+ // width, height in points, paper will contain the name of the selected
+ // paper after the call
+ void getPageSize( String& rPaper, int& rWidth, int& rHeight ) const;
+};
+
+} // namespace
+
+#endif // _PSPRINT_PPDPARSER_HXX_
diff --git a/psprint/inc/psprint/printergfx.hxx b/psprint/inc/psprint/printergfx.hxx
new file mode 100644
index 000000000000..286e95be492f
--- /dev/null
+++ b/psprint/inc/psprint/printergfx.hxx
@@ -0,0 +1,408 @@
+/*************************************************************************
+ *
+ * $RCSfile: printergfx.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: pl $ $Date: 2001-05-08 11:45:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _PSPRINT_PRINTERGFX_HXX_
+#define _PSPRINT_PRINTERGFX_HXX_
+
+#ifndef _PSPRINT_HELPER_HXX_
+#include <psprint/helper.hxx>
+#endif
+#ifndef _OSL_FILE_HXX_
+#include <osl/file.hxx>
+#endif
+#ifndef _SV_GEN_HXX
+#include <tools/gen.hxx>
+#endif
+#ifndef __SGI_STL_LIST
+#include <list>
+#endif
+#ifndef __SGI_STL_HASH_MAP
+#include <hash_map>
+#endif
+
+namespace psp {
+
+// forwards
+class JobData;
+
+/*
+ * lightweight container to handle RGB values
+ */
+
+class PrinterColor
+{
+public:
+
+ typedef enum ColorSpace { eInvalid, eRGB };
+
+private:
+
+ sal_uInt8 mnRed;
+ sal_uInt8 mnGreen;
+ sal_uInt8 mnBlue;
+ ColorSpace meColorspace;
+
+public:
+
+ PrinterColor () :
+ meColorspace(eInvalid)
+ {}
+ PrinterColor (sal_uInt16 nRed, sal_uInt16 nGreen,
+ sal_uInt16 nBlue) :
+ mnRed (nRed),
+ mnGreen (nGreen),
+ mnBlue (nBlue),
+ meColorspace (eRGB)
+ {}
+ PrinterColor (sal_uInt32 nRGB) :
+ meColorspace (eRGB),
+ mnBlue ((nRGB & 0x000000ff) ),
+ mnGreen ((nRGB & 0x0000ff00) >> 8),
+ mnRed ((nRGB & 0x00ff0000) >> 16)
+ {}
+ ~PrinterColor ()
+ {}
+
+ sal_Bool Is () const
+ { return meColorspace != eInvalid; }
+
+ ColorSpace GetColorSpace () const
+ { return meColorspace; }
+ sal_uInt16 GetRed () const
+ { return mnRed; }
+ sal_uInt16 GetGreen () const
+ { return mnGreen; }
+ sal_uInt16 GetBlue () const
+ { return mnBlue; }
+ sal_Bool operator== (const PrinterColor& aColor) const
+ {
+ return aColor.Is() && this->Is()
+ && mnRed == aColor.mnRed
+ && mnGreen == aColor.mnGreen
+ && mnBlue == aColor.mnBlue;
+ }
+ PrinterColor& operator= (const PrinterColor& aColor)
+ {
+ meColorspace = aColor.meColorspace;
+ mnRed = aColor.mnRed;
+ mnGreen = aColor.mnGreen;
+ mnBlue = aColor.mnBlue;
+
+ return *this;
+ }
+
+ PrinterColor& operator= (sal_uInt32 nRGB)
+ {
+ meColorspace = eRGB;
+ mnBlue = (nRGB & 0x000000ff);
+ mnGreen = (nRGB & 0x0000ff00) >> 8;
+ mnRed = (nRGB & 0x00ff0000) >> 16;
+
+ return *this;
+ }
+};
+
+/*
+ * forward declarations
+ */
+
+class GlyphSet;
+class PrinterJob;
+class PrintFontManager;
+class KernPair;
+struct CharacterMetric;
+
+/*
+ * Bitmap Interface, this has to be filled with your actual bitmap implementation
+ * sample implementations can be found in:
+ * psprint/workben/cui/pspdem.cxx
+ * vcl/unx/source/gdi/salgdi2.cxx
+ */
+
+class PrinterBmp
+{
+public:
+
+ virtual ~PrinterBmp () = 0;
+ virtual sal_uInt32 GetPaletteColor (sal_uInt32 nIdx) const = 0;
+ virtual sal_uInt32 GetPaletteEntryCount () const = 0;
+ virtual sal_uInt32 GetPixelRGB (sal_uInt32 nRow, sal_uInt32 nColumn) const = 0;
+ virtual sal_uInt8 GetPixelGray (sal_uInt32 nRow, sal_uInt32 nColumn) const = 0;
+ virtual sal_uInt8 GetPixelIdx (sal_uInt32 nRow, sal_uInt32 nColumn) const = 0;
+ virtual sal_uInt32 GetWidth () const = 0;
+ virtual sal_uInt32 GetHeight () const = 0;
+ virtual sal_uInt32 GetDepth () const = 0;
+};
+
+/*
+ * printer raster operations
+ */
+
+class PrinterGfx
+{
+private:
+
+ /* common settings */
+
+ double mfScaleX;
+ double mfScaleY;
+
+ sal_uInt32 mnDpiX;
+ sal_uInt32 mnDpiY;
+ sal_uInt16 mnDepth;
+
+ sal_uInt16 mnPSLevel;
+ sal_Bool mbColor;
+ sal_Bool mbUploadPS42Fonts;
+
+ osl::File* mpPageHeader;
+ osl::File* mpPageBody;
+
+ void TranslateCoordinates (sal_Int32 &rXOut, sal_Int32 &rYOut,
+ sal_Int32 nXIn, sal_Int32 nYIn )
+ { rXOut = nXIn; rYOut = nYIn; }
+ void TranslateCoordinates (Point& rOut, const Point& rIn)
+ { rOut = rIn; }
+
+ /* text/font related data, for a type1 font it has to be checked
+ whether this font has already been downloaded. A TrueType font
+ will be converted into one or more Type3 fonts, containing glyphs
+ in no particular order. In addition to the existence of the
+ glyph in one of the subfonts, the mapping from unicode to the
+ glyph has to be remembered */
+
+ std::list< sal_Int32 > maPS1Font;
+ std::list< GlyphSet > maPS3Font;
+
+ sal_Int32 mnFontID;
+ sal_Int32 mnFallbackID;
+ sal_Int32 mnTextHeight;
+ sal_Int32 mnTextWidth;
+ sal_Int32 mnTextAngle;
+ bool mbTextVertical;
+ rtl::OString maCurrentFont;
+ PrintFontManager& mrFontMgr;
+
+ /* bitmap drawing implementation */
+
+ sal_Bool mbCompressBmp;
+
+ void DrawPS1GrayImage (const PrinterBmp& rBitmap, const Rectangle& rArea);
+ void DrawPS2GrayImage (const PrinterBmp& rBitmap, const Rectangle& rArea);
+ void DrawPS2PaletteImage (const PrinterBmp& rBitmap, const Rectangle& rArea);
+ void DrawPS2TrueColorImage (const PrinterBmp& rBitmap, const Rectangle& rArea);
+
+ /* clip region */
+
+ std::list< Rectangle > maClipRegion;
+ sal_Bool JoinVerticalClipRectangles( std::list< Rectangle >::iterator& it,
+ Point& aOldPoint, sal_Int32& nColumn );
+
+ /* color settings */
+
+ sal_Bool mbCurrentColorValid;
+ PrinterColor maCurrentColor;
+
+ sal_Bool mbCurrentLineWidthValid;
+ double mfLineWidth;
+
+ PrinterColor maFillColor;
+ PrinterColor maTextColor;
+ PrinterColor maLineColor;
+
+ /* font / font substitution */
+ const ::std::hash_map< fontID, fontID >* mpFontSubstitutes;
+ int getCharWidth (sal_Bool b_vert, sal_Unicode n_char,
+ CharacterMetric *p_bbox);
+ fontID getCharMetric (fontID p_font[3], sal_Unicode n_char,
+ CharacterMetric *p_bbox);
+ fontID getFontSubstitute ();
+
+public:
+
+ enum pspath_t { moveto = 0, lineto = 1 };
+ void PSBinLineTo (const Point& rCurrent, Point& rOld,
+ sal_Int32& nColumn);
+ void PSBinMoveTo (const Point& rCurrent, Point& rOld,
+ sal_Int32& nColumn);
+ void PSBinStartPath ();
+ void PSBinEndPath ();
+ void PSBinCurrentPath (sal_uInt32 nPoints, const Point* pPath);
+ void PSBinPath (const Point& rCurrent, Point& rOld,
+ pspath_t eType, sal_Int32& nColumn);
+
+ void PSSetColor (const PrinterColor& rColor);
+ void PSSetLineWidth ();
+
+ void PSUploadPS1Font (sal_Int32 nFontID);
+ void PSSetFont (rtl::OString& rName,
+ rtl_TextEncoding nEncoding = RTL_TEXTENCODING_DONTKNOW);
+ void PSRotate (sal_Int32 nAngle);
+ void PSTranslate (const Point& rPoint);
+ void PSMoveTo (const Point& rPoint);
+ void PSRMoveTo (sal_Int32 nDx, sal_Int32 nDy = 0);
+ void PSScale (double fScaleX, double fScaleY);
+ void PSLineTo(const Point& rPoint );
+ void PSPointOp (const Point& rPoint, const sal_Char* pOperator);
+ void PSHexString (const sal_uChar* pString, sal_Int16 nLen);
+ void PSDeltaArray (const sal_Int32 *pArray, sal_Int16 nEntries);
+ void PSShowText (const sal_uChar* pString,
+ sal_Int16 nGlyphs, sal_Int16 nBytes,
+ const sal_Int32* pDeltaArray = NULL);
+ void PSGSave ();
+ void PSGRestore ();
+
+ void OnEndPage ();
+ PrintFontManager& GetFontMgr ();
+
+ void drawVerticalizedText (const Point& rPoint,
+ const sal_Unicode* pStr,
+ sal_Int16 nLen,
+ const sal_Int32* pDeltaArray );
+ void drawText (const Point& rPoint,
+ const sal_Unicode* pStr, sal_Int16 nLen,
+ const sal_Int32* pDeltaArray = NULL);
+public:
+ PrinterGfx();
+ ~PrinterGfx();
+ sal_Bool Init (PrinterJob &rPrinterSpec);
+ sal_Bool Init (const JobData& rData);
+ void Clear();
+
+ // query depth and size
+ void GetResolution (sal_Int32 &rDpiX, sal_Int32 &rDpiY) const;
+ void GetScreenFontResolution (sal_Int32 &rDpiX, sal_Int32 &rDpiY) const;
+ sal_uInt16 GetBitCount ();
+
+ // clip region
+ void ResetClipRegion ();
+ void BeginSetClipRegion (sal_uInt32);
+ sal_Bool UnionClipRegion (sal_Int32 nX, sal_Int32 nY,
+ sal_Int32 nDX, sal_Int32 nDY);
+ void EndSetClipRegion ();
+
+ // set xy color
+ void SetLineColor (const PrinterColor& rLineColor = PrinterColor())
+ { maLineColor = rLineColor; }
+ void SetFillColor (const PrinterColor& rFillColor = PrinterColor())
+ { maFillColor = rFillColor; }
+
+ // drawing primitives
+ void DrawPixel (const Point& rPoint, const PrinterColor& rPixelColor);
+ void DrawPixel (const Point& rPoint)
+ { DrawPixel (rPoint, maLineColor); }
+ void DrawLine (const Point& rFrom, const Point& rTo);
+ void DrawRect (const Rectangle& rRectangle);
+ void DrawPolyLine (sal_uInt32 nPoints, const Point* pPath );
+ void DrawPolygon (sal_uInt32 nPoints, const Point* pPath);
+ void DrawPolyPolygon (sal_uInt32 nPoly,
+ const sal_uInt32 *pPolygonSize,
+ const Point** pPolygonList);
+
+ // eps
+ sal_Bool DrawEPS ( const Rectangle& rBoundingBox, void* pPtr, sal_uInt32 nSize);
+
+ // image drawing
+ void DrawBitmap (const Rectangle& rDest, const Rectangle& rSrc,
+ const PrinterBmp& rBitmap);
+ void DrawBitmap (const Rectangle& rDest, const Rectangle& rSrc,
+ const PrinterBmp& rBitmap,
+ const PrinterBmp& rTransBitmap);
+ void DrawMask (const Rectangle& rDest, const Rectangle& rSrc,
+ const PrinterBmp &rBitmap, PrinterColor& rMaskColor);
+
+ // font and text handling
+ sal_uInt16 SetFont (
+ sal_Int32 nFontID,
+ sal_Int32 nPointHeight,
+ sal_Int32 nPointWidth,
+ sal_Int32 nAngle,
+ bool bVertical
+ );
+ sal_uInt16 SetFallbackFont ( sal_Int32 nFontID );
+ sal_Int32 GetFontAngle () const
+ { return mnTextAngle; }
+ sal_Int32 GetFontID () const
+ { return mnFontID; }
+ sal_Int32 GetFontHeight () const
+ { return mnTextHeight; }
+ sal_Int32 GetFontWidth () const
+ { return mnTextWidth; }
+ void DrawText (const Point& rPoint,
+ const sal_Unicode* pStr, sal_Int16 nLen,
+ const sal_Int32* pDeltaArray = NULL);
+ void SetTextColor (PrinterColor& rTextColor)
+ { maTextColor = rTextColor; }
+ sal_Int32 GetCharWidth (sal_uInt16 nFrom, sal_uInt16 nTo,
+ long *pWidthArray);
+ const ::std::list< KernPair >& getKernPairs( bool bVertical = false ) const;
+ // advanced font handling
+ sal_Bool GetGlyphBoundRect (sal_Unicode c, Rectangle& rOutRect);
+ sal_uInt32 GetGlyphOutline (sal_Unicode c,
+ sal_uInt16 **ppPolySizes, Point **ppPoints,
+ sal_uInt8 **ppFlags);
+};
+
+} /* namespace psp */
+
+
+#endif /* _PSPRINT_PRINTERGFX_HXX_ */
+
diff --git a/psprint/inc/psprint/printerinfomanager.hxx b/psprint/inc/psprint/printerinfomanager.hxx
new file mode 100644
index 000000000000..2e8d473a3218
--- /dev/null
+++ b/psprint/inc/psprint/printerinfomanager.hxx
@@ -0,0 +1,211 @@
+/*************************************************************************
+ *
+ * $RCSfile: printerinfomanager.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: pl $ $Date: 2001-05-08 11:45:32 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _PSPRINT_PRINTERINFOMANAGER_HXX_
+#define _PSPRINT_PRINTERINFOMANAGER_HXX_
+
+#ifndef __SGI_STL_HASH_MAP
+#include <hash_map>
+#endif
+#ifndef __SGI_STL_LIST
+#include <list>
+#endif
+#ifndef _PSPRINT_HELPER_HXX_
+#include <psprint/helper.hxx>
+#endif
+#ifndef _PSPRINT_JOBDATA_HXX_
+#include <psprint/jobdata.hxx>
+#endif
+#ifndef _OSL_FILE_HXX_
+#include <osl/file.hxx>
+#endif
+#ifndef _PSPRINT_HELPER_HXX_
+#include <psprint/helper.hxx>
+#endif
+
+namespace psp
+{
+struct PrinterInfo : JobData
+{
+ // basename of PPD
+ ::rtl::OUString m_aDriverName;
+ // can be the queue
+ ::rtl::OUString m_aLocation;
+ // a user defined comment
+ ::rtl::OUString m_aComment;
+ // a command line to pipe a PS-file to
+ ::rtl::OUString m_aCommand;
+ // a list of special features separated by ',' not used by psprint
+ // but assigned from the outside (currently only for "fax")
+ ::rtl::OUString m_aFeatures;
+ // a mapping of fonts to other fonts.
+ // this provides a method for the user
+ // to replace arbitrary fonts by printer builtin fonts
+ // currently this is only a mapping between font names
+ // assuming that only adbobe standard encoding fonts are
+ // built into the printer. in future it may be necessary
+ // to map to a font name and UCS2 vector which should be mapped
+ // this vector is currently implicitly given by the adobe
+ // standard encoding
+ bool m_bPerformFontSubstitution;
+ ::std::hash_map< ::rtl::OUString, ::rtl::OUString, ::rtl::OUStringHash >
+ m_aFontSubstitutes;
+ ::std::hash_map< fontID, fontID >
+ m_aFontSubstitutions;
+};
+
+class PrinterInfoManager
+{
+ // needed for checkPrintersChanged: files (not necessarily existant)
+ // and their last known modification time
+ struct WatchFile
+ {
+ // the file in question
+ ::rtl::OUString m_aFilePath;
+ // the last know modification time or 0, if file did not exist
+ TimeValue m_aModified;
+ };
+
+ // internal data to describe a printer
+ struct Printer
+ {
+ // configuration file containing this printer
+ // empty means a freshly added printer that has to be saved yet
+ ::rtl::OUString m_aFile;
+ // group in m_aFile containing the printer
+ // this must be unique over all configuration files
+ // it usually should be the printer name
+ ::rtl::OString m_aGroup;
+ // wether changes need to be saved
+ bool m_bModified;
+ // the corresponding info and job data
+ PrinterInfo m_aInfo;
+ };
+
+ ::std::hash_map< ::rtl::OUString, Printer, ::rtl::OUStringHash > m_aPrinters;
+ PrinterInfo m_aGlobalDefaults;
+ ::std::list< WatchFile > m_aWatchFiles;
+ ::rtl::OUString m_aDefaultPrinter;
+ ::rtl::OUString m_aSystemPrintCommand;
+ ::std::list< ::rtl::OUString > m_aSystemPrintQueues;
+
+ PrinterInfoManager();
+ ~PrinterInfoManager();
+
+ void initialize();
+
+ // fill in font substitutions
+ // the resulting hash_map maps from source to target font ids
+ void fillFontSubstitutions( PrinterInfo& rInfo ) const;
+public:
+
+ // there can only be one
+ static PrinterInfoManager& get();
+
+ // lists the names of all known printers
+ void listPrinters( ::std::list< ::rtl::OUString >& rList ) const;
+
+ // gets the number of known printers
+ int countPrinters() const { return m_aPrinters.size(); }
+
+ // gets info about a named printer
+ const PrinterInfo& getPrinterInfo( const ::rtl::OUString& rPrinter ) const;
+
+ // gets the name of the default printer
+ const ::rtl::OUString& getDefaultPrinter() const { return m_aDefaultPrinter; }
+
+ // changes the info about a named printer
+ void changePrinterInfo( const ::rtl::OUString& rPrinter, const PrinterInfo& rNewInfo );
+
+ // check if the printer configuration has changed
+ bool checkPrintersChanged();
+
+ // members for administration (->padmin)
+
+ // add a named printer
+ // addPrinter fails if a printer with the same name already exists
+ // or the driver does not exist
+ bool addPrinter( const ::rtl::OUString& rPrinterName, const ::rtl::OUString& rDriverName );
+
+ // remove a namend printer
+ // this fails if the config file belonging to this printer
+ // is not writeable
+ bool removePrinter( const ::rtl::OUString& rPrinterName );
+
+ // save the changes to all printers. this fails if there
+ // is no writable config file at all
+ bool writePrinterConfig();
+
+ // set a new default printer
+ // fails if the specified printer does not exist
+ bool setDefaultPrinter( const ::rtl::OUString& rPrinterName );
+
+ // primarily used internally but also by padmin
+ // returns the printer queue names
+ const ::std::list< ::rtl::OUString >& getSystemPrintQueues();
+
+ // similar but returnse whole commandlines
+ void getSystemPrintCommands( ::std::list< ::rtl::OUString >& rCommands );
+};
+
+} // namespace
+
+#endif // _PSPRINT_PRINTERINFOMANAGER_HXX_
diff --git a/psprint/inc/psprint/printerjob.hxx b/psprint/inc/psprint/printerjob.hxx
new file mode 100644
index 000000000000..9191b5be7dd0
--- /dev/null
+++ b/psprint/inc/psprint/printerjob.hxx
@@ -0,0 +1,161 @@
+/*************************************************************************
+ *
+ * $RCSfile: printerjob.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: pl $ $Date: 2001-05-08 11:45:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+
+#ifndef _PSPRINT_PRINTERJOB_HXX_
+#define _PSPRINT_PRINTERJOB_HXX_
+
+#ifndef __SGI_STL_LIST
+#include <list>
+#endif
+#ifndef _PSPRINT_JOBDATA_HXX_
+#include <psprint/jobdata.hxx>
+#endif
+#ifndef _OSL_FILE_HXX_
+#include <osl/file.hxx>
+#endif
+#ifndef _RTL_STRING_HXX_
+#include <rtl/string.hxx>
+#endif
+
+// forward declarations
+class SalGraphics;
+
+namespace psp {
+
+
+class PrinterJob
+{
+private: // private data
+
+ rtl::OUString maSpoolDirName;
+ rtl::OUString maFileName; // empty: spool to command, else spool to named file
+
+ osl::File* mpJobHeader;
+ osl::File* mpJobTrailer;
+
+ std::list< osl::File* > maPageList;
+ std::list< osl::File* > maHeaderList;
+
+ JobData m_aLastJobData;
+
+ sal_uInt32 mnResX;
+ sal_uInt32 mnResY;
+
+ sal_uInt32 mnWidthPt;
+ sal_uInt32 mnHeightPt;
+
+ sal_uInt32 mnLMarginPt;
+ sal_uInt32 mnRMarginPt;
+ sal_uInt32 mnTMarginPt;
+ sal_uInt32 mnBMarginPt;
+
+ double mfXScale;
+ double mfYScale;
+
+ sal_Int32 mnErrorCode;
+
+private: // private methods
+
+ osl::File* CreateSpoolFile (const rtl::OUString& rName,
+ const rtl::OUString& rExtension);
+ void InitPaperSize (const JobData& rJobSetup);
+
+ bool writeSetup( osl::File* pFile, const JobData& );
+ bool writePageSetup( osl::File* pFile, const JobData& );
+ bool writeProlog (osl::File* pFile);
+
+public: // for usage in PrinterGfx
+
+ void GetResolution (sal_uInt32 &rDpiX, sal_uInt32 &rDpiY) const;
+ void GetScale (double &rXScale, double &rYScale) const;
+ sal_uInt16 GetDepth () const;
+ sal_uInt16 GetPostscriptLevel (const JobData *pJobData = NULL) const;
+ sal_Bool IsColorPrinter () const;
+
+ osl::File* GetDocumentHeader ();
+ osl::File* GetDocumentTrailer ();
+ osl::File* GetCurrentPageHeader ();
+ osl::File* GetCurrentPageBody ();
+
+ const ::rtl::OUString& GetPrinterName() const { return m_aLastJobData.m_aPrinterName; }
+
+public:
+ PrinterJob ();
+ ~PrinterJob ();
+
+ sal_Bool StartJob (const rtl::OUString& rFileName,
+ const rtl::OUString& rJobName,
+ const rtl::OUString& rAppName,
+ const JobData& rSetupData);
+ sal_Bool EndJob ();
+
+ sal_Bool AbortJob ();
+
+ SalGraphics* StartPage (const JobData& rJobSetup, sal_Bool bNewJobData);
+ sal_Bool EndPage ();
+
+ sal_uInt32 GetErrorCode ();
+};
+
+} /* namespace psp */
+
+#endif /* _PSPRINT_PRINTERJOB_HXX_ */
+
diff --git a/psprint/inc/psprint/strhelper.hxx b/psprint/inc/psprint/strhelper.hxx
new file mode 100644
index 000000000000..b4f9a4523677
--- /dev/null
+++ b/psprint/inc/psprint/strhelper.hxx
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * $RCSfile: strhelper.hxx,v $
+ *
+ * $Revision: 1.1.1.1 $
+ *
+ * last change: $Author: pl $ $Date: 2001-05-08 11:45:33 $
+ *
+ * The Contents of this file are made available subject to the terms of
+ * either of the following licenses
+ *
+ * - GNU Lesser General Public License Version 2.1
+ * - Sun Industry Standards Source License Version 1.1
+ *
+ * Sun Microsystems Inc., October, 2000
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2000 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ *
+ * Sun Industry Standards Source License Version 1.1
+ * =================================================
+ * The contents of this file are subject to the Sun Industry Standards
+ * Source License Version 1.1 (the "License"); You may not use this file
+ * except in compliance with the License. You may obtain a copy of the
+ * License at http://www.openoffice.org/license.html.
+ *
+ * Software provided under this License is provided on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
+ * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
+ * See the License for the specific provisions governing your rights and
+ * obligations concerning the Software.
+ *
+ * The Initial Developer of the Original Code is: Sun Microsystems, Inc.
+ *
+ * Copyright: 2000 by Sun Microsystems, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * Contributor(s): _______________________________________
+ *
+ *
+ ************************************************************************/
+#ifndef _PSPRINT_STRHELPER_HXX_
+#define _PSPRINT_STRHELPER_HXX_
+
+#ifndef _STRING_HXX
+#include <tools/string.hxx>
+#endif
+
+namespace psp {
+
+String GetCommandLineToken( int, const String& );
+ByteString GetCommandLineToken( int, const ByteString& );
+// gets one token of a unix command line style string
+// doublequote, singlequote and singleleftquote protect their respective
+// contents
+
+int GetCommandLineTokenCount( const String& );
+int GetCommandLineTokenCount( const ByteString& );
+// returns number of tokens (zero if empty or whitespace only)
+
+String WhitespaceToSpace( const String&, BOOL bProtect = TRUE );
+ByteString WhitespaceToSpace( const ByteString&, BOOL bProtect = TRUE );
+// returns a string with multiple adjacent occurences of whitespace
+// converted to a single space. if bProtect is TRUE (nonzero), then
+// doublequote, singlequote and singleleftquote protect their respective
+// contents
+
+double StringToDouble( const String& rStr );
+double StringToDouble( const ByteString& rStr );
+// parses the first double in the string; decimal is '.' only
+
+// fills a character buffer with the string representation of a double
+// the buffer has to be long enough (e.g. 128 bytes)
+// returns the string len
+int getValueOfDouble( char* pBuffer, double f, int nPrecision = 0 );
+// corresponding convenience functions
+ByteString DoubleToByteString( double f, int nPrecision = 0 );
+String DoubleToString( double f, int nPrecision = 0 );
+
+} // namespace
+
+#endif // _PSPRINT_STRHELPER_HXX_