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);
appendStr(const::rtl::OString & rSrc,sal_Char * pDst)48 inline sal_Int32 appendStr( const ::rtl::OString& rSrc, sal_Char* pDst) { return appendStr( rSrc.getStr(), pDst);}
49 
50 sal_Bool    WritePS (osl::File* pFile, const sal_Char* pString);
51 sal_Bool    WritePS (osl::File* pFile, const sal_Char* pString, sal_uInt64 nInLength);
52 sal_Bool    WritePS (osl::File* pFile, const rtl::OString &rString);
53 sal_Bool    WritePS (osl::File* pFile, const rtl::OUString &rString);
54 
55 class ConverterFactory
56 {
57 
58 public:
59     ConverterFactory();
60     ~ConverterFactory();
61     rtl_UnicodeToTextConverter  Get (rtl_TextEncoding nEncoding);
62     sal_Size                    Convert (const sal_Unicode *pText, int nTextLen,
63                                          sal_uChar *pBuffer, sal_Size nBufferSize,
64                                          rtl_TextEncoding nEncoding);
65 private:
66 
67     std::map< rtl_TextEncoding, rtl_UnicodeToTextConverter >		m_aConverters;
68 };
69 
70 ConverterFactory* GetConverterFactory ();
71 
72 }  /* namespace psp */
73 
74 #endif /* _PSPRINT_PRINTERUTIL_HXX_ */
75 
76