Update ooo320-m1
[ooovba.git] / extensions / source / propctrlr / stringdefine.hxx
blobeb21c63c8aa342d37d0365dd9449005316316b80
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: stringdefine.hxx,v $
10 * $Revision: 1.5 $
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 //............................................................................
38 namespace pcr
40 //............................................................................
42 //============================================================
43 //= a helper for static ascii pseudo-unicode strings
44 //============================================================
45 struct ConstAsciiString
47 const sal_Char* ascii;
48 sal_Int32 length;
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();
56 private:
57 mutable ::rtl::OUString* ustring;
60 //------------------------------------------------------------
61 inline ConstAsciiString::ConstAsciiString(const sal_Char* _pAsciiZeroTerminated, const sal_Int32 _nLength)
62 :ascii(_pAsciiZeroTerminated)
63 ,length(_nLength)
64 ,ustring(NULL)
68 //------------------------------------------------------------
69 inline ConstAsciiString::~ConstAsciiString()
71 delete ustring;
72 ustring = NULL;
75 //------------------------------------------------------------
76 inline ConstAsciiString::operator const ::rtl::OUString& () const
78 if (!ustring)
79 ustring = new ::rtl::OUString(ascii, length, RTL_TEXTENCODING_ASCII_US);
80 return *ustring;
83 //============================================================
85 #define CONST_ASCII_LENGTH(c) \
86 (const sal_Char*)c, c.length()
88 //============================================================
89 //= concrete strings
90 //============================================================
91 #ifndef PCR_IMPLEMENT_STRINGS
92 #define PCR_CONSTASCII_STRING(ident, string) extern const ConstAsciiString ident
93 #else
94 #define PCR_CONSTASCII_STRING(ident, string) extern const ConstAsciiString ident(string, sizeof(string)-1)
95 #endif
97 //............................................................................
98 } // namespace pcr
99 //............................................................................
101 #endif // _EXTENSIONS_FORMSCTRLR_STRINGDEFINE_HXX_