summaryrefslogtreecommitdiff
path: root/svtools/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-08-28 21:46:45 +0100
committerCaolán McNamara <caolanm@redhat.com>2016-08-29 09:45:16 +0000
commit9ae319f938de37a9de1e8a8853af106b413a4bc7 (patch)
treea0f339f0deb8cfc8fd13793d94396c2934fc28f1 /svtools/source
parent01c41fa9113272644ea81f2d51bfea07eb0954ed (diff)
coverity#1371317 avoid unnecessary copies
and coverity#1371211 Change-Id: I65e277c4af70a86f1513749de4eb116d929e858f Reviewed-on: https://gerrit.libreoffice.org/28448 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools/source')
-rw-r--r--svtools/source/control/collatorres.cxx73
-rw-r--r--svtools/source/control/indexentryres.cxx86
2 files changed, 30 insertions, 129 deletions
diff --git a/svtools/source/control/collatorres.cxx b/svtools/source/control/collatorres.cxx
index 26fc9a7d2e9f..b11cfceca646 100644
--- a/svtools/source/control/collatorres.cxx
+++ b/svtools/source/control/collatorres.cxx
@@ -17,70 +17,27 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
-
#include <svtools/svtresid.hxx>
#include <svtools/svtools.hrc>
#include <svtools/collatorres.hxx>
-
-// wrapper for locale specific translations data of collator algorithm
-
-
-class CollatorResourceData
-{
- friend class CollatorResource;
- private: /* data */
- OUString ma_Name;
- OUString ma_Translation;
- private: /* member functions */
- CollatorResourceData () {}
- public:
- CollatorResourceData ( const OUString &r_Algorithm, const OUString &r_Translation)
- : ma_Name (r_Algorithm), ma_Translation (r_Translation) {}
-
- const OUString& GetAlgorithm () const { return ma_Name; }
-
- const OUString& GetTranslation () const { return ma_Translation; }
-
- ~CollatorResourceData () {}
-
- CollatorResourceData& operator= (const CollatorResourceData& r_From)
- {
- ma_Name = r_From.GetAlgorithm();
- ma_Translation = r_From.GetTranslation();
- return *this;
- }
-};
-
-
// implementation of the collator-algorithm-name translation
-
-
-#define COLLATOR_RESOURCE_COUNT (STR_SVT_COLLATE_END - STR_SVT_COLLATE_START + 1)
-
CollatorResource::CollatorResource()
{
- mp_Data = new CollatorResourceData[COLLATOR_RESOURCE_COUNT];
-
#define RESSTR(rid) SvtResId(rid).toString()
- mp_Data[0] = CollatorResourceData ("alphanumeric", RESSTR(STR_SVT_COLLATE_ALPHANUMERIC));
- mp_Data[1] = CollatorResourceData ("charset", RESSTR(STR_SVT_COLLATE_CHARSET));
- mp_Data[2] = CollatorResourceData ("dict", RESSTR(STR_SVT_COLLATE_DICTIONARY));
- mp_Data[3] = CollatorResourceData ("normal", RESSTR(STR_SVT_COLLATE_NORMAL));
- mp_Data[4] = CollatorResourceData ("pinyin", RESSTR(STR_SVT_COLLATE_PINYIN));
- mp_Data[5] = CollatorResourceData ("radical", RESSTR(STR_SVT_COLLATE_RADICAL));
- mp_Data[6] = CollatorResourceData ("stroke", RESSTR(STR_SVT_COLLATE_STROKE));
- mp_Data[7] = CollatorResourceData ("unicode", RESSTR(STR_SVT_COLLATE_UNICODE));
- mp_Data[8] = CollatorResourceData ("zhuyin", RESSTR(STR_SVT_COLLATE_ZHUYIN));
- mp_Data[9] = CollatorResourceData ("phonebook", RESSTR(STR_SVT_COLLATE_PHONEBOOK));
- mp_Data[10] = CollatorResourceData ("phonetic (alphanumeric first)", RESSTR(STR_SVT_COLLATE_PHONETIC_F));
- mp_Data[11] = CollatorResourceData ("phonetic (alphanumeric last)", RESSTR(STR_SVT_COLLATE_PHONETIC_L));
-}
-
-CollatorResource::~CollatorResource()
-{
- delete[] mp_Data;
+ m_aData.push_back(CollatorResourceData("alphanumeric", RESSTR(STR_SVT_COLLATE_ALPHANUMERIC)));
+ m_aData.push_back(CollatorResourceData("charset", RESSTR(STR_SVT_COLLATE_CHARSET)));
+ m_aData.push_back(CollatorResourceData("dict", RESSTR(STR_SVT_COLLATE_DICTIONARY)));
+ m_aData.push_back(CollatorResourceData("normal", RESSTR(STR_SVT_COLLATE_NORMAL)));
+ m_aData.push_back(CollatorResourceData("pinyin", RESSTR(STR_SVT_COLLATE_PINYIN)));
+ m_aData.push_back(CollatorResourceData("radical", RESSTR(STR_SVT_COLLATE_RADICAL)));
+ m_aData.push_back(CollatorResourceData("stroke", RESSTR(STR_SVT_COLLATE_STROKE)));
+ m_aData.push_back(CollatorResourceData("unicode", RESSTR(STR_SVT_COLLATE_UNICODE)));
+ m_aData.push_back(CollatorResourceData("zhuyin", RESSTR(STR_SVT_COLLATE_ZHUYIN)));
+ m_aData.push_back(CollatorResourceData("phonebook", RESSTR(STR_SVT_COLLATE_PHONEBOOK)));
+ m_aData.push_back(CollatorResourceData("phonetic (alphanumeric first)", RESSTR(STR_SVT_COLLATE_PHONETIC_F)));
+ m_aData.push_back(CollatorResourceData("phonetic (alphanumeric last)", RESSTR(STR_SVT_COLLATE_PHONETIC_L)));
}
const OUString&
@@ -99,10 +56,10 @@ CollatorResource::GetTranslation(const OUString &r_Algorithm)
aLocaleFreeAlgorithm = r_Algorithm.copy(nIndex, r_Algorithm.getLength() - nIndex);
}
- for (sal_uInt32 i = 0; i < COLLATOR_RESOURCE_COUNT; i++)
+ for (size_t i = 0; i < m_aData.size(); ++i)
{
- if (aLocaleFreeAlgorithm == mp_Data[i].GetAlgorithm())
- return mp_Data[i].GetTranslation();
+ if (aLocaleFreeAlgorithm == m_aData[i].GetAlgorithm())
+ return m_aData[i].GetTranslation();
}
return r_Algorithm;
diff --git a/svtools/source/control/indexentryres.cxx b/svtools/source/control/indexentryres.cxx
index 4fc91f00f106..11e1acf2b3d3 100644
--- a/svtools/source/control/indexentryres.cxx
+++ b/svtools/source/control/indexentryres.cxx
@@ -22,77 +22,21 @@
#include <svtools/svtools.hrc>
#include <svtools/indexentryres.hxx>
-
-// wrapper for locale specific translations data of indexentry algorithm
-
-
-class IndexEntryResourceData
-{
- friend class IndexEntryResource;
- private: /* data */
- OUString ma_Name;
- OUString ma_Translation;
- private: /* member functions */
- IndexEntryResourceData () {}
- public:
- IndexEntryResourceData ( const OUString &r_Algorithm, const OUString &r_Translation)
- : ma_Name (r_Algorithm), ma_Translation (r_Translation) {}
-
- const OUString& GetAlgorithm () const { return ma_Name; }
-
- const OUString& GetTranslation () const { return ma_Translation; }
-
- ~IndexEntryResourceData () {}
-
- IndexEntryResourceData& operator= (const IndexEntryResourceData& r_From)
- {
- ma_Name = r_From.GetAlgorithm();
- ma_Translation = r_From.GetTranslation();
- return *this;
- }
-};
-
-
// implementation of the indexentry-algorithm-name translation
-
-
-#define INDEXENTRY_RESOURCE_COUNT (STR_SVT_INDEXENTRY_END - STR_SVT_INDEXENTRY_START + 1)
-
IndexEntryResource::IndexEntryResource()
{
- mp_Data = new IndexEntryResourceData[INDEXENTRY_RESOURCE_COUNT];
-
- #define RESSTR(rid) SvtResId(rid).toString()
-
- mp_Data[STR_SVT_INDEXENTRY_ALPHANUMERIC - STR_SVT_INDEXENTRY_START] =
- IndexEntryResourceData ("alphanumeric", RESSTR(STR_SVT_INDEXENTRY_ALPHANUMERIC));
- mp_Data[STR_SVT_INDEXENTRY_DICTIONARY - STR_SVT_INDEXENTRY_START] =
- IndexEntryResourceData ("dict", RESSTR(STR_SVT_INDEXENTRY_DICTIONARY));
- mp_Data[STR_SVT_INDEXENTRY_PINYIN - STR_SVT_INDEXENTRY_START] =
- IndexEntryResourceData ("pinyin", RESSTR(STR_SVT_INDEXENTRY_PINYIN));
- mp_Data[STR_SVT_INDEXENTRY_PINYIN - STR_SVT_INDEXENTRY_START] =
- IndexEntryResourceData ("radical", RESSTR(STR_SVT_INDEXENTRY_RADICAL));
- mp_Data[STR_SVT_INDEXENTRY_STROKE - STR_SVT_INDEXENTRY_START] =
- IndexEntryResourceData ("stroke", RESSTR(STR_SVT_INDEXENTRY_STROKE));
- mp_Data[STR_SVT_INDEXENTRY_STROKE - STR_SVT_INDEXENTRY_START] =
- IndexEntryResourceData ("zhuyin", RESSTR(STR_SVT_INDEXENTRY_ZHUYIN));
- mp_Data[STR_SVT_INDEXENTRY_ZHUYIN - STR_SVT_INDEXENTRY_START] =
- IndexEntryResourceData ("phonetic (alphanumeric first) (grouped by syllable)",
- RESSTR(STR_SVT_INDEXENTRY_PHONETIC_FS));
- mp_Data[STR_SVT_INDEXENTRY_PHONETIC_FS - STR_SVT_INDEXENTRY_START] =
- IndexEntryResourceData ("phonetic (alphanumeric first) (grouped by consonant)",
- RESSTR(STR_SVT_INDEXENTRY_PHONETIC_FC));
- mp_Data[STR_SVT_INDEXENTRY_PHONETIC_FC - STR_SVT_INDEXENTRY_START] =
- IndexEntryResourceData ("phonetic (alphanumeric last) (grouped by syllable)",
- RESSTR(STR_SVT_INDEXENTRY_PHONETIC_LS));
- mp_Data[STR_SVT_INDEXENTRY_PHONETIC_LS - STR_SVT_INDEXENTRY_START] =
- IndexEntryResourceData ("phonetic (alphanumeric last) (grouped by consonant)",
- RESSTR(STR_SVT_INDEXENTRY_PHONETIC_LC));
-}
-
-IndexEntryResource::~IndexEntryResource()
-{
- delete[] mp_Data;
+ #define RESSTR(rid) SvtResId(rid).toString()
+
+ m_aData.push_back(IndexEntryResourceData("alphanumeric", RESSTR(STR_SVT_INDEXENTRY_ALPHANUMERIC)));
+ m_aData.push_back(IndexEntryResourceData("dict", RESSTR(STR_SVT_INDEXENTRY_DICTIONARY)));
+ m_aData.push_back(IndexEntryResourceData("pinyin", RESSTR(STR_SVT_INDEXENTRY_PINYIN)));
+ m_aData.push_back(IndexEntryResourceData("radical", RESSTR(STR_SVT_INDEXENTRY_RADICAL)));
+ m_aData.push_back(IndexEntryResourceData("stroke", RESSTR(STR_SVT_INDEXENTRY_STROKE)));
+ m_aData.push_back(IndexEntryResourceData("zhuyin", RESSTR(STR_SVT_INDEXENTRY_ZHUYIN)));
+ m_aData.push_back(IndexEntryResourceData("phonetic (alphanumeric first) (grouped by syllable)", RESSTR(STR_SVT_INDEXENTRY_PHONETIC_FS)));
+ m_aData.push_back(IndexEntryResourceData("phonetic (alphanumeric first) (grouped by consonant)", RESSTR(STR_SVT_INDEXENTRY_PHONETIC_FC)));
+ m_aData.push_back(IndexEntryResourceData("phonetic (alphanumeric last) (grouped by syllable)", RESSTR(STR_SVT_INDEXENTRY_PHONETIC_LS)));
+ m_aData.push_back(IndexEntryResourceData("phonetic (alphanumeric last) (grouped by consonant)", RESSTR(STR_SVT_INDEXENTRY_PHONETIC_LC)));
}
const OUString& IndexEntryResource::GetTranslation(const OUString &r_Algorithm)
@@ -107,9 +51,9 @@ const OUString& IndexEntryResource::GetTranslation(const OUString &r_Algorithm)
aLocaleFreeAlgorithm = r_Algorithm.copy(nIndex, r_Algorithm.getLength() - nIndex);
}
- for (sal_uInt32 i = 0; i < INDEXENTRY_RESOURCE_COUNT; i++)
- if (aLocaleFreeAlgorithm == mp_Data[i].GetAlgorithm())
- return mp_Data[i].GetTranslation();
+ for (size_t i = 0; i < m_aData.size(); ++i)
+ if (aLocaleFreeAlgorithm == m_aData[i].GetAlgorithm())
+ return m_aData[i].GetTranslation();
return r_Algorithm;
}