1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _PSPRINT_PRINTERUTIL_HXX_
29 #define _PSPRINT_PRINTERUTIL_HXX_
30 
31 #include "osl/file.hxx"
32 
33 #include "rtl/ustring.hxx"
34 #include "rtl/string.hxx"
35 #include "rtl/tencinfo.h"
36 #include "rtl/textcvt.h"
37 
38 #include <map>
39 
40 namespace psp {
41 
42 /*
43  *  string convenience routines
44  *  sizeof(pBuffer) must be at least 2 Bytes, 0x00 <= nValue <= 0xFF,
45  *  effective buffer of get*ValueOf() is NOT NULL-terminated
46  */
47 sal_Int32   getHexValueOf (sal_Int32 nValue, sal_Char* pBuffer);
48 sal_Int32   getAlignedHexValueOf (sal_Int32 nValue, sal_Char* pBuffer);
49 sal_Int32   getValueOf    (sal_Int32 nValue, sal_Char* pBuffer);
50 sal_Int32   appendStr     (const sal_Char* pSrc, sal_Char* pDst);
51 sal_Int32   appendStr     (const sal_Char* pSrc, sal_Char* pDst, sal_Int32 nBytes);
52 
53 sal_Bool    WritePS (osl::File* pFile, const sal_Char* pString);
54 sal_Bool    WritePS (osl::File* pFile, const sal_Char* pString, sal_uInt64 nInLength);
55 sal_Bool    WritePS (osl::File* pFile, const rtl::OString &rString);
56 sal_Bool    WritePS (osl::File* pFile, const rtl::OUString &rString);
57 
58 class ConverterFactory
59 {
60 
61 public:
62     ConverterFactory();
63     ~ConverterFactory();
64     rtl_UnicodeToTextConverter  Get (rtl_TextEncoding nEncoding);
65     sal_Size                    Convert (const sal_Unicode *pText, int nTextLen,
66                                          sal_uChar *pBuffer, sal_Size nBufferSize,
67                                          rtl_TextEncoding nEncoding);
68 private:
69 
70     std::map< rtl_TextEncoding, rtl_UnicodeToTextConverter >		m_aConverters;
71 };
72 
73 ConverterFactory* GetConverterFactory ();
74 
75 }  /* namespace psp */
76 
77 #endif /* _PSPRINT_PRINTERUTIL_HXX_ */
78 
79