diff options
Diffstat (limited to 'src/rtfstyle.cpp')
-rw-r--r-- | src/rtfstyle.cpp | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/src/rtfstyle.cpp b/src/rtfstyle.cpp index 163d5b8..98581bb 100644 --- a/src/rtfstyle.cpp +++ b/src/rtfstyle.cpp @@ -1,13 +1,13 @@ /****************************************************************************** * - * + * * * * Copyright (C) 1997-2015 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its - * documentation under the terms of the GNU General Public License is hereby - * granted. No representations are made about the suitability of this software + * documentation under the terms of the GNU General Public License is hereby + * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * @@ -224,30 +224,22 @@ Rtf_Style_Default rtf_Style_Default[] = } }; -const QRegExp StyleData::s_clause("\\\\s[0-9]+\\s*"); +static const QRegExp s_clause("\\\\s[0-9]+\\s*"); StyleData::StyleData(const char* reference, const char* definition) { const char *ref = reference; - const char *def = definition; int start = s_clause.match(ref); ASSERT(start >= 0); ref += start; - index = (int)atol(ref + 2); ASSERT(index > 0); - - ASSERT(ref != 0); - size_t size = 1 + strlen(ref); - memcpy(this->reference = new char[size], ref, size); + m_index = (int)atol(ref + 2); ASSERT(m_index > 0); - ASSERT(def != 0); - size = 1 + strlen(def); - memcpy(this->definition = new char[size], def, size); + m_reference = ref; + m_definition = definition; } StyleData::~StyleData() { - delete[] reference; - delete[] definition; } bool StyleData::setStyle(const char* s, const char* styleName) @@ -264,7 +256,7 @@ bool StyleData::setStyle(const char* s, const char* styleName) return FALSE; } s += start; - index = (int)atol(s + 2); ASSERT(index > 0); + m_index = (int)atol(s + 2); ASSERT(m_index > 0); // search for the end of pure formatting codes const char* end = s + len; @@ -302,16 +294,10 @@ bool StyleData::setStyle(const char* s, const char* styleName) else // plain name without leading \\snext break; } - delete[] reference; - reference = new char[ref_len + 1]; - memcpy(reference, s, ref_len); - reference[ref_len] = 0; + m_reference = s; if (haveNewDefinition) { - delete[] definition; - size_t size = 1 + strlen(end); - definition = new char[size]; - memcpy(definition, end, size); + m_definition = end; } return TRUE; } |