summaryrefslogtreecommitdiff
path: root/vcl/inc
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2009-03-06 09:33:41 +0000
committerOliver Bolte <obo@openoffice.org>2009-03-06 09:33:41 +0000
commit659af2052b0471ff4507f1742a4f0c0681d66e8e (patch)
treed047328a27e779c050e18e63766fed55f759bdd1 /vcl/inc
parent3315021862137d58fd8d57c035d397474a9df644 (diff)
CWS-TOOLING: integrate CWS movepsprint
2009-02-27 10:42:24 +0100 pl r268559 : #i99633# remove X11 build for mac 2009-02-26 16:38:01 +0100 pl r268535 : #i97898# move psprint to vcl: no more linking psprint 2009-02-26 16:36:35 +0100 pl r268534 : #i97898# move psprint to vcl: tentative os2 changes 2009-02-26 16:20:36 +0100 pl r268532 : #i97898# move psprint to vcl: make compile again, round 5 2009-02-26 15:53:12 +0100 pl r268530 : #i97898# psprint removed 2009-02-26 13:43:40 +0100 pl r268513 : #i97898# use proper X display in PrintFontManager::initialize 2009-02-26 12:39:05 +0100 pl r268496 : #i99633# remove unsused header 2009-02-25 19:12:54 +0100 pl r268467 : #i99633# get rid of special casing for the now discontinued Mac X11 port 2009-02-25 18:25:37 +0100 pl r268466 : #i97898# move psprint to vcl: make compile again, round 4 2009-02-25 17:38:55 +0100 pl r268458 : #i97898# move psprint to vcl: make compile again, round 3 2009-02-25 16:55:15 +0100 pl r268452 : #i97898# move psprint to vcl: remove psp lib from install set 2009-02-25 16:50:25 +0100 pl r268451 : #i97898# move psprint to vcl: make compile again, round 2 2009-02-25 16:10:50 +0100 pl r268448 : #i97898# move psprint to vcl: make compile again, round 1 2009-02-25 14:38:12 +0100 pl r268440 : #i97898# move psprint to vcl: remove references to psprint in solenv 2009-02-25 14:22:22 +0100 pl r268437 : #i97898# move psprint to vcl, first step: move in svn
Diffstat (limited to 'vcl/inc')
-rw-r--r--vcl/inc/cupsmgr.hxx111
-rw-r--r--vcl/inc/list.h103
-rw-r--r--vcl/inc/sft.h641
-rw-r--r--vcl/inc/vcl/fontcache.hxx102
-rw-r--r--vcl/inc/vcl/fontmanager.hxx748
-rw-r--r--vcl/inc/vcl/helper.hxx68
-rw-r--r--vcl/inc/vcl/jobdata.hxx86
-rw-r--r--vcl/inc/vcl/ppdparser.hxx333
-rw-r--r--vcl/inc/vcl/printergfx.hxx444
-rw-r--r--vcl/inc/vcl/printerinfomanager.hxx242
-rw-r--r--vcl/inc/vcl/printerjob.hxx152
-rw-r--r--vcl/inc/vcl/salinst.hxx19
-rw-r--r--vcl/inc/vcl/strhelper.hxx86
13 files changed, 3127 insertions, 8 deletions
diff --git a/vcl/inc/cupsmgr.hxx b/vcl/inc/cupsmgr.hxx
new file mode 100644
index 000000000000..9caec2d30031
--- /dev/null
+++ b/vcl/inc/cupsmgr.hxx
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: cupsmgr.hxx,v $
+ * $Revision: 1.11 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _PSPRINT_CUPSMGR_HXX_
+#define _PSPRINT_CUPSMGR_HXX_
+
+#include "vcl/printerinfomanager.hxx"
+#include "osl/module.h"
+#include "osl/thread.h"
+#include "osl/mutex.hxx"
+
+namespace psp
+{
+
+class CUPSWrapper;
+class PPDParser;
+
+struct FPtrHash
+{
+ size_t operator()(const FILE* pPtr) const
+ { return (size_t)pPtr; }
+};
+
+class CUPSManager : public PrinterInfoManager
+{
+ CUPSWrapper* m_pCUPSWrapper;
+ std::hash_map< FILE*, rtl::OString, FPtrHash > m_aSpoolFiles;
+ int m_nDests;
+ void* m_pDests;
+ bool m_bNewDests;
+ std::hash_map< rtl::OUString, int, rtl::OUStringHash > m_aCUPSDestMap;
+
+ std::hash_map< rtl::OUString, PPDContext, rtl::OUStringHash > m_aDefaultContexts;
+
+ rtl::OString m_aUser;
+ // this is a security risk, but the CUPS API demands
+ // to deliver a pointer to a static buffer containing
+ // the password, so this cannot be helped
+ rtl::OString m_aPassword;
+
+ osl::Mutex m_aCUPSMutex;
+ oslThread m_aDestThread;
+
+ CUPSManager( CUPSWrapper* );
+ virtual ~CUPSManager();
+
+ virtual void initialize();
+
+ void getOptionsFromDocumentSetup( const JobData& rJob, int& rNumOptions, void** rOptions ) const;
+ void runDests();
+public:
+ // public for stub
+ static void runDestThread(void* pMgr);
+
+ static CUPSManager* tryLoadCUPS();
+
+ const PPDParser* createCUPSParser( const rtl::OUString& rPrinter );
+ // wraps cupsGetPPD, so unlink after use !
+
+ const char* authenticateUser( const char* );
+
+ virtual FILE* startSpool( const rtl::OUString& rPrinterName, bool bQuickCommand );
+ virtual int endSpool( const rtl::OUString& rPrinterName, const rtl::OUString& rJobTitle, FILE* pFile, const JobData& rDocumentJobData );
+ virtual void setupJobContextData( JobData& rData );
+
+ // changes the info about a named printer
+ virtual void changePrinterInfo( const ::rtl::OUString& rPrinter, const PrinterInfo& rNewInfo );
+
+ // check if the printer configuration has changed
+ virtual bool checkPrintersChanged( bool bWait );
+
+ // members for administration (->padmin)
+ // disable for CUPS
+ virtual bool addPrinter( const rtl::OUString& rPrinterName, const ::rtl::OUString& rDriverName );
+ virtual bool removePrinter( const rtl::OUString& rPrinterName, bool bCheckOnly = false );
+ virtual bool writePrinterConfig();
+ virtual bool setDefaultPrinter( const rtl::OUString& rPrinterName );
+
+ virtual bool addOrRemovePossible() const;
+};
+
+} // namespace psp
+
+#endif
diff --git a/vcl/inc/list.h b/vcl/inc/list.h
new file mode 100644
index 000000000000..b86521a1f666
--- /dev/null
+++ b/vcl/inc/list.h
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: list.h,v $
+ * $Revision: 1.4 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* $Id: list.h,v 1.4 2008-06-25 14:20:01 kz Exp $ */
+
+/*[]---------------------------------------------------[]*/
+/*| |*/
+/*| Implementation of the list data type |*/
+/*| |*/
+/*| |*/
+/*| Author: Alexander Gelfenbain |*/
+/*[]---------------------------------------------------[]*/
+
+#ifndef __CLIST_H
+#define __CLIST_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/*
+ * List of void * pointers
+ */
+
+ typedef struct _list *list;
+
+/*- constructors and a destructor */
+ list listNewEmpty(void);
+#ifdef TEST
+ list listNewCopy(list);
+#endif
+ void listDispose(list);
+ void listSetElementDtor(list, void (*f)(void *)); /*- this function will be executed when the element is removed via listRemove() or listClear() */
+
+/*- queries */
+ void * listCurrent(list);
+ int listCount(list);
+ int listIsEmpty(list);
+#ifdef TEST
+ int listAtFirst(list);
+ int listAtLast(list);
+ int listPosition(list); /* Expensive! */
+#endif
+/*- search */
+ int listFind(list, void *); /* Returns true/false */
+
+/*- positioning functions */
+/*- return the number of elements by which the current position in the list changes */
+ int listNext(list);
+ int listSkipForward(list, int n);
+ int listToFirst(list);
+ int listToLast(list);
+ int listPositionAt(list, int n); /* Expensive! */
+
+/*- adding and removing elements */
+ list listAppend(list, void *);
+#ifdef TEST
+ list listPrepend(list, void *);
+ list listInsertAfter(list, void *);
+ list listInsertBefore(list, void *);
+#endif
+ list listRemove(list); /* removes the current element */
+ list listClear(list); /* removes all elements */
+
+#ifdef TEST
+/*- forall */
+ void listForAll(list, void (*f)(void *));
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __CLIST_H */
diff --git a/vcl/inc/sft.h b/vcl/inc/sft.h
new file mode 100644
index 000000000000..efda0903afc5
--- /dev/null
+++ b/vcl/inc/sft.h
@@ -0,0 +1,641 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: sft.h,v $
+ * $Revision: 1.21 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/* $Id: sft.h,v 1.21 2008-06-25 14:20:49 kz Exp $ */
+
+/**
+
+ *
+ * @file sft.h
+ * @brief Sun Font Tools
+ * @author Alexander Gelfenbain
+ */
+
+/*
+ * If NO_MAPPERS is defined, MapChar() and MapString() and consequently GetTTSimpleCharMetrics()
+ * don't get compiled in. This is done to avoid including a large chunk of code (TranslateXY() from
+ * xlat.c in the projects that don't require it.
+ *
+ * If NO_TYPE3 is defined CreateT3FromTTGlyphs() does not get compiled in.
+ * If NO_TYPE42 is defined Type42-related code is excluded
+ * If NO_TTCR is defined TrueType creation related code is excluded\
+ * If NO_LIST is defined list.h and piblic functions that use it don't get compiled
+ */
+
+/*
+ * Generated fonts contain an XUID entry in the form of:
+ *
+ * 103 0 T C1 N C2 C3
+ *
+ * 103 - Sun's Adobe assigned XUID number. Contact person: Alexander Gelfenbain <gelf@eng.sun.com>
+ *
+ * T - font type. 0: Type 3, 1: Type 42
+ * C1 - CRC-32 of the entire source TrueType font
+ * N - number of glyphs in the subset
+ * C2 - CRC-32 of the array of glyph IDs used to generate the subset
+ * C3 - CRC-32 of the array of encoding numbers used to generate the subset
+ *
+ */
+
+
+#ifndef __SUBFONT_H
+#define __SUBFONT_H
+
+#ifdef UNX
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+#include <stdio.h>
+
+#include <sal/types.h>
+
+#ifndef NO_LIST
+#include "list.h"
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*@{*/
+#ifndef __cplusplus
+#define false 0 /**< standard false value */
+#define true 1 /**< standard true value */
+#endif
+/*@}*/
+
+/*@{*/
+ typedef sal_Int16 F2Dot14; /**< fixed: 2.14 */
+ typedef sal_Int32 F16Dot16; /**< fixed: 16.16 */
+/*@}*/
+
+ typedef struct {
+ sal_uInt16 s;
+ sal_uInt16 d;
+ } sal_uInt16pair;
+
+/** Return value of OpenTTFont() and CreateT3FromTTGlyphs() */
+ enum SFErrCodes {
+ SF_OK, /**< no error */
+ SF_BADFILE, /**< file not found */
+ SF_FILEIO, /**< file I/O error */
+ SF_MEMORY, /**< memory allocation error */
+ SF_GLYPHNUM, /**< incorrect number of glyphs */
+ SF_BADARG, /**< incorrect arguments */
+ SF_TTFORMAT, /**< incorrect TrueType font format */
+ SF_TABLEFORMAT, /**< incorrect format of a TrueType table */
+ SF_FONTNO /**< incorrect logical font number of a TTC font */
+ };
+
+#ifndef FW_THIN /* WIN32 compilation would conflict */
+/** Value of the weight member of the TTGlobalFontInfo struct */
+ enum WeightClass {
+ FW_THIN = 100, /**< Thin */
+ FW_EXTRALIGHT = 200, /**< Extra-light (Ultra-light) */
+ FW_LIGHT = 300, /**< Light */
+ FW_NORMAL = 400, /**< Normal (Regular) */
+ FW_MEDIUM = 500, /**< Medium */
+ FW_SEMIBOLD = 600, /**< Semi-bold (Demi-bold) */
+ FW_BOLD = 700, /**< Bold */
+ FW_EXTRABOLD = 800, /**< Extra-bold (Ultra-bold) */
+ FW_BLACK = 900 /**< Black (Heavy) */
+ };
+
+/** Value of the width member of the TTGlobalFontInfo struct */
+#ifndef OS2
+ enum WidthClass {
+ FWIDTH_ULTRA_CONDENSED = 1, /**< 50% of normal */
+ FWIDTH_EXTRA_CONDENSED = 2, /**< 62.5% of normal */
+ FWIDTH_CONDENSED = 3, /**< 75% of normal */
+ FWIDTH_SEMI_CONDENSED = 4, /**< 87.5% of normal */
+ FWIDTH_NORMAL = 5, /**< Medium, 100% */
+ FWIDTH_SEMI_EXPANDED = 6, /**< 112.5% of normal */
+ FWIDTH_EXPANDED = 7, /**< 125% of normal */
+ FWIDTH_EXTRA_EXPANDED = 8, /**< 150% of normal */
+ FWIDTH_ULTRA_EXPANDED = 9 /**< 200% of normal */
+ };
+#endif // OS2
+#endif /* FW_THIN */
+
+/** Type of the 'kern' table, stored in _TrueTypeFont::kerntype */
+ enum KernType {
+ KT_NONE = 0, /**< no kern table */
+ KT_APPLE_NEW = 1, /**< new Apple kern table */
+ KT_MICROSOFT = 2 /**< Microsoft table */
+ };
+
+/* Composite glyph flags definition */
+ enum CompositeFlags {
+ ARG_1_AND_2_ARE_WORDS = 1,
+ ARGS_ARE_XY_VALUES = 1<<1,
+ ROUND_XY_TO_GRID = 1<<2,
+ WE_HAVE_A_SCALE = 1<<3,
+ MORE_COMPONENTS = 1<<5,
+ WE_HAVE_AN_X_AND_Y_SCALE = 1<<6,
+ WE_HAVE_A_TWO_BY_TWO = 1<<7,
+ WE_HAVE_INSTRUCTIONS = 1<<8,
+ USE_MY_METRICS = 1<<9,
+ OVERLAP_COMPOUND = 1<<10
+ };
+
+#ifndef NO_TTCR
+/** Flags for TrueType generation */
+ enum TTCreationFlags {
+ TTCF_AutoName = 1, /**< Automatically generate a compact 'name' table.
+ If this flag is not set, name table is generated
+ either from an array of NameRecord structs passed as
+ arguments or if the array is NULL, 'name' table
+ of the generated TrueType file will be a copy
+ of the name table of the original file.
+ If this flag is set the array of NameRecord structs
+ is ignored and a very compact 'name' table is automatically
+ generated. */
+
+ TTCF_IncludeOS2 = 2 /** If this flag is set OS/2 table from the original font will be
+ copied to the subset */
+ };
+#endif
+
+
+
+
+/** Structure used by GetTTSimpleGlyphMetrics() and GetTTSimpleCharMetrics() functions */
+ typedef struct {
+ sal_uInt16 adv; /**< advance width or height */
+ sal_Int16 sb; /**< left or top sidebearing */
+ } TTSimpleGlyphMetrics;
+
+
+
+/** Structure used by the TrueType Creator and GetRawGlyphData() */
+
+ typedef struct {
+ sal_uInt32 glyphID; /**< glyph ID */
+ sal_uInt16 nbytes; /**< number of bytes in glyph data */
+ sal_uInt8 *ptr; /**< pointer to glyph data */
+ sal_uInt16 aw; /**< advance width */
+ sal_Int16 lsb; /**< left sidebearing */
+ sal_uInt16 compflag; /**< 0- if non-composite, 1- otherwise */
+ sal_uInt16 npoints; /**< number of points */
+ sal_uInt16 ncontours; /**< number of contours */
+ /* */
+ sal_uInt32 newID; /**< used internally by the TTCR */
+ } GlyphData;
+
+/** Structure used by the TrueType Creator and CreateTTFromTTGlyphs() */
+ typedef struct {
+ sal_uInt16 platformID; /**< Platform ID */
+ sal_uInt16 encodingID; /**< Platform-specific encoding ID */
+ sal_uInt16 languageID; /**< Language ID */
+ sal_uInt16 nameID; /**< Name ID */
+ sal_uInt16 slen; /**< String length in bytes */
+ sal_uInt8 *sptr; /**< Pointer to string data (not zero-terminated!) */
+ } NameRecord;
+
+
+
+/** Return value of GetTTGlobalFontInfo() */
+
+ typedef struct {
+ char *family; /**< family name */
+ sal_uInt16 *ufamily; /**< family name UCS2 */
+ char *subfamily; /**< subfamily name */
+ sal_uInt16 *usubfamily; /**< subfamily name UCS2 */
+ char *psname; /**< PostScript name */
+ sal_uInt16 macStyle; /**< macstyle bits from 'HEAD' table */
+ int weight; /**< value of WeightClass or 0 if can't be determined */
+ int width; /**< value of WidthClass or 0 if can't be determined */
+ int pitch; /**< 0: proportianal font, otherwise: monospaced */
+ int italicAngle; /**< in counter-clockwise degrees * 65536 */
+ int xMin; /**< global bounding box: xMin */
+ int yMin; /**< global bounding box: yMin */
+ int xMax; /**< global bounding box: xMax */
+ int yMax; /**< global bounding box: yMax */
+ int ascender; /**< typographic ascent. */
+ int descender; /**< typographic descent. */
+ int linegap; /**< typographic line gap.\ Negative values are treated as
+ zero in Win 3.1, System 6 and System 7. */
+ int vascent; /**< typographic ascent for vertical writing mode */
+ int vdescent; /**< typographic descent for vertical writing mode */
+ int typoAscender; /**< OS/2 portable typographic ascender */
+ int typoDescender; /**< OS/2 portable typographic descender */
+ int typoLineGap; /**< OS/2 portable typographc line gap */
+ int winAscent; /**< ascender metric for Windows */
+ int winDescent; /**< descender metric for Windows */
+ int symbolEncoded; /**< 1: MS symbol encoded 0: not symbol encoded */
+ int rangeFlag; /**< if set to 1 Unicode Range flags are applicable */
+ sal_uInt32 ur1; /**< bits 0 - 31 of Unicode Range flags */
+ sal_uInt32 ur2; /**< bits 32 - 63 of Unicode Range flags */
+ sal_uInt32 ur3; /**< bits 64 - 95 of Unicode Range flags */
+ sal_uInt32 ur4; /**< bits 96 - 127 of Unicode Range flags */
+ sal_uInt8 panose[10]; /**< PANOSE classification number */
+ sal_uInt16 typeFlags; /**< type flags (copyright information) */
+ } TTGlobalFontInfo;
+
+/** Structure used by KernGlyphs() */
+ typedef struct {
+ int x; /**< positive: right, negative: left */
+ int y; /**< positive: up, negative: down */
+ } KernData;
+
+
+/** ControlPoint structure used by GetTTGlyphPoints() */
+ typedef struct {
+ sal_uInt32 flags; /**< 00000000 00000000 e0000000 bbbbbbbb */
+ /**< b - byte flags from the glyf array */
+ /**< e == 0 - regular point */
+ /**< e == 1 - end contour */
+ sal_Int16 x; /**< X coordinate in EmSquare units */
+ sal_Int16 y; /**< Y coordinate in EmSquare units */
+ } ControlPoint;
+
+ typedef struct _TrueTypeFont TrueTypeFont;
+
+/**
+ * @defgroup sft Sun Font Tools Exported Functions
+ */
+
+
+/**
+ * Get the number of fonts contained in a TrueType collection
+ * @param fname - file name
+ * @return number of fonts or zero, if file is not a TTC file.
+ * @ingroup sft
+ */
+ int CountTTCFonts(const char* fname);
+
+
+/**
+ * TrueTypeFont constructor.
+ * The font file has to be provided as a memory buffer and length
+ * @param facenum - logical font number within a TTC file. This value is ignored
+ * for TrueType fonts
+ * @return value of SFErrCodes enum
+ * @ingroup sft
+ */
+ int OpenTTFontBuffer(void* pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont** ttf); /*FOLD01*/
+#if !defined(WIN32) && !defined(OS2)
+/**
+ * TrueTypeFont constructor.
+ * Reads the font file and allocates the memory for the structure.
+ * on WIN32 the font has to be provided as a memory buffer and length
+ * @param facenum - logical font number within a TTC file. This value is ignored
+ * for TrueType fonts
+ * @return value of SFErrCodes enum
+ * @ingroup sft
+ */
+ int OpenTTFontFile(const char *fname, sal_uInt32 facenum, TrueTypeFont** ttf);
+#endif
+
+/**
+ * TrueTypeFont destructor. Deallocates the memory.
+ * @ingroup sft
+ */
+ void CloseTTFont(TrueTypeFont *);
+
+/**
+ * Extracts TrueType control points, and stores them in an allocated array pointed to
+ * by *pointArray. This function returns the number of extracted points.
+ *
+ * @param ttf pointer to the TrueTypeFont structure
+ * @param glyphID Glyph ID
+ * @param pointArray Return value - address of the pointer to the first element of the array
+ * of points allocated by the function
+ * @return Returns the number of points in *pointArray or -1 if glyphID is
+ * invalid.
+ * @ingroup sft
+ *
+ */
+ int GetTTGlyphPoints(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint **pointArray);
+
+/**
+ * Extracts raw glyph data from the 'glyf' table and returns it in an allocated
+ * GlyphData structure.
+ *
+ * @param ttf pointer to the TrueTypeFont structure
+ * @param glyphID Glyph ID
+ *
+ * @return pointer to an allocated GlyphData structure or NULL if
+ * glyphID is not present in the font
+ * @ingroup sft
+ *
+ */
+ GlyphData *GetTTRawGlyphData(TrueTypeFont *ttf, sal_uInt32 glyphID);
+
+#ifndef NO_LIST
+/**
+ * For a specified glyph adds all component glyphs IDs to the list and
+ * return their number. If the glyph is a single glyph it has one component
+ * glyph (which is added to the list) and the function returns 1.
+ * For a composite glyphs it returns the number of component glyphs
+ * and adds all of them to the list.
+ *
+ * @param ttf pointer to the TrueTypeFont structure
+ * @param glyphID Glyph ID
+ * @param glyphlist list of glyphs
+ *
+ * @return number of component glyphs
+ * @ingroup sft
+ *
+ */
+ int GetTTGlyphComponents(TrueTypeFont *ttf, sal_uInt32 glyphID, list glyphlist);
+#endif
+
+/**
+ * Extracts all Name Records from the font and stores them in an allocated
+ * array of NameRecord structs
+ *
+ * @param ttf pointer to the TrueTypeFont struct
+ * @param nr pointer to the array of NameRecord structs
+ *
+ * @return number of NameRecord structs
+ * @ingroup sft
+ */
+
+ int GetTTNameRecords(TrueTypeFont *ttf, NameRecord **nr);
+
+/**
+ * Deallocates previously allocated array of NameRecords.
+ *
+ * @param nr array of NameRecord structs
+ * @param n number of elements in the array
+ *
+ * @ingroup sft
+ */
+ void DisposeNameRecords(NameRecord* nr, int n);
+
+
+#ifndef NO_TYPE3
+/**
+ * Generates a new PostScript Type 3 font and dumps it to <b>outf</b> file.
+ * This functions subsititues glyph 0 for all glyphIDs that are not found in the font.
+ * @param ttf pointer to the TrueTypeFont structure
+ * @param outf the resulting font is written to this stream
+ * @param fname font name for the new font. If it is NULL the PostScript name of the
+ * original font will be used
+ * @param glyphArray pointer to an array of glyphs that are to be extracted from ttf
+ * @param encoding array of encoding values. encoding[i] specifies the position of the glyph
+ * glyphArray[i] in the encoding vector of the resulting Type3 font
+ * @param nGlyphs number of glyph IDs in glyphArray and encoding values in encoding
+ * @param wmode writing mode for the output file: 0 - horizontal, 1 - vertical
+ * @return return the value of SFErrCodes enum
+ * @see SFErrCodes
+ * @ingroup sft
+ *
+ */
+ int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, sal_uInt16 *glyphArray, sal_uInt8 *encoding, int nGlyphs, int wmode);
+#endif
+
+#ifndef NO_TTCR
+/**
+ * Generates a new TrueType font and dumps it to <b>outf</b> file.
+ * This functions subsititues glyph 0 for all glyphIDs that are not found in the font.
+ * @param ttf pointer to the TrueTypeFont structure
+ * @param fname file name for the output TrueType font file
+ * @param glyphArray pointer to an array of glyphs that are to be extracted from ttf. The first
+ * element of this array has to be glyph 0 (default glyph)
+ * @param encoding array of encoding values. encoding[i] specifies character code for
+ * the glyphID glyphArray[i]. Character code 0 usually points to a default
+ * glyph (glyphID 0)
+ * @param nGlyphs number of glyph IDs in glyphArray and encoding values in encoding
+ * @param nNameRecs number of NameRecords for the font, if 0 the name table from the
+ * original font will be used
+ * @param nr array of NameRecords
+ * @param flags or'ed TTCreationFlags
+ * @return return the value of SFErrCodes enum
+ * @see SFErrCodes
+ * @ingroup sft
+ *
+ */
+ int CreateTTFromTTGlyphs(TrueTypeFont *ttf,
+ const char *fname,
+ sal_uInt16 *glyphArray,
+ sal_uInt8 *encoding,
+ int nGlyphs,
+ int nNameRecs,
+ NameRecord *nr,
+ sal_uInt32 flags);
+#endif
+
+#ifndef NO_TYPE42
+/**
+ * Generates a new PostScript Type42 font and dumps it to <b>outf</b> file.
+ * This functions subsititues glyph 0 for all glyphIDs that are not found in the font.
+ * @param ttf pointer to the TrueTypeFont structure
+ * @param outf output stream for a resulting font
+ * @param psname PostScript name of the resulting font
+ * @param glyphArray pointer to an array of glyphs that are to be extracted from ttf. The first
+ * element of this array has to be glyph 0 (default glyph)
+ * @param encoding array of encoding values. encoding[i] specifies character code for
+ * the glyphID glyphArray[i]. Character code 0 usually points to a default
+ * glyph (glyphID 0)
+ * @param nGlyphs number of glyph IDs in glyphArray and encoding values in encoding
+ * @return SF_OK - no errors
+ * SF_GLYPHNUM - too many glyphs (> 255)
+ * SF_TTFORMAT - corrupted TrueType fonts
+ *
+ * @see SFErrCodes
+ * @ingroup sft
+ *
+ */
+ int CreateT42FromTTGlyphs(TrueTypeFont *ttf,
+ FILE *outf,
+ const char *psname,
+ sal_uInt16 *glyphArray,
+ sal_uInt8 *encoding,
+ int nGlyphs);
+#endif
+
+
+/**
+ * Queries glyph metrics. Allocates an array of TTSimpleGlyphMetrics structs and returns it.
+ *
+ * @param ttf pointer to the TrueTypeFont structure
+ * @param glyphArray pointer to an array of glyphs that are to be extracted from ttf
+ * @param nGlyphs number of glyph IDs in glyphArray and encoding values in encoding
+ * @param mode writing mode: 0 - horizontal, 1 - vertical
+ * @ingroup sft
+ *
+ */
+ TTSimpleGlyphMetrics *GetTTSimpleGlyphMetrics(TrueTypeFont *ttf, sal_uInt16 *glyphArray, int nGlyphs, int mode);
+
+#ifndef NO_MAPPERS
+/**
+ * Queries glyph metrics. Allocates an array of TTSimpleGlyphMetrics structs and returns it.
+ * This function behaves just like GetTTSimpleGlyphMetrics() but it takes a range of Unicode
+ * characters instead of an array of glyphs.
+ *
+ * @param ttf pointer to the TrueTypeFont structure
+ * @param firstChar Unicode value of the first character in the range
+ * @param nChars number of Unicode characters in the range
+ * @param mode writing mode: 0 - horizontal, 1 - vertical
+ *
+ * @see GetTTSimpleGlyphMetrics
+ * @ingroup sft
+ *
+ */
+ TTSimpleGlyphMetrics *GetTTSimpleCharMetrics(TrueTypeFont *ttf, sal_uInt16 firstChar, int nChars, int mode);
+
+/**
+ * Maps a Unicode (UCS-2) string to a glyph array. Returns the number of glyphs in the array,
+ * which for TrueType fonts is always the same as the number of input characters.
+ *
+ * @param ttf pointer to the TrueTypeFont structure
+ * @param str pointer to a UCS-2 string
+ * @param nchars number of characters in <b>str</b>
+ * @param glyphArray pointer to the glyph array where glyph IDs are to be recorded.
+ *
+ * @return MapString() returns -1 if the TrueType font has no usable 'cmap' tables.
+ * Otherwise it returns the number of characters processed: <b>nChars</b>
+ *
+ * glyphIDs of TrueType fonts are 2 byte positive numbers. glyphID of 0 denotes a missing
+ * glyph and traditionally defaults to an empty square.
+ * glyphArray should be at least sizeof(sal_uInt16) * nchars bytes long. If glyphArray is NULL
+ * MapString() replaces the UCS-2 characters in str with glyphIDs.
+ * @ingroup sft
+ */
+ int MapString(TrueTypeFont *ttf, sal_uInt16 *str, int nchars, sal_uInt16 *glyphArray, int bvertical);
+
+/**
+ * Maps a Unicode (UCS-2) character to a glyph ID and returns it. Missing glyph has
+ * a glyphID of 0 so this function can be used to test if a character is encoded in the font.
+ *
+ * @param ttf pointer to the TrueTypeFont structure
+ * @param ch Unicode (UCS-2) character
+ * @return glyph ID, if the character is missing in the font, the return value is 0.
+ * @ingroup sft
+ */
+ sal_uInt16 MapChar(TrueTypeFont *ttf, sal_uInt16 ch, int bvertical);
+
+/**
+ * Returns 0 when the font does not substitute vertical glyphs
+ *
+ * @param ttf pointer to the TrueTypeFont structure
+ */
+ int DoesVerticalSubstitution( TrueTypeFont *ttf, int bvertical);
+
+#endif
+
+/**
+ * Returns global font information about the TrueType font.
+ * @see TTGlobalFontInfo
+ *
+ * @param ttf pointer to a TrueTypeFont structure
+ * @param info pointer to a TTGlobalFontInfo structure
+ * @ingroup sft
+ *
+ */
+ void GetTTGlobalFontInfo(TrueTypeFont *ttf, TTGlobalFontInfo *info);
+
+#ifdef TEST5
+/**
+ * Returns kerning information for an array of glyphs.
+ * Kerning is not cumulative.
+ * kern[i] contains kerning information for a pair of glyphs at positions i and i+1
+ *
+ * @param ttf pointer to a TrueTypeFont structure
+ * @param glyphs array of source glyphs
+ * @param nglyphs number of glyphs in the array
+ * @param wmode writing mode: 0 - horizontal, 1 - vertical
+ * @param kern array of KernData structures. It should contain nglyphs-1 elements
+ * @see KernData
+ * @ingroup sft
+ *
+ */
+ void KernGlyphs(TrueTypeFont *ttf, sal_uInt16 *glyphs, int nglyphs, int wmode, KernData *kern);
+#endif
+
+/**
+ * Returns nonzero if font is a symbol encoded font
+ */
+ int CheckSymbolEncoding(TrueTypeFont* ttf);
+
+/**
+ * returns the number of glyphs in a font
+ */
+ int GetTTGlyphCount( TrueTypeFont* ttf );
+
+/*- private definitions */ /*FOLD00*/
+
+ struct _TrueTypeFont {
+ sal_uInt32 tag;
+
+ char *fname;
+ sal_Int32 fsize;
+ sal_uInt8 *ptr;
+
+ char *psname;
+ char *family;
+ sal_uInt16 *ufamily;
+ char *subfamily;
+ sal_uInt16 *usubfamily;
+
+ sal_uInt32 ntables;
+ sal_uInt32 *goffsets;
+ sal_uInt32 nglyphs;
+ sal_uInt32 unitsPerEm;
+ sal_uInt32 numberOfHMetrics;
+ sal_uInt32 numOfLongVerMetrics; /* if this number is not 0, font has vertical metrics information */
+ sal_uInt8 *cmap;
+ int cmapType;
+ sal_uInt32 (*mapper)(const sal_uInt8 *, sal_uInt32); /* character to glyphID translation function */
+ void **tables; /* array of pointers to tables */
+ sal_uInt32 *tlens; /* array of table lengths */
+ int kerntype; /* Defined in the KernType enum */
+ sal_uInt32 nkern; /* number of kern subtables */
+ sal_uInt8 **kerntables; /* array of pointers to kern subtables */
+ void *pGSubstitution; /* info provided by GSUB for UseGSUB() */
+ };
+
+#ifdef __cplusplus
+}
+#endif
+
+/* indexes into _TrueTypeFont::tables[] and _TrueTypeFont::tlens[] */
+#define O_maxp 0 /* 'maxp' */
+#define O_glyf 1 /* 'glyf' */
+#define O_head 2 /* 'head' */
+#define O_loca 3 /* 'loca' */
+#define O_name 4 /* 'name' */
+#define O_hhea 5 /* 'hhea' */
+#define O_hmtx 6 /* 'hmtx' */
+#define O_cmap 7 /* 'cmap' */
+#define O_vhea 8 /* 'vhea' */
+#define O_vmtx 9 /* 'vmtx' */
+#define O_OS2 10 /* 'OS/2' */
+#define O_post 11 /* 'post' */
+#define O_kern 12 /* 'kern' */
+#define O_cvt 13 /* 'cvt_' - only used in TT->TT generation */
+#define O_prep 14 /* 'prep' - only used in TT->TT generation */
+#define O_fpgm 15 /* 'fpgm' - only used in TT->TT generation */
+#define O_gsub 16 /* 'GSUB' */
+#define NUM_TAGS 17
+
+#endif /* __SUBFONT_H */
diff --git a/vcl/inc/vcl/fontcache.hxx b/vcl/inc/vcl/fontcache.hxx
new file mode 100644
index 000000000000..acc2e1c10092
--- /dev/null
+++ b/vcl/inc/vcl/fontcache.hxx
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: fontcache.hxx,v $
+ * $Revision: 1.9 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _PSPRINT_FONTCACHE_HXX
+#define _PSPRINT_FONTCACHE_HXX
+
+#include "vcl/dllapi.h"
+#include "vcl/fontmanager.hxx"
+
+#include "tools/string.hxx"
+
+#include <hash_map>
+
+namespace psp
+{
+
+class VCL_DLLPUBLIC FontCache
+{
+ struct FontDir;
+ friend class FontDir;
+ struct FontFile;
+ friend class FontFile;
+
+ typedef std::list< PrintFontManager::PrintFont* > FontCacheEntry;
+ struct FontFile
+ {
+ FontCacheEntry m_aEntry;
+ };
+
+ typedef std::hash_map< ::rtl::OString, FontFile, ::rtl::OStringHash > FontDirMap;
+ struct FontDir
+ {
+ sal_Int64 m_nTimestamp;
+ bool m_bNoFiles;
+ bool m_bUserOverrideOnly;
+ FontDirMap m_aEntries;
+
+ FontDir() : m_nTimestamp(0), m_bNoFiles(false), m_bUserOverrideOnly( false ) {}
+ };
+
+ typedef std::hash_map< int, FontDir > FontCacheData;
+ FontCacheData m_aCache;
+ String m_aCacheFile;
+ bool m_bDoFlush;
+
+ void read();
+ void clearCache();
+
+ void copyPrintFont( const PrintFontManager::PrintFont* pFrom, PrintFontManager::PrintFont* pTo ) const;
+ bool equalsPrintFont( const PrintFontManager::PrintFont* pLeft, PrintFontManager::PrintFont* pRight ) const;
+ PrintFontManager::PrintFont* clonePrintFont( const PrintFontManager::PrintFont* pFont ) const;
+
+ void createCacheDir( int nDirID );
+public:
+ FontCache();
+ ~FontCache();
+
+ bool getFontCacheFile( int nDirID, const rtl::OString& rFile, std::list< PrintFontManager::PrintFont* >& rNewFonts ) const;
+ void updateFontCacheEntry( const PrintFontManager::PrintFont*, bool bFlush );
+ void markEmptyDir( int nDirID, bool bNoFiles = true );
+
+ // returns false for non cached directory
+ // a cached but empty directory will return true but not append anything
+ bool listDirectory( const rtl::OString& rDir, std::list< PrintFontManager::PrintFont* >& rNewFonts ) const;
+ // returns true for directoris that contain only user overridden fonts
+ bool scanAdditionalFiles( const rtl::OString& rDir );
+
+ void flush();
+
+ void updateDirTimestamp( int nDirID );
+};
+
+} // namespace psp
+
+#endif // _PSPRINT_FONTCACHE_HXX
diff --git a/vcl/inc/vcl/fontmanager.hxx b/vcl/inc/vcl/fontmanager.hxx
new file mode 100644
index 000000000000..bdfd30d12f7f
--- /dev/null
+++ b/vcl/inc/vcl/fontmanager.hxx
@@ -0,0 +1,748 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: fontmanager.hxx,v $
+ * $Revision: 1.36 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _PSPRINT_FONTMANAGER_HXX_
+#define _PSPRINT_FONTMANAGER_HXX_
+
+#include <hash_map>
+#include <map>
+#include <list>
+#include <set>
+
+#include "vcl/dllapi.h"
+#include "vcl/helper.hxx"
+
+#include "com/sun/star/lang/Locale.hpp"
+
+#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
+};
+}
+
+namespace fcstatus
+{
+enum type {
+ istrue,
+ isunset,
+ isfalse
+};
+}
+
+/*
+ * 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;
+ rtl::OUString m_aStyleName;
+ std::list< rtl::OUString > m_aAliases;
+ family::type m_eFamilyStyle;
+ italic::type m_eItalic;
+ width::type m_eWidth;
+ weight::type m_eWeight;
+ pitch::type m_ePitch;
+ rtl_TextEncoding m_aEncoding;
+ fcstatus::type m_eEmbeddedbitmap;
+ fcstatus::type m_eAntialias;
+
+ FastPrintFontInfo() :
+ m_nID( 0 ),
+ m_eType( fonttype::Unknown ),
+ m_eFamilyStyle( family::Unknown ),
+ m_eItalic( italic::Unknown ),
+ m_eWidth( width::Unknown ),
+ m_eWeight( weight::Unknown ),
+ m_ePitch( pitch::Unknown ),
+ m_aEncoding( RTL_TEXTENCODING_DONTKNOW ),
+ m_eEmbeddedbitmap( fcstatus::isunset ),
+ m_eAntialias( fcstatus::isunset )
+ {}
+};
+
+struct PrintFontInfo : public FastPrintFontInfo
+{
+ int m_nAscend;
+ int m_nDescend;
+ int m_nLeading;
+ int m_nWidth;
+
+ PrintFontInfo() :
+ FastPrintFontInfo(),
+ m_nAscend( 0 ),
+ m_nDescend( 0 ),
+ m_nLeading( 0 ),
+ m_nWidth( 0 )
+ {}
+};
+
+// 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 ) {}
+ bool operator==( const CharacterMetric& rOther ) const
+ { return rOther.width == width && rOther.height == height; }
+ bool operator!=( const CharacterMetric& rOther ) const
+ { return rOther.width != width || rOther.height != height; }
+};
+
+struct KernPair
+{
+ sal_Unicode first, second;
+ short int kern_x, kern_y;
+
+ KernPair() : first( 0 ), second( 0 ), kern_x( 0 ), kern_y( 0 ) {}
+};
+
+class FontCache;
+
+// a class to manage printable fonts
+// aims are type1 and truetype fonts
+
+class FontCache;
+
+class VCL_DLLPUBLIC PrintFontManager
+{
+ struct PrintFont;
+ struct TrueTypeFontFile;
+ struct Type1FontFile;
+ struct BuiltinFont;
+ friend struct PrintFont;
+ friend struct TrueTypeFontFile;
+ friend struct Type1FontFile;
+ friend struct BuiltinFont;
+ friend class FontCache;
+
+ 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;
+ std::hash_map< sal_Unicode, bool > m_bVerticalSubstitutions;
+
+ PrintFontMetrics() : m_bKernPairsQueried( false ) {}
+
+ bool isEmpty() const { return m_aMetrics.empty(); }
+ };
+
+ struct PrintFont
+ {
+ fonttype::type m_eType;
+
+ // font attributes
+ int m_nFamilyName; // atom
+ std::list< int > m_aAliases;
+ int m_nPSName; // atom
+ rtl::OUString m_aStyleName;
+ italic::type m_eItalic;
+ width::type m_eWidth;
+ weight::type m_eWeight;
+ pitch::type m_ePitch;
+ rtl_TextEncoding m_aEncoding;
+ bool m_bFontEncodingOnly; // set if font should be only accessed by builtin encoding
+ CharacterMetric m_aGlobalMetricX;
+ CharacterMetric m_aGlobalMetricY;
+ PrintFontMetrics* m_pMetrics;
+ int m_nAscend;
+ int m_nDescend;
+ int m_nLeading;
+ int m_nXMin; // font bounding box
+ int m_nYMin;
+ int m_nXMax;
+ int m_nYMax;
+ bool m_bHaveVerticalSubstitutedGlyphs;
+ bool m_bUserOverride;
+
+ fcstatus::type m_eEmbeddedbitmap;
+ fcstatus::type m_eAntialias;
+
+ std::map< sal_Unicode, sal_Int32 > m_aEncodingVector;
+ std::map< sal_Unicode, rtl::OString > m_aNonEncoded;
+
+ PrintFont( fonttype::type eType );
+ virtual ~PrintFont();
+ virtual bool queryMetricPage( int nPage, utl::MultiAtomProvider* pProvider ) = 0;
+
+ bool readAfmMetrics( const rtl::OString& rFileName, utl::MultiAtomProvider* pProvider, bool bFillEncodingvector, bool bOnlyGlobalAttributes );
+ };
+
+ 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 ), m_nDirectory( 0 ) {}
+ 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
+ unsigned int m_nTypeFlags; // from TrueType file; only known use is for copyright flags
+
+ TrueTypeFontFile() : PrintFont( fonttype::TrueType ), m_nDirectory( 0 ), m_nCollectionEntry(-1), m_nTypeFlags( 0x80000000 ) {}
+ 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 );
+ };
+
+ struct XLFDEntry
+ {
+ static const int MaskFoundry = 1;
+ static const int MaskFamily = 2;
+ static const int MaskAddStyle = 4;
+ static const int MaskItalic = 8;
+ static const int MaskWeight = 16;
+ static const int MaskWidth = 32;
+ static const int MaskPitch = 64;
+ static const int MaskEncoding = 128;
+
+ int nMask; // contains a bit set for every valid member
+
+ rtl::OString aFoundry;
+ rtl::OString aFamily;
+ rtl::OString aAddStyle;
+ italic::type eItalic;
+ weight::type eWeight;
+ width::type eWidth;
+ pitch::type ePitch;
+ rtl_TextEncoding aEncoding;
+
+ XLFDEntry() { nMask = 0; }
+
+ bool operator<(const XLFDEntry& rRight) const;
+ bool operator==(const XLFDEntry& rRight) const;
+ };
+
+ static rtl::OString s_aEmptyOString;
+
+ 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;
+ std::list< int > m_aPrivateFontDirectories;
+ std::map< struct XLFDEntry, std::list< struct XLFDEntry > >
+ m_aXLFD_Aliases;
+ utl::MultiAtomProvider* m_pAtoms;
+ // for speeding up findFontFileID
+ std::hash_map< rtl::OString, std::set< fontID >, rtl::OStringHash >
+ m_aFontFileToFontID;
+
+ std::hash_map< rtl::OString, int, rtl::OStringHash >
+ m_aDirToAtom;
+ std::hash_map< int, rtl::OString > m_aAtomToDir;
+ int m_nNextDirAtom;
+
+ std::hash_multimap< rtl::OString, sal_Unicode, rtl::OStringHash >
+ m_aAdobenameToUnicode;
+ std::hash_multimap< sal_Unicode, rtl::OString >
+ m_aUnicodeToAdobename;
+ std::hash_multimap< sal_Unicode, sal_uInt8 > m_aUnicodeToAdobecode;
+ std::hash_multimap< sal_uInt8, sal_Unicode > m_aAdobecodeToUnicode;
+
+ mutable FontCache* m_pFontCache;
+ bool m_bFontconfigSuccess;
+
+ mutable std::vector< fontID > m_aOverrideFonts;
+
+ rtl::OString getAfmFile( PrintFont* pFont ) const;
+ rtl::OString getFontFile( PrintFont* pFont ) const;
+
+ void getFontAttributesFromXLFD( PrintFont* pFont, const std::list< rtl::OString >& rXLFDs ) const;
+
+ bool analyzeFontFile( int nDirID, const rtl::OString& rFileName, const std::list< rtl::OString >& rXLFDs, std::list< PrintFont* >& rNewFonts ) const;
+ rtl::OUString convertTrueTypeName( void* pNameRecord ) const; // actually a NameRecord* formt font subsetting code
+ void analyzeTrueTypeFamilyName( void* pTTFont, std::list< rtl::OUString >& rnames ) const; // actually a TrueTypeFont* from font subsetting code
+ 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< fontID, PrintFont* >::const_iterator it;
+ it = m_aFonts.find( nID );
+ return it == m_aFonts.end() ? NULL : it->second;
+ }
+ rtl::OString 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 );
+
+ /* try to initialize fonts from libfontconfig
+
+ called from <code>initialize()</code>
+
+ @returns
+ true if at least one font was added by libfontconfig
+ false else (e.g. no libfontconfig found)
+ */
+ bool initFontconfig();
+ int countFontconfigFonts();
+ /* deinitialize fontconfig
+ */
+ void deinitFontconfig();
+
+ /* register an application specific font directory for libfontconfig
+
+ since fontconfig is asked for font substitutes before OOo will check for font availability
+ and fontconfig will happily substitute fonts it doesn't know (e.g. "Arial Narrow" -> "DejaVu Sans Book"!)
+ it becomes necessary to tell the library about all the hidden font treasures
+
+ @returns
+ true if libfontconfig accepted the directory
+ false else (e.g. no libfontconfig found)
+ */
+ bool addFontconfigDir(const rtl::OString& rDirectory);
+
+ static bool parseXLFD( const rtl::OString& rXLFD, XLFDEntry& rEntry );
+ void parseXLFD_appendAliases( const std::list< rtl::OString >& rXLFDs, std::list< XLFDEntry >& rEntries ) const;
+ void initFontsAlias();
+
+ bool readOverrideMetrics();
+
+ PrintFontManager();
+ ~PrintFontManager();
+public:
+ static PrintFontManager& get(); // one instance only
+
+ int addFontFile( const rtl::OString& rFileName, int nFaceNum );
+
+ void initialize();
+
+ // returns the number of managed fonts
+ int getFontCount() const { return m_aFonts.size(); }
+
+ // caution: the getFontList* methods can change the font list on demand
+ // depending on the pParser argument. That is getFontCount() may
+ // return a larger value after getFontList()
+
+ // 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, bool bUseOverrideMetrics = false );
+ // get the font list and detailed font info. see getFontList for pParser
+ void getFontListWithInfo( std::list< PrintFontInfo >& rFonts, const PPDParser* pParser = NULL, bool bUseOverrideMetrics = false );
+ // get the font list and fast font info. see getFontList for pParser
+ void getFontListWithFastInfo( std::list< FastPrintFontInfo >& rFonts, const PPDParser* pParser = NULL, bool bUseOverrideMetrics = false );
+
+ // 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 getFontFamilyType( fontID nFontID ) const;
+
+ // get a specific fonts family name aliases
+ void getFontFamilyAliases( 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;
+ }
+
+ // should i only use font's builtin encoding ?
+ bool getUseOnlyFontEncoding( fontID nFontID ) const
+ {
+ PrintFont* pFont = getFont( nFontID );
+ return pFont ? pFont->m_bFontEncodingOnly : false;
+ }
+
+ // 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;
+
+ // 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 a fonts glyph bounding box
+ bool getFontBoundingBox( fontID nFont, int& xMin, int& yMin, int& xMax, int& yMax );
+
+ // info whether there are vertical substitutions
+ bool hasVerticalSubstitutions( fontID nFontID ) const;
+
+ // info whether an array of glyphs has vertical substitutions
+ void hasVerticalSubstitutions( fontID nFontID, const sal_Unicode* pCharacters,
+ int nCharacters, bool* pHasSubst ) 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;
+
+ // get encoding vector of font, currently only for Type1 and Builtin fonts
+ // returns NULL if encoding vector is empty or font is neither type1 or
+ // builtin; if ppNonEncoded is set and non encoded type1 glyphs exist
+ // then *ppNonEncoded is set to the mapping for nonencoded glyphs.
+ // the encoding vector contains -1 for non encoded glyphs
+ const std::map< sal_Unicode, sal_Int32 >* getEncodingMap( fontID nFontID, const std::map< sal_Unicode, rtl::OString >** ppNonEncoded ) const;
+
+ // to get font substitution transparently use the
+ // getKernPairs method of PrinterGfx
+ const std::list< KernPair >& getKernPairs( fontID nFontID, bool bVertical = false ) const;
+
+ // evaluates copyright flags for TrueType fonts
+ // type1 fonts do not have such a feature, so return for them is true
+ // returns true for builtin fonts (surprise!)
+ bool isFontDownloadingAllowed( fontID nFont ) const;
+
+ // helper for type 1 fonts
+ std::list< rtl::OString > getAdobeNameFromUnicode( sal_Unicode aChar ) const;
+
+ std::pair< std::hash_multimap< sal_Unicode, sal_uInt8 >::const_iterator,
+ std::hash_multimap< sal_Unicode, sal_uInt8 >::const_iterator >
+ getAdobeCodeFromUnicode( sal_Unicode aChar ) const
+ {
+ return m_aUnicodeToAdobecode.equal_range( aChar );
+ }
+ std::list< sal_Unicode > getUnicodeFromAdobeName( const rtl::OString& rName ) const;
+ std::pair< std::hash_multimap< sal_uInt8, sal_Unicode >::const_iterator,
+ std::hash_multimap< sal_uInt8, sal_Unicode >::const_iterator >
+ getUnicodeFromAdobeCode( sal_uInt8 aChar ) const
+ {
+ return m_aAdobecodeToUnicode.equal_range( aChar );
+ }
+
+ // creates a new font subset of an existing TrueType font
+ // returns true in case of success, else false
+ // nFont: the font to be subsetted
+ // rOutFile: the file to put the new subset into;
+ // must be a valid osl file URL
+ // pGlyphIDs: input array of glyph ids for new font
+ // pNewEncoding: the corresponding encoding in the new font
+ // pWidths: output array of widths of requested glyphs
+ // nGlyphs: number of glyphs in arrays
+ // pCapHeight:: capital height of the produced font
+ // pXMin, pYMin, pXMax, pYMax: outgoing font bounding box
+ bool createFontSubset( fontID nFont,
+ const rtl::OUString& rOutFile,
+ sal_Int32* pGlyphIDs,
+ sal_uInt8* pNewEncoding,
+ sal_Int32* pWidths,
+ int nGlyphs,
+ bool bVertical = false
+ );
+ void getGlyphWidths( fontID nFont,
+ bool bVertical,
+ std::vector< sal_Int32 >& rWidths,
+ std::map< sal_Unicode, sal_uInt32 >& rUnicodeEnc );
+
+
+ // 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::OString >& rFiles, bool bLinkOnly = false, 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 );
+
+ // get properties of a not imported font file
+ bool getImportableFontProperties( const rtl::OString& rFile, std::list< FastPrintFontInfo >& rFontProps );
+
+ // get fonts that come from the same font file
+ bool getFileDuplicates( fontID nFont, std::list< fontID >& rFonts ) const;
+ // remove font files
+ bool removeFonts( const std::list< fontID >& rFonts );
+
+ bool isPrivateFontFile( fontID ) const;
+
+ // returns false if there were not any
+ bool getAlternativeFamilyNames( fontID nFont, std::list< rtl::OUString >& rNames ) const;
+
+ /* system dependendent font matching
+
+ <p>
+ <code>matchFont</code> matches a pattern of font characteristics
+ and returns the closest match if possibe. If a match was found
+ the <code>FastPrintFontInfo</code> passed in as parameter
+ will be update to the found matching font.
+ </p>
+ <p>
+ implementation note: currently the function is only implemented
+ for fontconfig.
+ </p>
+
+ @param rInfo
+ out of the FastPrintFontInfo structure the following
+ fields will be used for the match:
+ <ul>
+ <li>family name</li>
+ <li>italic</li>
+ <li>width</li>
+ <li>weight</li>
+ <li>pitch</li>
+ </ul>
+
+ @param rLocale
+ if <code>rLocal</code> contains non empty strings the corresponding
+ locale will be used for font matching also; e.g. "Sans" can result
+ in different fonts in e.g. english and japanese
+
+ @returns
+ true if a match was found
+ false else
+ */
+ bool matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale );
+
+ rtl::OUString Substitute( const rtl::OUString& rFontName, rtl::OUString& rMissingCodes,
+ const rtl::OString& rLangAttrib, italic::type eItalic, weight::type eWeight,
+ width::type eWidth, pitch::type ePitch) const;
+ bool hasFontconfig() const { return m_bFontconfigSuccess; }
+
+ int FreeTypeCharIndex( void *pFace, sal_uInt32 aChar );
+};
+
+} // namespace
+
+#endif // _PSPRINT_FONTMANAGER_HXX_
diff --git a/vcl/inc/vcl/helper.hxx b/vcl/inc/vcl/helper.hxx
new file mode 100644
index 000000000000..04576e30b516
--- /dev/null
+++ b/vcl/inc/vcl/helper.hxx
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: helper.hxx,v $
+ * $Revision: 1.11 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _PSPRINT_HELPER_HXX_
+#define _PSPRINT_HELPER_HXX_
+
+#include <list>
+
+#include "vcl/dllapi.h"
+
+#include "rtl/ustring.hxx"
+
+
+// forwards
+namespace osl { class File; }
+
+namespace psp {
+typedef int fontID;
+
+void VCL_DLLPUBLIC getPrinterPathList( std::list< rtl::OUString >& rPathList, const char* pSubDir );
+
+// note: gcc 3.4.1 warns about visibility if we retunr a const rtl::OUString& here
+// seems to be a bug in gcc, now we return an object instead of a reference
+rtl::OUString VCL_DLLPUBLIC getFontPath();
+
+bool VCL_DLLPUBLIC convertPfbToPfa( osl::File& rInFile, osl::File& rOutFile );
+
+// normalized path (equivalent to realpath)
+void VCL_DLLPUBLIC normPath( rtl::OString& rPath );
+
+// splits rOrgPath into dirname and basename
+// rOrgPath will be subject to normPath
+void VCL_DLLPUBLIC splitPath( rtl::OString& rOrgPath, rtl::OString& rDir, rtl::OString& rBase );
+
+enum whichOfficePath { NetPath, UserPath, ConfigPath };
+// note: gcc 3.4.1 warns about visibility if we retunr a const rtl::OUString& here
+// seems to be a bug in gcc, now we return an object instead of a reference
+rtl::OUString VCL_DLLPUBLIC getOfficePath( enum whichOfficePath ePath );
+} // namespace
+
+#endif // _PSPRINT_HELPER_HXX_
diff --git a/vcl/inc/vcl/jobdata.hxx b/vcl/inc/vcl/jobdata.hxx
new file mode 100644
index 000000000000..4451c566b5bf
--- /dev/null
+++ b/vcl/inc/vcl/jobdata.hxx
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: jobdata.hxx,v $
+ * $Revision: 1.5 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _PSPRINT_JOBDATA_HXX_
+#define _PSPRINT_JOBDATA_HXX_
+
+#include "vcl/ppdparser.hxx"
+
+namespace psp {
+
+namespace orientation {
+enum type {
+ Portrait,
+ Landscape
+};
+}
+
+struct JobData
+{
+ int m_nCopies;
+ 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_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 ) {}
+
+ JobData& operator=(const psp::JobData& rRight);
+
+ JobData( const JobData& rData ) { *this = rData; }
+
+ // 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/vcl/inc/vcl/ppdparser.hxx b/vcl/inc/vcl/ppdparser.hxx
new file mode 100644
index 000000000000..5fa47d412f26
--- /dev/null
+++ b/vcl/inc/vcl/ppdparser.hxx
@@ -0,0 +1,333 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: ppdparser.hxx,v $
+ * $Revision: 1.12.10.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _PSPRINT_PPDPARSER_HXX_
+#define _PSPRINT_PPDPARSER_HXX_
+
+#include <list>
+#include <vector>
+#include <hash_map>
+
+#include "tools/string.hxx"
+#include "tools/stream.hxx"
+
+#define PRINTER_PPDDIR "driver"
+
+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;
+
+ 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;
+
+ void eraseValue( const String& rOption );
+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* getValueCaseInsensitive( 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; }
+};
+
+// define a hash for PPDKey
+struct PPDKeyhash
+{
+ size_t operator()( const PPDKey * pKey) const
+ { return (size_t)pKey; }
+};
+
+// ----------------------------------------------------------------------
+
+/*
+ * PPDParser - parses a PPD file and contains all available keys from it
+ */
+
+class PPDContext;
+class CUPSManager;
+
+class PPDParser
+{
+ friend class PPDContext;
+ friend class CUPSManager;
+
+ 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
+ {
+ 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 ) {}
+ };
+private:
+
+ static ::std::list< PPDParser* > aAllParsers;
+ static ::std::hash_map< rtl::OUString, rtl::OUString, rtl::OUStringHash >*
+ pAllPPDFiles;
+
+ hash_type m_aKeys;
+ value_type m_aOrderedKeys;
+ ::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;
+ rtl_TextEncoding m_aFileEncoding;
+
+
+ // 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 ByteString& rLine );
+ void parseOpenUI( const ByteString& rLine );
+ void parseConstraint( const ByteString& rLine );
+ void parse( std::list< ByteString >& rLines );
+
+ String handleTranslation( const ByteString& rString );
+
+ static void scanPPDDir( const String& rDir );
+ static void initPPDFiles();
+ static String getPPDFile( const String& rFile );
+public:
+ static const PPDParser* getParser( const String& rFile );
+ static String getPPDPrinterName( const String& rFile );
+ static void freeAll();
+ static void getKnownPPDDrivers( std::list< rtl::OUString >& o_rDrivers );
+
+ 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;
+ 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
+{
+ typedef ::std::hash_map< const PPDKey*, const PPDValue*, PPDKeyhash > hash_type;
+ hash_type 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
+ int getRenderResolution() 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/vcl/inc/vcl/printergfx.hxx b/vcl/inc/vcl/printergfx.hxx
new file mode 100644
index 000000000000..3bb242c802dd
--- /dev/null
+++ b/vcl/inc/vcl/printergfx.hxx
@@ -0,0 +1,444 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: printergfx.hxx,v $
+ * $Revision: 1.19.18.1 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _PSPRINT_PRINTERGFX_HXX_
+#define _PSPRINT_PRINTERGFX_HXX_
+
+#include "vcl/helper.hxx"
+#include "osl/file.hxx"
+#include "tools/gen.hxx"
+
+#include <list>
+#include <hash_map>
+
+namespace psp {
+
+// forwards
+class JobData;
+
+/*
+ * lightweight container to handle RGB values
+ */
+
+class PrinterColor
+{
+public:
+
+ 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) :
+ mnRed ((nRGB & 0x00ff0000) >> 16),
+ mnGreen ((nRGB & 0x0000ff00) >> 8),
+ mnBlue ((nRGB & 0x000000ff) ),
+ meColorspace (eRGB)
+ {}
+ ~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;
+ }
+ sal_Bool operator!= (const PrinterColor& aColor) const
+ { return ! (aColor==*this); }
+ 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 Font3;
+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;
+};
+
+typedef enum {
+ InvalidType = 0,
+ TrueColorImage,
+ MonochromeImage,
+ PaletteImage,
+ GrayScaleImage
+} ImageType;
+
+/*
+ * printer raster operations
+ */
+
+struct GraphicsStatus
+{
+ rtl::OString maFont;
+ rtl_TextEncoding maEncoding;
+ bool mbArtItalic;
+ bool mbArtBold;
+ sal_Int32 mnTextHeight;
+ sal_Int32 mnTextWidth;
+ PrinterColor maColor;
+ double mfLineWidth;
+
+ GraphicsStatus();
+};
+
+class Font3;
+
+class PrinterGfx
+{
+private:
+
+ /* common settings */
+
+ double mfScaleX;
+ double mfScaleY;
+
+ sal_uInt32 mnDpi;
+ 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 mnTextAngle;
+ bool mbTextVertical;
+ PrintFontManager& mrFontMgr;
+
+ /* bitmap drawing implementation */
+
+ sal_Bool mbCompressBmp;
+
+ void DrawPS1GrayImage (const PrinterBmp& rBitmap, const Rectangle& rArea);
+ void writePS2ImageHeader (const Rectangle& rArea, psp::ImageType nType);
+ void writePS2Colorspace (const PrinterBmp& rBitmap, psp::ImageType nType);
+ void DrawPS2GrayImage (const PrinterBmp& rBitmap, const Rectangle& rArea);
+ void DrawPS2PaletteImage (const PrinterBmp& rBitmap, const Rectangle& rArea);
+ void DrawPS2TrueColorImage (const PrinterBmp& rBitmap, const Rectangle& rArea);
+ void DrawPS2MonoImage (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 */
+ PrinterColor maFillColor;
+ PrinterColor maTextColor;
+ PrinterColor maLineColor;
+
+ /* graphics state */
+ GraphicsStatus maVirtualStatus;
+ std::list< GraphicsStatus > maGraphicsStack;
+ GraphicsStatus& currentState() { return maGraphicsStack.front(); }
+
+ /* font / font substitution */
+ friend class Font3;
+ const ::std::hash_map< fontID, fontID >* mpFontSubstitutes;
+ int getCharWidth (sal_Bool b_vert, sal_Unicode n_char,
+ CharacterMetric *p_bbox);
+ fontID getCharMetric (const Font3 &rFont, sal_Unicode n_char,
+ CharacterMetric *p_bbox);
+ fontID getFontSubstitute () const;
+ fontID getFallbackID () const { return mnFallbackID; }
+
+ bool mbStrictSO52Compatibility;
+public:
+ /* grahics status update */
+ void PSSetColor ();
+ void PSSetLineWidth ();
+ void PSSetFont ();
+
+ /* graphics status functions */
+ void PSSetColor (const PrinterColor& rColor)
+ { maVirtualStatus.maColor = rColor; }
+
+ void PSUploadPS1Font (sal_Int32 nFontID);
+ void PSSetFont (const rtl::OString& rName,
+ rtl_TextEncoding nEncoding = RTL_TEXTENCODING_DONTKNOW)
+ { maVirtualStatus.maFont = rName; maVirtualStatus.maEncoding = nEncoding; }
+
+ /* graphics status stack */
+ void PSGSave ();
+ void PSGRestore ();
+
+
+ /* PS helpers */
+ 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 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 PSComment (const sal_Char* pComment );
+ 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,
+ 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);
+
+ void drawGlyphs( const Point& rPoint,
+ sal_uInt32* pGlyphIds,
+ sal_Unicode* pUnicodes,
+ sal_Int16 nLen,
+ sal_Int32* pDeltaArray );
+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;
+ 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);
+ 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);
+
+ // 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,
+ bool bArtItalic,
+ bool bArtBold
+ );
+ sal_uInt16 SetFallbackFont ( sal_Int32 nFontID );
+ sal_Int32 GetFontAngle () const
+ { return mnTextAngle; }
+ sal_Int32 GetFontID () const
+ { return mnFontID; }
+ bool GetFontVertical() const
+ { return mbTextVertical; }
+ sal_Int32 GetFontHeight () const
+ { return maVirtualStatus.mnTextHeight; }
+ sal_Int32 GetFontWidth () const
+ { return maVirtualStatus.mnTextWidth; }
+ bool GetArtificialItalic() const
+ { return maVirtualStatus.mbArtItalic; }
+ bool GetArtificialBold() const
+ { return maVirtualStatus.mbArtBold; }
+ 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);
+
+ // for CTL
+ void DrawGlyphs( const Point& rPoint,
+ sal_uInt32* pGlyphIds,
+ sal_Unicode* pUnicodes,
+ sal_Int16 nLen,
+ sal_Int32* pDeltaArray );
+
+ bool getStrictSO52Compatibility() const;
+ void setStrictSO52Compatibility( bool );
+};
+
+} /* namespace psp */
+
+
+#endif /* _PSPRINT_PRINTERGFX_HXX_ */
+
diff --git a/vcl/inc/vcl/printerinfomanager.hxx b/vcl/inc/vcl/printerinfomanager.hxx
new file mode 100644
index 000000000000..810ad428c9db
--- /dev/null
+++ b/vcl/inc/vcl/printerinfomanager.hxx
@@ -0,0 +1,242 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: printerinfomanager.hxx,v $
+ * $Revision: 1.20 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _PSPRINT_PRINTERINFOMANAGER_HXX_
+#define _PSPRINT_PRINTERINFOMANAGER_HXX_
+
+#include <hash_map>
+#include <list>
+
+#include "vcl/dllapi.h"
+#include "vcl/helper.hxx"
+#include "vcl/jobdata.hxx"
+#include "vcl/helper.hxx"
+#include "osl/file.hxx"
+
+#include <cstdio>
+
+namespace psp
+{
+
+class SystemQueueInfo;
+
+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 command line to pipe a PS-file to in case of direct print
+ rtl::OUString m_aQuickCommand;
+ // a list of special features separated by ',' not used by psprint
+ // but assigned from the outside (currently for "fax","pdf=","autoqueue","external_dialog")
+ 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;
+
+ PrinterInfo() :
+ JobData(),
+ m_bPerformFontSubstitution( false )
+ {}
+};
+
+class VCL_DLLPUBLIC PrinterInfoManager
+{
+public:
+ enum Type { Default = 0, CUPS = 1 };
+
+ struct SystemPrintQueue
+ {
+ rtl::OUString m_aQueue;
+ rtl::OUString m_aLocation;
+ rtl::OUString m_aComment;
+ };
+protected:
+ // 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;
+ // details other config files that have this printer
+ // in case of removal all have to be removed
+ std::list< rtl::OUString > m_aAlternateFiles;
+ // 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;
+ // whether 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< SystemPrintQueue > m_aSystemPrintQueues;
+
+ SystemQueueInfo* m_pQueueInfo;
+
+ Type m_eType;
+ bool m_bUseIncludeFeature;
+ rtl::OUString m_aSystemDefaultPaper;
+
+ bool m_bDisableCUPS;
+
+ PrinterInfoManager( Type eType = Default );
+ virtual ~PrinterInfoManager();
+
+ virtual void initialize();
+
+ // fill in font substitutions
+ // the resulting hash_map maps from source to target font ids
+ void fillFontSubstitutions( PrinterInfo& rInfo ) const;
+
+ // fill default paper if not configured in config file
+ // default paper is e.g. locale dependent
+ // if a paper is already set it will not be overwritten
+ void setDefaultPaper( PPDContext& rInfo ) const;
+
+ void initSystemDefaultPaper();
+public:
+
+ // there can only be one
+ static PrinterInfoManager& get();
+
+ // get PrinterInfoManager type
+ Type getType() const { return m_eType; }
+
+ // 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; }
+
+ virtual void setupJobContextData( JobData& rData );
+
+ // changes the info about a named printer
+ virtual void changePrinterInfo( const rtl::OUString& rPrinter, const PrinterInfo& rNewInfo );
+
+ // check if the printer configuration has changed
+ // if bwait is true, then this method waits for eventual asynchronous
+ // printer discovery to finish
+ virtual bool checkPrintersChanged( bool bWait );
+
+ // 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
+ virtual bool addPrinter( const rtl::OUString& rPrinterName, const rtl::OUString& rDriverName );
+
+ // remove a named printer
+ // this fails if the config file belonging to this printer
+ // is not writeable
+ // if bCheckOnly is true, the printer is not really removed;
+ // this is for checking if the removal would fail
+ virtual bool removePrinter( const rtl::OUString& rPrinterName, bool bCheckOnly = false );
+
+ // save the changes to all printers. this fails if there
+ // is no writable config file at all
+ virtual bool writePrinterConfig();
+
+ // set a new default printer
+ // fails if the specified printer does not exist
+ virtual bool setDefaultPrinter( const rtl::OUString& rPrinterName );
+
+ // primarily used internally but also by padmin
+ // returns the printer queue names
+ virtual const std::list< SystemPrintQueue >& getSystemPrintQueues();
+
+ // similar but returnse whole commandlines
+ virtual void getSystemPrintCommands( std::list< rtl::OUString >& rCommands );
+
+ // abstract print command
+ // returns a stdio FILE* that a postscript file may be written to
+ // this may either be a regular file or the result of popen()
+ virtual FILE* startSpool( const rtl::OUString& rPrinterName, bool bQuickCommand );
+ // close the FILE* returned by startSpool and does the actual spooling
+ // returns a numerical job id
+ virtual int endSpool( const rtl::OUString& rPrinterName, const rtl::OUString& rJobTitle, FILE* pFile, const JobData& rDocumentJobData );
+
+ // for spadmin: whether adding or removing a printer is possible
+ virtual bool addOrRemovePossible() const;
+
+ bool getUseIncludeFeature() const { return m_bUseIncludeFeature; }
+
+ // check whether a printer's feature string contains a subfeature
+ bool checkFeatureToken( const rtl::OUString& rPrinterName, const char* pToken ) const;
+
+ // set m_bDisableCUPS and update printer config
+ void setCUPSDisabled( bool );
+
+ // gets m_bDisableCUPS, initialized from printer config
+ bool isCUPSDisabled() const;
+};
+
+} // namespace
+
+#endif // _PSPRINT_PRINTERINFOMANAGER_HXX_
diff --git a/vcl/inc/vcl/printerjob.hxx b/vcl/inc/vcl/printerjob.hxx
new file mode 100644
index 000000000000..9880700d4008
--- /dev/null
+++ b/vcl/inc/vcl/printerjob.hxx
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: printerjob.hxx,v $
+ * $Revision: 1.12 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _PSPRINT_PRINTERJOB_HXX_
+#define _PSPRINT_PRINTERJOB_HXX_
+
+#include "vcl/jobdata.hxx"
+#include "osl/file.hxx"
+#include "rtl/string.hxx"
+
+#include <list>
+
+namespace psp {
+
+// forward declarations
+class PrinterGfx;
+
+
+class PrinterJob
+{
+private: // private data
+
+ rtl::OUString maSpoolDirName;
+ rtl::OUString maFileName; // empty: spool to command, else spool to named file
+ rtl::OUString maJobTitle;
+ int mnFileMode;
+
+ osl::File* mpJobHeader;
+ osl::File* mpJobTrailer;
+
+ 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;
+
+ int mnLandscapes;
+ int mnPortraits;
+
+ sal_uInt32 mnLMarginPt;
+ sal_uInt32 mnRMarginPt;
+ sal_uInt32 mnTMarginPt;
+ sal_uInt32 mnBMarginPt;
+
+ double mfXScale;
+ double mfYScale;
+
+ sal_Int32 mnErrorCode;
+ bool m_bQuickJob;
+
+private: // private methods
+
+ osl::File* CreateSpoolFile (const rtl::OUString& rName,
+ const rtl::OUString& rExtension);
+ void InitPaperSize (const JobData& rJobSetup);
+
+ bool writeFeatureList( osl::File* pFile, const JobData&, bool bDocumentSetup );
+ bool writeSetup( osl::File* pFile, const JobData& );
+ bool writePageSetup( osl::File* pFile, const JobData& );
+ void writeJobPatch( osl::File* File, const JobData& );
+ bool writeProlog (osl::File* pFile, const JobData& );
+
+public: // for usage in PrinterGfx
+
+ sal_uInt32 GetResolution () const { return mnResolution; }
+ 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 ();
+
+ /* 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
+ * bIsQuickJob: the job was started as "direct print" meaning
+ * the quick command for spooling should be used instead
+ * of the normal command
+ */
+ sal_Bool StartJob (const rtl::OUString& rFileName,
+ int nMode,
+ const rtl::OUString& rJobName,
+ const rtl::OUString& rAppName,
+ const JobData& rSetupData,
+ PrinterGfx* pGraphics,
+ bool bIsQuickJob
+ );
+ sal_Bool EndJob ();
+
+ sal_Bool AbortJob ();
+
+ sal_Bool StartPage (const JobData& rJobSetup);
+ sal_Bool EndPage ();
+
+ sal_uInt32 GetErrorCode ();
+};
+
+} /* namespace psp */
+
+#endif /* _PSPRINT_PRINTERJOB_HXX_ */
+
diff --git a/vcl/inc/vcl/salinst.hxx b/vcl/inc/vcl/salinst.hxx
index cf88b7813ec8..221c9e370ea6 100644
--- a/vcl/inc/vcl/salinst.hxx
+++ b/vcl/inc/vcl/salinst.hxx
@@ -31,14 +31,14 @@
#ifndef _SV_SALINST_HXX
#define _SV_SALINST_HXX
-#ifdef __cplusplus
+#include "vcl/sv.h"
+#include "vcl/dllapi.h"
-#include <tools/string.hxx>
-#endif // __cplusplus
-#include <vcl/sv.h>
-#include <vcl/dllapi.h>
+#include "tools/string.hxx"
-#ifdef __cplusplus
+#include "rtl/string.hxx"
+
+#include <list>
struct SystemParentData;
struct SalPrinterQueueInfo;
@@ -171,6 +171,11 @@ public:
enum ConnectionIdentifierType { AsciiCString, Blob };
virtual void* GetConnectionIdentifier( ConnectionIdentifierType& rReturnedType, int& rReturnedBytes ) = 0;
+
+ // this is a vehicle for PrintFontManager to bridge the gap between vcl and libvclplug_*
+ // this is only necessary because PrintFontManager is an exported vcl API and therefore
+ // needs to be in libvcl while libvclplug_* do not contain exported C++ API
+ virtual void FillFontPathList( std::list< rtl::OString >& o_rFontPaths );
};
// called from SVMain
@@ -185,8 +190,6 @@ void SalAbort( const XubString& rErrorText );
VCL_DLLPUBLIC const ::rtl::OUString& SalGetDesktopEnvironment();
-#endif // __cplusplus
-
// -----------
// - SalData -
// -----------
diff --git a/vcl/inc/vcl/strhelper.hxx b/vcl/inc/vcl/strhelper.hxx
new file mode 100644
index 000000000000..b3548a07680b
--- /dev/null
+++ b/vcl/inc/vcl/strhelper.hxx
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: strhelper.hxx,v $
+ * $Revision: 1.5 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org 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 version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _PSPRINT_STRHELPER_HXX_
+#define _PSPRINT_STRHELPER_HXX_
+
+#include "vcl/dllapi.h"
+
+#include <tools/string.hxx>
+#include <rtl/math.hxx>
+
+#include <cstring>
+
+namespace psp {
+
+String VCL_DLLPUBLIC GetCommandLineToken( int, const String& );
+ByteString VCL_DLLPUBLIC GetCommandLineToken( int, const ByteString& );
+// gets one token of a unix command line style string
+// doublequote, singlequote and singleleftquote protect their respective
+// contents
+
+int VCL_DLLPUBLIC GetCommandLineTokenCount( const String& );
+int VCL_DLLPUBLIC GetCommandLineTokenCount( const ByteString& );
+// returns number of tokens (zero if empty or whitespace only)
+
+String VCL_DLLPUBLIC WhitespaceToSpace( const String&, BOOL bProtect = TRUE );
+ByteString VCL_DLLPUBLIC 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
+
+
+// parses the first double in the string; decimal is '.' only
+inline double VCL_DLLPUBLIC StringToDouble( const String& rStr )
+{
+ rtl_math_ConversionStatus eStatus;
+ return rtl::math::stringToDouble( rStr, sal_Unicode('.'), sal_Unicode(0), &eStatus, NULL);
+}
+
+inline double VCL_DLLPUBLIC StringToDouble( const ByteString& rStr )
+{
+ rtl_math_ConversionStatus eStatus;
+ return rtl::math::stringToDouble( rtl::OStringToOUString( rStr, osl_getThreadTextEncoding() ), sal_Unicode('.'), sal_Unicode(0), &eStatus, NULL);
+}
+
+// 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
+inline int VCL_DLLPUBLIC getValueOfDouble( char* pBuffer, double f, int nPrecision = 0)
+{
+ rtl::OString aStr( rtl::math::doubleToString( f, rtl_math_StringFormat_G, nPrecision, '.', true ) );
+ int nLen = aStr.getLength();
+ std::strncpy( pBuffer, aStr.getStr(), nLen+1 ); // copy string including terminating zero
+ return nLen;
+}
+
+} // namespace
+
+#endif // _PSPRINT_STRHELPER_HXX_