From 5dcf536b69848b56f1199b81e4b7ed87a0a3864d Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 17 May 2012 14:00:15 +0100 Subject: merge the 5 ConstAsciiString duplicate classes together a) merge them together and move it into comphelper b) turn it into a POD rather than having vast amounts of destructors registered into the cxa_atexit chain Change-Id: I04d3b9d7804f8e233013c916df9d617a0f84f96a --- extensions/source/propctrlr/stringdefine.hxx | 46 ++-------------------------- 1 file changed, 3 insertions(+), 43 deletions(-) (limited to 'extensions/source') diff --git a/extensions/source/propctrlr/stringdefine.hxx b/extensions/source/propctrlr/stringdefine.hxx index 2394c987fd3e..80294607f65c 100644 --- a/extensions/source/propctrlr/stringdefine.hxx +++ b/extensions/source/propctrlr/stringdefine.hxx @@ -30,52 +30,12 @@ #define _EXTENSIONS_FORMSCTRLR_STRINGDEFINE_HXX_ #include +#include //............................................................................ namespace pcr { -//............................................................................ - - //============================================================ - //= a helper for static ascii pseudo-unicode strings - //============================================================ - struct ConstAsciiString - { - const sal_Char* ascii; - sal_Int32 length; - - inline operator const ::rtl::OUString& () const; - inline operator const sal_Char* () const { return ascii; } - - inline ConstAsciiString(const sal_Char* _pAsciiZeroTerminated, const sal_Int32 _nLength); - inline ~ConstAsciiString(); - - private: - mutable ::rtl::OUString* ustring; - }; - - //------------------------------------------------------------ - inline ConstAsciiString::ConstAsciiString(const sal_Char* _pAsciiZeroTerminated, const sal_Int32 _nLength) - :ascii(_pAsciiZeroTerminated) - ,length(_nLength) - ,ustring(NULL) - { - } - - //------------------------------------------------------------ - inline ConstAsciiString::~ConstAsciiString() - { - delete ustring; - ustring = NULL; - } - - //------------------------------------------------------------ - inline ConstAsciiString::operator const ::rtl::OUString& () const - { - if (!ustring) - ustring = new ::rtl::OUString(ascii, length, RTL_TEXTENCODING_ASCII_US); - return *ustring; - } + using comphelper::string::ConstAsciiString; //============================================================ @@ -88,7 +48,7 @@ namespace pcr #ifndef PCR_IMPLEMENT_STRINGS #define PCR_CONSTASCII_STRING(ident, string) extern const ConstAsciiString ident #else - #define PCR_CONSTASCII_STRING(ident, string) extern const ConstAsciiString ident(string, sizeof(string)-1) + #define PCR_CONSTASCII_STRING(ident, string) extern const ConstAsciiString ident = {RTL_CONSTASCII_STRINGPARAM(string)} #endif //............................................................................ -- cgit