summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-07-19 13:18:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-08-05 09:39:11 +0200
commit14cfff500e93f0d6cbf8412065feea85c01ea81d (patch)
tree76e3fb8fbf2b0d8a12c8406d8cf994ea6a37aaff /cui
parentd924ce30e0ca260682bd2aed192b8b1b2ca3e7c0 (diff)
Pass context and resource string down to boost::locale separately
because this is often on a hot path, and we can avoid the splitting and joining of strings like this. Change-Id: Ia36047209368ca53431178c2e8723a18cfe8260a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119220 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cui')
-rw-r--r--cui/inc/numcategories.hrc6
-rw-r--r--cui/inc/strings.hrc2
-rw-r--r--cui/inc/tipoftheday.hrc5
-rw-r--r--cui/inc/toolbarmode.hrc5
-rw-r--r--cui/inc/treeopt.hrc26
-rw-r--r--cui/inc/twolines.hrc6
-rw-r--r--cui/source/dialogs/about.cxx2
-rw-r--r--cui/source/dialogs/cuifmsearch.cxx6
-rw-r--r--cui/source/factory/cuiresmgr.cxx2
-rw-r--r--cui/source/inc/border.hxx3
-rw-r--r--cui/source/inc/dialmgr.hxx3
-rw-r--r--cui/source/inc/macropg.hxx5
-rw-r--r--cui/source/options/optpath.cxx2
-rw-r--r--cui/source/options/treeopt.cxx1
-rw-r--r--cui/source/tabpages/border.cxx6
15 files changed, 44 insertions, 36 deletions
diff --git a/cui/inc/numcategories.hrc b/cui/inc/numcategories.hrc
index 73d25da4f079..40370cc65811 100644
--- a/cui/inc/numcategories.hrc
+++ b/cui/inc/numcategories.hrc
@@ -9,9 +9,11 @@
#pragma once
-#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
+#include <unotools/resmgr.hxx>
-const char* NUM_CATEGORIES[] =
+#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String))
+
+const TranslateId NUM_CATEGORIES[] =
{
NC_("numberingformatpage|liststore1", "All"),
NC_("numberingformatpage|liststore1", "User-defined"),
diff --git a/cui/inc/strings.hrc b/cui/inc/strings.hrc
index 2e6b1276739e..83995559a27a 100644
--- a/cui/inc/strings.hrc
+++ b/cui/inc/strings.hrc
@@ -18,7 +18,7 @@
*/
#pragma once
-#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
+#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String))
#define RID_SVXSTR_KEY_CONFIG_DIR NC_("RID_SVXSTR_KEY_CONFIG_DIR", "Configuration")
#define RID_SVXSTR_KEY_WORK_PATH NC_("RID_SVXSTR_KEY_WORK_PATH", "My Documents")
diff --git a/cui/inc/tipoftheday.hrc b/cui/inc/tipoftheday.hrc
index d5d5c7f62a8e..b410d8f5f1ca 100644
--- a/cui/inc/tipoftheday.hrc
+++ b/cui/inc/tipoftheday.hrc
@@ -19,11 +19,12 @@
#pragma once
-#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
+#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String))
#include <rtl/ustring.hxx>
#include <config_python.h>
#include <tuple>
+#include <unotools/resmgr.hxx>
/*
* std:tuple consists of <text, uri, image>
@@ -44,7 +45,7 @@
* images are scaled to 150x150px; const ThumbSize() in tipoftheday.cxx
*/
-const std::tuple<const char*, OUString, OUString> TIPOFTHEDAY_STRINGARRAY[] =
+const std::tuple<TranslateId, OUString, OUString> TIPOFTHEDAY_STRINGARRAY[] =
{
{ NC_("RID_CUI_TIPOFTHEDAY", "%PRODUCTNAME offers a variety of user interface options to make you feel at home"), ".uno:ToolbarModeUI", "toolbarmode.png"},
{ NC_("RID_CUI_TIPOFTHEDAY", "Need to allow changes to parts of a read-only document in Writer? Insert frames or sections that can authorize changes."), "https://help.libreoffice.org/%PRODUCTVERSION/%LANGUAGENAME/text/swriter/guide/section_edit.html", "tipoftheday_w.png"}, //local help missing
diff --git a/cui/inc/toolbarmode.hrc b/cui/inc/toolbarmode.hrc
index ab2c9263abd6..d073eaaf996a 100644
--- a/cui/inc/toolbarmode.hrc
+++ b/cui/inc/toolbarmode.hrc
@@ -9,15 +9,16 @@
#pragma once
-#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
+#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String))
#include <rtl/ustring.hxx>
#include <tuple>
+#include <unotools/resmgr.hxx>
/*
Description, ui file name, preview file name
*/
-const std::tuple<const char*, OUString, OUString> TOOLBARMODES_ARRAY[] =
+const std::tuple<TranslateId, OUString, OUString> TOOLBARMODES_ARRAY[] =
{
{ NC_("RID_CUI_TOOLBARMODES", "Standard user interface with menu, toolbar, and collapsed sidebar. Intended for users who are familiar with the classic interface."), "Default", "default.png" },
{ NC_("RID_CUI_TOOLBARMODES", "The Tabbed user interface is the most similar to the Ribbons used in Microsoft Office. It organizes functions in tabs and makes the main menu obsolete."), "notebookbar.ui", "notebookbar.png" },
diff --git a/cui/inc/treeopt.hrc b/cui/inc/treeopt.hrc
index 64894a91a5da..c7ee66d7e8d0 100644
--- a/cui/inc/treeopt.hrc
+++ b/cui/inc/treeopt.hrc
@@ -26,9 +26,9 @@
#include <utility>
-#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
+#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String))
-const std::pair<const char*, sal_uInt16> SID_GENERAL_OPTIONS_RES[] =
+const std::pair<TranslateId, sal_uInt16> SID_GENERAL_OPTIONS_RES[] =
{
{ NC_("SID_GENERAL_OPTIONS_RES", "%PRODUCTNAME"), 0 },
{ NC_("SID_GENERAL_OPTIONS_RES", "User Data"), RID_SFXPAGE_GENERAL },
@@ -47,7 +47,7 @@ const std::pair<const char*, sal_uInt16> SID_GENERAL_OPTIONS_RES[] =
{ NC_("SID_GENERAL_OPTIONS_RES", "OpenCL"), RID_SVXPAGE_OPENCL }
};
-const std::pair<const char*, sal_uInt16> SID_LANGUAGE_OPTIONS_RES[] =
+const std::pair<TranslateId, sal_uInt16> SID_LANGUAGE_OPTIONS_RES[] =
{
{ NC_("SID_LANGUAGE_OPTIONS_RES", "Language Settings"), 0 },
{ NC_("SID_LANGUAGE_OPTIONS_RES", "Languages"), OFA_TP_LANGUAGES },
@@ -57,14 +57,14 @@ const std::pair<const char*, sal_uInt16> SID_LANGUAGE_OPTIONS_RES[] =
{ NC_("SID_LANGUAGE_OPTIONS_RES", "Complex Text Layout"), RID_SVXPAGE_OPTIONS_CTL }
};
-const std::pair<const char*, sal_uInt16> SID_INET_DLG_RES[] =
+const std::pair<TranslateId, sal_uInt16> SID_INET_DLG_RES[] =
{
{ NC_("SID_INET_DLG_RES", "Internet"), 0 },
{ NC_("SID_INET_DLG_RES", "Proxy"), RID_SVXPAGE_INET_PROXY },
{ NC_("SID_INET_DLG_RES", "Email"), RID_SVXPAGE_INET_MAIL }
};
-const std::pair<const char*, sal_uInt16> SID_SW_EDITOPTIONS_RES[] =
+const std::pair<TranslateId, sal_uInt16> SID_SW_EDITOPTIONS_RES[] =
{
{ NC_("SID_SW_EDITOPTIONS_RES", "%PRODUCTNAME Writer"), 0 },
{ NC_("SID_SW_EDITOPTIONS_RES", "General"), RID_SW_TP_OPTLOAD_PAGE },
@@ -83,7 +83,7 @@ const std::pair<const char*, sal_uInt16> SID_SW_EDITOPTIONS_RES[] =
{ NC_("SID_SW_EDITOPTIONS_RES", "Mail Merge Email"), RID_SW_TP_MAILCONFIG }
};
-const std::pair<const char*, sal_uInt16> SID_SW_ONLINEOPTIONS_RES[] =
+const std::pair<TranslateId, sal_uInt16> SID_SW_ONLINEOPTIONS_RES[] =
{
{ NC_("SID_SW_ONLINEOPTIONS_RES", "%PRODUCTNAME Writer/Web"), 0 },
{ NC_("SID_SW_ONLINEOPTIONS_RES", "View"), RID_SW_TP_HTML_CONTENT_OPT },
@@ -94,13 +94,13 @@ const std::pair<const char*, sal_uInt16> SID_SW_ONLINEOPTIONS_RES[] =
{ NC_("SID_SW_ONLINEOPTIONS_RES", "Background"), RID_SW_TP_BACKGROUND }
};
-const std::pair<const char*, sal_uInt16> SID_SM_EDITOPTIONS_RES[] =
+const std::pair<TranslateId, sal_uInt16> SID_SM_EDITOPTIONS_RES[] =
{
{ NC_("SID_SM_EDITOPTIONS_RES", "%PRODUCTNAME Math"), 0 },
{ NC_("SID_SM_EDITOPTIONS_RES", "Settings"), SID_SM_TP_PRINTOPTIONS },
};
-const std::pair<const char*, sal_uInt16> SID_SC_EDITOPTIONS_RES[] =
+const std::pair<TranslateId, sal_uInt16> SID_SC_EDITOPTIONS_RES[] =
{
{ NC_("SID_SC_EDITOPTIONS_RES", "%PRODUCTNAME Calc"), 0 },
{ NC_("SID_SC_EDITOPTIONS_RES", "General"), SID_SC_TP_LAYOUT },
@@ -115,7 +115,7 @@ const std::pair<const char*, sal_uInt16> SID_SC_EDITOPTIONS_RES[] =
{ NC_("SID_SC_EDITOPTIONS_RES", "Print"), RID_SC_TP_PRINT }
};
-const std::pair<const char*, sal_uInt16> SID_SD_EDITOPTIONS_RES[] =
+const std::pair<TranslateId, sal_uInt16> SID_SD_EDITOPTIONS_RES[] =
{
{ NC_("SID_SD_EDITOPTIONS_RES", "%PRODUCTNAME Impress"), 0 },
{ NC_("SID_SD_EDITOPTIONS_RES", "General"), SID_SI_TP_MISC },
@@ -124,7 +124,7 @@ const std::pair<const char*, sal_uInt16> SID_SD_EDITOPTIONS_RES[] =
{ NC_("SID_SD_EDITOPTIONS_RES", "Print"), SID_SI_TP_PRINT }
};
-const std::pair<const char*, sal_uInt16> SID_SD_GRAPHIC_OPTIONS_RES[] =
+const std::pair<TranslateId, sal_uInt16> SID_SD_GRAPHIC_OPTIONS_RES[] =
{
{ NC_("SID_SD_GRAPHIC_OPTIONS_RES", "%PRODUCTNAME Draw"), 0 },
{ NC_("SID_SD_GRAPHIC_OPTIONS_RES", "General"), SID_SD_TP_MISC },
@@ -133,13 +133,13 @@ const std::pair<const char*, sal_uInt16> SID_SD_GRAPHIC_OPTIONS_RES[] =
{ NC_("SID_SD_GRAPHIC_OPTIONS_RES", "Print"), SID_SD_TP_PRINT }
};
-const std::pair<const char*, sal_uInt16> SID_SCH_EDITOPTIONS_RES[] =
+const std::pair<TranslateId, sal_uInt16> SID_SCH_EDITOPTIONS_RES[] =
{
{ NC_("SID_SCH_EDITOPTIONS_RES", "Charts"), 0 },
{ NC_("SID_SCH_EDITOPTIONS_RES", "Default Colors"), RID_OPTPAGE_CHART_DEFCOLORS }
};
-const std::pair<const char*, sal_uInt16> SID_FILTER_DLG_RES[] =
+const std::pair<TranslateId, sal_uInt16> SID_FILTER_DLG_RES[] =
{
{ NC_("SID_FILTER_DLG_RES", "Load/Save"), 0 },
{ NC_("SID_FILTER_DLG_RES", "General"), RID_SFXPAGE_SAVE },
@@ -148,7 +148,7 @@ const std::pair<const char*, sal_uInt16> SID_FILTER_DLG_RES[] =
{ NC_("SID_FILTER_DLG_RES", "HTML Compatibility"), RID_OFAPAGE_HTMLOPT }
};
-const std::pair<const char*, sal_uInt16> SID_SB_STARBASEOPTIONS_RES[] =
+const std::pair<TranslateId, sal_uInt16> SID_SB_STARBASEOPTIONS_RES[] =
{
{ NC_("SID_SB_STARBASEOPTIONS_RES", "%PRODUCTNAME Base"), 0 },
{ NC_("SID_SB_STARBASEOPTIONS_RES", "Connections"), SID_SB_CONNECTIONPOOLING },
diff --git a/cui/inc/twolines.hrc b/cui/inc/twolines.hrc
index 609e05e267d6..c0e46d70144e 100644
--- a/cui/inc/twolines.hrc
+++ b/cui/inc/twolines.hrc
@@ -13,7 +13,7 @@
#include <utility>
-#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
+#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String))
#define CHRDLG_ENCLOSE_NONE 0
#define CHRDLG_ENCLOSE_ROUND 1
@@ -22,7 +22,7 @@
#define CHRDLG_ENCLOSE_CURVED 4
#define CHRDLG_ENCLOSE_SPECIAL_CHAR 5
-const std::pair<const char*, sal_uInt16> TWOLINE_OPEN[] =
+const std::pair<TranslateId, sal_uInt16> TWOLINE_OPEN[] =
{
{ NC_("twolinespage|liststore1", "(None)"), CHRDLG_ENCLOSE_NONE },
{ NC_("twolinespage|liststore1", "("), CHRDLG_ENCLOSE_ROUND },
@@ -32,7 +32,7 @@ const std::pair<const char*, sal_uInt16> TWOLINE_OPEN[] =
{ NC_("twolinespage|liststore1", "Other Characters..."), CHRDLG_ENCLOSE_SPECIAL_CHAR }
};
-const std::pair<const char*, sal_uInt16> TWOLINE_CLOSE[] =
+const std::pair<TranslateId, sal_uInt16> TWOLINE_CLOSE[] =
{
{ NC_("twolinespage|liststore2", "(None)"), CHRDLG_ENCLOSE_NONE },
{ NC_("twolinespage|liststore2", ")"), CHRDLG_ENCLOSE_ROUND },
diff --git a/cui/source/dialogs/about.cxx b/cui/source/dialogs/about.cxx
index 12d1927b5ccd..36a7e6e69656 100644
--- a/cui/source/dialogs/about.cxx
+++ b/cui/source/dialogs/about.cxx
@@ -146,7 +146,7 @@ bool AboutDialog::IsStringValidGitHash(const OUString &hash) {
}
OUString AboutDialog::GetVersionString() {
- OUString sVersion = CuiResId("%ABOUTBOXPRODUCTVERSION%ABOUTBOXPRODUCTVERSIONSUFFIX");
+ OUString sVersion = CuiResId(TranslateId(nullptr, "%ABOUTBOXPRODUCTVERSION%ABOUTBOXPRODUCTVERSIONSUFFIX"));
#ifdef _WIN64
sVersion += " (x64)";
diff --git a/cui/source/dialogs/cuifmsearch.cxx b/cui/source/dialogs/cuifmsearch.cxx
index d6e223dc0d19..18f9cae66536 100644
--- a/cui/source/dialogs/cuifmsearch.cxx
+++ b/cui/source/dialogs/cuifmsearch.cxx
@@ -192,13 +192,13 @@ void FmSearchDialog::Init(const OUString& strVisibleFields, const OUString& sIni
// fill the listboxes
// method of field comparison
- const char* const aResIds[] = {
+ const TranslateId aResIds[] = {
RID_STR_SEARCH_ANYWHERE,
RID_STR_SEARCH_BEGINNING,
RID_STR_SEARCH_END,
RID_STR_SEARCH_WHOLE
};
- for (auto pResId : aResIds)
+ for (auto const & pResId : aResIds)
m_plbPosition->append_text(CuiResId(pResId));
m_plbPosition->set_active(MATCHING_ANYWHERE);
@@ -600,7 +600,7 @@ IMPL_LINK(FmSearchDialog, OnSearchProgress, const FmSearchProgress*, pProgress,
case FmSearchProgress::State::Error:
case FmSearchProgress::State::NothingFound:
{
- const char* pErrorId = (FmSearchProgress::State::Error == pProgress->aSearchState)
+ TranslateId pErrorId = (FmSearchProgress::State::Error == pProgress->aSearchState)
? RID_STR_SEARCH_GENERAL_ERROR
: RID_STR_SEARCH_NORECORD;
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(m_xDialog.get(),
diff --git a/cui/source/factory/cuiresmgr.cxx b/cui/source/factory/cuiresmgr.cxx
index fc6f0d5fd24d..2b58e5854f6e 100644
--- a/cui/source/factory/cuiresmgr.cxx
+++ b/cui/source/factory/cuiresmgr.cxx
@@ -20,6 +20,6 @@
#include <dialmgr.hxx>
#include <unotools/resmgr.hxx>
-OUString CuiResId(std::string_view aKey) { return Translate::get(aKey, Translate::Create("cui")); }
+OUString CuiResId(TranslateId aKey) { return Translate::get(aKey, Translate::Create("cui")); }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/inc/border.hxx b/cui/source/inc/border.hxx
index 708f79083380..d863650ee52f 100644
--- a/cui/source/inc/border.hxx
+++ b/cui/source/inc/border.hxx
@@ -27,6 +27,7 @@
#include <svx/colorbox.hxx>
#include <svx/frmsel.hxx>
#include <svx/flagsdef.hxx>
+#include <unotools/resmgr.hxx>
#include <set>
@@ -169,7 +170,7 @@ private:
DECL_LINK(RemoveAdjacentCellBorderHdl_Impl, weld::Toggleable&, void);
sal_uInt16 GetPresetImageId(sal_uInt16 nValueSetIdx) const;
- const char* GetPresetStringId(sal_uInt16 nValueSetIdx) const;
+ TranslateId GetPresetStringId(sal_uInt16 nValueSetIdx) const;
void FillPresetVS();
void FillShadowVS();
diff --git a/cui/source/inc/dialmgr.hxx b/cui/source/inc/dialmgr.hxx
index 003941790603..a26c0b25d32b 100644
--- a/cui/source/inc/dialmgr.hxx
+++ b/cui/source/inc/dialmgr.hxx
@@ -20,7 +20,8 @@
#pragma once
#include <rtl/ustring.hxx>
+#include <unotools/resmgr.hxx>
-OUString CuiResId(std::string_view aKey);
+OUString CuiResId(TranslateId aKey);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/source/inc/macropg.hxx b/cui/source/inc/macropg.hxx
index f6a6e8a17ae2..39e4ef284384 100644
--- a/cui/source/inc/macropg.hxx
+++ b/cui/source/inc/macropg.hxx
@@ -25,6 +25,7 @@
#include <com/sun/star/util/XModifiable.hpp>
#include <com/sun/star/uno/Reference.hxx>
#include <rtl/ustring.hxx>
+#include <unotools/resmgr.hxx>
#include <unordered_map>
#include <vector>
@@ -34,8 +35,8 @@ typedef std::unordered_map< OUString, std::pair< OUString, OUString > > EventsHa
struct EventDisplayName
{
const char* pAsciiEventName;
- const char* pEventResourceID;
- EventDisplayName(const char* pAsciiName, const char* pResId)
+ TranslateId pEventResourceID;
+ EventDisplayName(const char* pAsciiName, TranslateId pResId)
: pAsciiEventName(pAsciiName)
, pEventResourceID(pResId)
{
diff --git a/cui/source/options/optpath.cxx b/cui/source/options/optpath.cxx
index 590ff2eb05c5..bdd7db2ca89e 100644
--- a/cui/source/options/optpath.cxx
+++ b/cui/source/options/optpath.cxx
@@ -245,7 +245,7 @@ void SvxPathTabPage::Reset( const SfxItemSet* )
&& !SvtModuleOptions().IsModuleInstalled( SvtModuleOptions::EModule::WRITER ) )
continue;
- const char* pId = nullptr;
+ TranslateId pId;
switch (static_cast<SvtPathOptions::Paths>(i))
{
diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index 38cbe4952de5..533dc34edea1 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -29,6 +29,7 @@
#include <svx/dialogs.hrc>
#include <svx/svxids.hrc>
+#include <unotools/resmgr.hxx>
#include <treeopt.hrc>
#include <helpids.h>
diff --git a/cui/source/tabpages/border.cxx b/cui/source/tabpages/border.cxx
index 435b86ad6b9d..c0adea646e35 100644
--- a/cui/source/tabpages/border.cxx
+++ b/cui/source/tabpages/border.cxx
@@ -1297,10 +1297,10 @@ sal_uInt16 SvxBorderTabPage::GetPresetImageId( sal_uInt16 nValueSetIdx ) const
return ppnImgIds[ nLine ][ nValueSetIdx - 1 ];
}
-const char* SvxBorderTabPage::GetPresetStringId( sal_uInt16 nValueSetIdx ) const
+TranslateId SvxBorderTabPage::GetPresetStringId( sal_uInt16 nValueSetIdx ) const
{
// string resource IDs for each image (in order of the IID_PRE_* image IDs)
- static const char* pnStrIds[] =
+ static const TranslateId pnStrIds[] =
{
RID_SVXSTR_TABLE_PRESET_NONE,
RID_SVXSTR_PARA_PRESET_ALL,
@@ -1357,7 +1357,7 @@ void SvxBorderTabPage::FillShadowVS()
m_xWndShadows->SetColCount( SVX_BORDER_SHADOW_COUNT );
// string resource IDs for each image
- static const char* pnStrIds[ SVX_BORDER_SHADOW_COUNT ] =
+ static const TranslateId pnStrIds[ SVX_BORDER_SHADOW_COUNT ] =
{ RID_SVXSTR_SHADOW_STYLE_NONE, RID_SVXSTR_SHADOW_STYLE_BOTTOMRIGHT, RID_SVXSTR_SHADOW_STYLE_TOPRIGHT, RID_SVXSTR_SHADOW_STYLE_BOTTOMLEFT, RID_SVXSTR_SHADOW_STYLE_TOPLEFT };
// insert images and help texts