1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: stringdefine.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _EXTENSIONS_FORMSCTRLR_STRINGDEFINE_HXX_
32 #define _EXTENSIONS_FORMSCTRLR_STRINGDEFINE_HXX_
34 #include <rtl/ustring.hxx>
35 #include <tools/string.hxx>
37 //............................................................................
40 //............................................................................
42 //============================================================
43 //= a helper for static ascii pseudo-unicode strings
44 //============================================================
45 struct ConstAsciiString
47 const sal_Char
* ascii
;
50 inline operator const ::rtl::OUString
& () const;
51 inline operator const sal_Char
* () const { return ascii
; }
53 inline ConstAsciiString(const sal_Char
* _pAsciiZeroTerminated
, const sal_Int32 _nLength
);
54 inline ~ConstAsciiString();
57 mutable ::rtl::OUString
* ustring
;
60 //------------------------------------------------------------
61 inline ConstAsciiString::ConstAsciiString(const sal_Char
* _pAsciiZeroTerminated
, const sal_Int32 _nLength
)
62 :ascii(_pAsciiZeroTerminated
)
68 //------------------------------------------------------------
69 inline ConstAsciiString::~ConstAsciiString()
75 //------------------------------------------------------------
76 inline ConstAsciiString::operator const ::rtl::OUString
& () const
79 ustring
= new ::rtl::OUString(ascii
, length
, RTL_TEXTENCODING_ASCII_US
);
83 //============================================================
85 #define CONST_ASCII_LENGTH(c) \
86 (const sal_Char*)c, c.length()
88 //============================================================
90 //============================================================
91 #ifndef PCR_IMPLEMENT_STRINGS
92 #define PCR_CONSTASCII_STRING(ident, string) extern const ConstAsciiString ident
94 #define PCR_CONSTASCII_STRING(ident, string) extern const ConstAsciiString ident(string, sizeof(string)-1)
97 //............................................................................
99 //............................................................................
101 #endif // _EXTENSIONS_FORMSCTRLR_STRINGDEFINE_HXX_