1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _PSPRINT_PRINTERUTIL_HXX_
25 #define _PSPRINT_PRINTERUTIL_HXX_
26 
27 #include "osl/file.hxx"
28 
29 #include "rtl/ustring.hxx"
30 #include "rtl/string.hxx"
31 #include "rtl/tencinfo.h"
32 #include "rtl/textcvt.h"
33 
34 #include <map>
35 
36 namespace psp {
37 
38 /*
39  *  string convenience routines
40  *  sizeof(pBuffer) must be at least 2 Bytes, 0x00 <= nValue <= 0xFF,
41  *  effective buffer of get*ValueOf() is NOT NULL-terminated
42  */
43 sal_Int32   getHexValueOf (sal_Int32 nValue, sal_Char* pBuffer);
44 sal_Int32   getAlignedHexValueOf (sal_Int32 nValue, sal_Char* pBuffer);
45 sal_Int32   getValueOf    (sal_Int32 nValue, sal_Char* pBuffer);
46 sal_Int32   appendStr     (const sal_Char* pSrc, sal_Char* pDst);
47 sal_Int32   appendStr     (const sal_Char* pSrc, sal_Char* pDst, sal_Int32 nBytes);
48 
49 sal_Bool    WritePS (osl::File* pFile, const sal_Char* pString);
50 sal_Bool    WritePS (osl::File* pFile, const sal_Char* pString, sal_uInt64 nInLength);
51 sal_Bool    WritePS (osl::File* pFile, const rtl::OString &rString);
52 sal_Bool    WritePS (osl::File* pFile, const rtl::OUString &rString);
53 
54 class ConverterFactory
55 {
56 
57 public:
58     ConverterFactory();
59     ~ConverterFactory();
60     rtl_UnicodeToTextConverter  Get (rtl_TextEncoding nEncoding);
61     sal_Size                    Convert (const sal_Unicode *pText, int nTextLen,
62                                          sal_uChar *pBuffer, sal_Size nBufferSize,
63                                          rtl_TextEncoding nEncoding);
64 private:
65 
66     std::map< rtl_TextEncoding, rtl_UnicodeToTextConverter >		m_aConverters;
67 };
68 
69 ConverterFactory* GetConverterFactory ();
70 
71 }  /* namespace psp */
72 
73 #endif /* _PSPRINT_PRINTERUTIL_HXX_ */
74 
75