diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-07-19 13:18:49 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-05 09:39:11 +0200 |
commit | 14cfff500e93f0d6cbf8412065feea85c01ea81d (patch) | |
tree | 76e3fb8fbf2b0d8a12c8406d8cf994ea6a37aaff /include | |
parent | d924ce30e0ca260682bd2aed192b8b1b2ca3e7c0 (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 'include')
-rw-r--r-- | include/basic/sbdef.hxx | 5 | ||||
-rw-r--r-- | include/editeng/editrids.hrc | 2 | ||||
-rw-r--r-- | include/editeng/eerdll.hxx | 3 | ||||
-rw-r--r-- | include/editeng/frmdir.hxx | 3 | ||||
-rw-r--r-- | include/editeng/itemtype.hxx | 3 | ||||
-rw-r--r-- | include/fpicker/strings.hrc | 2 | ||||
-rw-r--r-- | include/sfx2/sfxresid.hxx | 4 | ||||
-rw-r--r-- | include/sfx2/strings.hrc | 2 | ||||
-rw-r--r-- | include/sfx2/styfitem.hxx | 3 | ||||
-rw-r--r-- | include/svl/svl.hrc | 2 | ||||
-rw-r--r-- | include/svl/svlresid.hxx | 4 | ||||
-rw-r--r-- | include/svtools/ehdl.hxx | 2 | ||||
-rw-r--r-- | include/svtools/strings.hrc | 2 | ||||
-rw-r--r-- | include/svtools/svtresid.hxx | 3 | ||||
-rw-r--r-- | include/svx/dialmgr.hxx | 3 | ||||
-rw-r--r-- | include/svx/strings.hrc | 2 | ||||
-rw-r--r-- | include/svx/svddrgmt.hxx | 2 | ||||
-rw-r--r-- | include/svx/svdmrkv.hxx | 4 | ||||
-rw-r--r-- | include/svx/svdobj.hxx | 3 | ||||
-rw-r--r-- | include/svx/svdundo.hxx | 7 | ||||
-rw-r--r-- | include/svx/svxitems.hrc | 4 | ||||
-rw-r--r-- | include/svx/xit.hxx | 3 | ||||
-rw-r--r-- | include/unotools/resmgr.hxx | 18 |
23 files changed, 47 insertions, 39 deletions
diff --git a/include/basic/sbdef.hxx b/include/basic/sbdef.hxx index e84a14d5d51d..d864ed8de7b2 100644 --- a/include/basic/sbdef.hxx +++ b/include/basic/sbdef.hxx @@ -24,6 +24,7 @@ #include <rtl/ustring.hxx> #include <basic/basicdllapi.h> #include <o3tl/typed_flags_set.hxx> +#include <unotools/resmgr.hxx> class ErrCode; @@ -69,9 +70,9 @@ enum class PropertyMode Set }; -BASIC_DLLPUBLIC extern std::pair<const char*, ErrCode> const RID_BASIC_START[]; +BASIC_DLLPUBLIC extern std::pair<TranslateId, ErrCode> const RID_BASIC_START[]; BASIC_DLLPUBLIC std::locale BasResLocale(); -OUString BasResId(std::string_view pId); +OUString BasResId(TranslateId pId); #endif diff --git a/include/editeng/editrids.hrc b/include/editeng/editrids.hrc index 1abb476975e0..556ee042aeca 100644 --- a/include/editeng/editrids.hrc +++ b/include/editeng/editrids.hrc @@ -20,7 +20,7 @@ #ifndef INCLUDED_INCLUDE_EDITENG_EDITRIDS_HRC #define INCLUDED_INCLUDE_EDITENG_EDITRIDS_HRC -#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String) +#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String)) // enum SvxBreak ------------------------------------------------------------ #define RID_SVXITEMS_BREAK_NONE NC_("RID_SVXITEMS_BREAK_NONE", "No break") diff --git a/include/editeng/eerdll.hxx b/include/editeng/eerdll.hxx index a3b215f44395..b77d6a0d4703 100644 --- a/include/editeng/eerdll.hxx +++ b/include/editeng/eerdll.hxx @@ -22,6 +22,7 @@ #include <editeng/editengdllapi.h> #include <rtl/ustring.hxx> +#include <unotools/resmgr.hxx> #include <memory> class GlobalEditData; @@ -30,7 +31,7 @@ namespace editeng class SharedVclResources; } -OUString EDITENG_DLLPUBLIC EditResId(std::string_view aId); +OUString EDITENG_DLLPUBLIC EditResId(TranslateId aId); class EditDLL { diff --git a/include/editeng/frmdir.hxx b/include/editeng/frmdir.hxx index ca3cc615b773..ef5275d26a7d 100644 --- a/include/editeng/frmdir.hxx +++ b/include/editeng/frmdir.hxx @@ -21,6 +21,7 @@ #define INCLUDED_EDITENG_FRMDIR_HXX #include <com/sun/star/text/WritingMode2.hpp> +#include <unotools/resmgr.hxx> /** * Defines possible text directions in frames. @@ -54,7 +55,7 @@ enum class SvxFrameDirection Vertical_LR_BT = css::text::WritingMode2::BT_LR, }; -const char* getFrmDirResId(size_t nIndex); +TranslateId getFrmDirResId(size_t nIndex); #endif // INCLUDED_EDITENG_FRMDIR_HXX diff --git a/include/editeng/itemtype.hxx b/include/editeng/itemtype.hxx index 117e477c8621..7f70a7073a45 100644 --- a/include/editeng/itemtype.hxx +++ b/include/editeng/itemtype.hxx @@ -24,6 +24,7 @@ #include <tools/long.hxx> #include <tools/mapunit.hxx> #include <editeng/editengdllapi.h> +#include <unotools/resmgr.hxx> class Color; class IntlWrapper; @@ -33,7 +34,7 @@ inline constexpr OUStringLiteral cpDelim = u", "; EDITENG_DLLPUBLIC OUString GetMetricText( tools::Long nVal, MapUnit eSrcUnit, MapUnit eDestUnit, const IntlWrapper * pIntl ); OUString GetColorString( const Color& rCol ); -EDITENG_DLLPUBLIC const char* GetMetricId(MapUnit eUnit); +EDITENG_DLLPUBLIC TranslateId GetMetricId(MapUnit eUnit); #endif diff --git a/include/fpicker/strings.hrc b/include/fpicker/strings.hrc index d86a5c569e7b..4dd7fb5fa50c 100644 --- a/include/fpicker/strings.hrc +++ b/include/fpicker/strings.hrc @@ -9,7 +9,7 @@ #ifndef INCLUDED_FPICKER_FPICKER_HRC #define INCLUDED_FPICKER_FPICKER_HRC -#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 STR_SVT_FILEPICKER_AUTO_EXTENSION NC_("STR_SVT_FILEPICKER_AUTO_EXTENSION", "~Automatic file name extension") #define STR_SVT_FILEPICKER_PASSWORD NC_("STR_SVT_FILEPICKER_PASSWORD", "Save with pass~word") diff --git a/include/sfx2/sfxresid.hxx b/include/sfx2/sfxresid.hxx index 62bbc99e92bc..f5cd1aca4cf3 100644 --- a/include/sfx2/sfxresid.hxx +++ b/include/sfx2/sfxresid.hxx @@ -21,9 +21,9 @@ #include <sfx2/dllapi.h> #include <rtl/ustring.hxx> -#include <string_view> +#include <unotools/resmgr.hxx> -SFX2_DLLPUBLIC OUString SfxResId(std::string_view aId); +SFX2_DLLPUBLIC OUString SfxResId(TranslateId aId); #endif diff --git a/include/sfx2/strings.hrc b/include/sfx2/strings.hrc index ce05fa4dce27..3367d368b2fa 100644 --- a/include/sfx2/strings.hrc +++ b/include/sfx2/strings.hrc @@ -20,7 +20,7 @@ #ifndef INCLUDED_SFX2_INC_STRINGS_HRC #define INCLUDED_SFX2_INC_STRINGS_HRC -#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 STR_TEMPLATE_FILTER NC_("STR_TEMPLATE_FILTER", "Templates") #define STR_SAVEDOC NC_("STR_SAVEDOC", "~Save") diff --git a/include/sfx2/styfitem.hxx b/include/sfx2/styfitem.hxx index dc939342689f..dc2efd88cf85 100644 --- a/include/sfx2/styfitem.hxx +++ b/include/sfx2/styfitem.hxx @@ -23,6 +23,7 @@ #include <sal/config.h> #include <sfx2/dllapi.h> #include <svl/style.hxx> +#include <unotools/resmgr.hxx> #include <vector> struct SFX2_DLLPUBLIC SfxFilterTuple @@ -46,7 +47,7 @@ class SFX2_DLLPUBLIC SfxStyleFamilyItem SfxStyleFilter aFilterList; public: - SfxStyleFamilyItem(SfxStyleFamily nFamily, const OUString &rName, const OUString& rImage, const std::pair<const char*, SfxStyleSearchBits>* pStringArray, const std::locale& rLocale); + SfxStyleFamilyItem(SfxStyleFamily nFamily, const OUString &rName, const OUString& rImage, const std::pair<TranslateId, SfxStyleSearchBits>* pStringArray, const std::locale& rLocale); const OUString& GetText() const { return aText; } SfxStyleFamily GetFamily() const { return nFamily; } diff --git a/include/svl/svl.hrc b/include/svl/svl.hrc index 231d26c0f3b5..f1f60756c301 100644 --- a/include/svl/svl.hrc +++ b/include/svl/svl.hrc @@ -19,7 +19,7 @@ #ifndef INCLUDED_SVL_SVL_HRC #define INCLUDED_SVL_SVL_HRC -#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String) +#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String)) // Internet Media Type Presentations diff --git a/include/svl/svlresid.hxx b/include/svl/svlresid.hxx index 5e6f271ea7a1..5b57aa2c0c52 100644 --- a/include/svl/svlresid.hxx +++ b/include/svl/svlresid.hxx @@ -12,9 +12,9 @@ #include <svl/svldllapi.h> #include <rtl/ustring.hxx> -#include <string_view> +#include <unotools/resmgr.hxx> -SVL_DLLPUBLIC OUString SvlResId(std::string_view aId); +SVL_DLLPUBLIC OUString SvlResId(TranslateId sContextAndId); #endif // INCLUDED_SVL_SVTRESID_HXX diff --git a/include/svtools/ehdl.hxx b/include/svtools/ehdl.hxx index bcfdd93b2442..2324a5107b5c 100644 --- a/include/svtools/ehdl.hxx +++ b/include/svtools/ehdl.hxx @@ -23,7 +23,7 @@ #include <svtools/svtresid.hxx> #include <vcl/errinf.hxx> -typedef std::pair<const char*, ErrCode> ErrMsgCode; +typedef std::pair<TranslateId, ErrCode> ErrMsgCode; SVT_DLLPUBLIC extern const ErrMsgCode RID_ERRHDL[]; SVT_DLLPUBLIC extern const ErrMsgCode RID_ERRCTX[]; diff --git a/include/svtools/strings.hrc b/include/svtools/strings.hrc index 774d701d6e1a..b4393c4ebd7b 100644 --- a/include/svtools/strings.hrc +++ b/include/svtools/strings.hrc @@ -19,7 +19,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)) // To translators: tdf#125447 use no mnemonic in this string #define STR_UNDO NC_("STR_UNDO", "Undo: ") diff --git a/include/svtools/svtresid.hxx b/include/svtools/svtresid.hxx index cf2fa976293b..c24ee7d936ae 100644 --- a/include/svtools/svtresid.hxx +++ b/include/svtools/svtresid.hxx @@ -21,9 +21,10 @@ #include <svtools/svtdllapi.h> #include <rtl/ustring.hxx> +#include <unotools/resmgr.hxx> #include <locale> SVT_DLLPUBLIC std::locale SvtResLocale(); -SVT_DLLPUBLIC OUString SvtResId(std::string_view aId); +SVT_DLLPUBLIC OUString SvtResId(TranslateId aId); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/svx/dialmgr.hxx b/include/svx/dialmgr.hxx index ea31de153123..34681a510761 100644 --- a/include/svx/dialmgr.hxx +++ b/include/svx/dialmgr.hxx @@ -21,9 +21,10 @@ #include <rtl/ustring.hxx> #include <svx/svxdllapi.h> +#include <unotools/resmgr.hxx> SVXCORE_DLLPUBLIC std::locale SvxResLocale(); -SVXCORE_DLLPUBLIC OUString SvxResId(std::string_view aId); +SVXCORE_DLLPUBLIC OUString SvxResId(TranslateId aId); #endif diff --git a/include/svx/strings.hrc b/include/svx/strings.hrc index c1bbf42205f8..e18af6a34981 100644 --- a/include/svx/strings.hrc +++ b/include/svx/strings.hrc @@ -20,7 +20,7 @@ #ifndef INCLUDED_SVX_INC_STRINGS_HRC #define INCLUDED_SVX_INC_STRINGS_HRC -#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 STR_ObjNameSingulNONE NC_("STR_ObjNameSingulNONE", "Drawing object") #define STR_ObjNamePluralNONE NC_("STR_ObjNamePluralNONE", "Drawing objects") diff --git a/include/svx/svddrgmt.hxx b/include/svx/svddrgmt.hxx index 72d8ad3ff154..626467f18465 100644 --- a/include/svx/svddrgmt.hxx +++ b/include/svx/svddrgmt.hxx @@ -157,7 +157,7 @@ protected: void createSdrDragEntries_GlueDrag(); // old call forwarders to the SdrDragView - OUString ImpGetDescriptionStr(const char* pStrCacheID) const; + OUString ImpGetDescriptionStr(TranslateId pStrCacheID) const; SdrHdl* GetDragHdl() const { return getSdrDragView().mpDragHdl; } SdrHdlKind GetDragHdlKind() const { return getSdrDragView().meDragHdl; } SdrDragStat& DragStat() { return getSdrDragView().maDragStat; } diff --git a/include/svx/svdmrkv.hxx b/include/svx/svdmrkv.hxx index 48ebb4917414..bdd1046c097d 100644 --- a/include/svx/svdmrkv.hxx +++ b/include/svx/svdmrkv.hxx @@ -26,7 +26,7 @@ #include <svx/svxdllapi.h> #include <o3tl/typed_flags_set.hxx> #include <basegfx/range/b2drectangle.hxx> - +#include <unotools/resmgr.hxx> class SfxViewShell; @@ -169,7 +169,7 @@ protected: SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObjList const * pOL, SdrPageView* pPV, SdrSearchOptions nOptions, const SdrLayerIDSet* pMVisLay, SdrObject*& rpRootObj) const; SdrObject* CheckSingleSdrObjectHit(const Point& rPnt, sal_uInt16 nTol, SdrObjList const * pOL, SdrPageView* pPV, SdrSearchOptions nOptions, const SdrLayerIDSet* pMVisLay, SdrObject*& rpRootObj,const SdrMarkList * pMarkList) const; bool ImpIsFrameHandles() const; - OUString ImpGetDescriptionString(const char* pStrCacheID, ImpGetDescriptionOptions nOpt=ImpGetDescriptionOptions::NONE) const; + OUString ImpGetDescriptionString(TranslateId pStrCacheID, ImpGetDescriptionOptions nOpt=ImpGetDescriptionOptions::NONE) const; // Generates a string including degrees symbol, from an angel specification in 1/100deg bool ImpMarkPoint(SdrHdl* pHdl, SdrMark* pMark, bool bUnmark); diff --git a/include/svx/svdobj.hxx b/include/svx/svdobj.hxx index d7ccf830cf44..d10adcd36445 100644 --- a/include/svx/svdobj.hxx +++ b/include/svx/svdobj.hxx @@ -35,6 +35,7 @@ #include <tools/link.hxx> #include <tools/weakbase.h> #include <tools/gen.hxx> +#include <unotools/resmgr.hxx> #include <unordered_set> @@ -910,7 +911,7 @@ protected: tools::Rectangle ImpDragCalcRect(const SdrDragStat& rDrag) const; // for GetDragComment - OUString ImpGetDescriptionStr(const char* pStrCacheID) const; + OUString ImpGetDescriptionStr(TranslateId pStrCacheID) const; void ImpForcePlusData(); diff --git a/include/svx/svdundo.hxx b/include/svx/svdundo.hxx index 24ee5e569e82..cdfd8070f6ac 100644 --- a/include/svx/svdundo.hxx +++ b/include/svx/svdundo.hxx @@ -31,6 +31,7 @@ #include <svx/svdtypes.hxx> #include <svx/svdsob.hxx> #include <svx/svxdllapi.h> +#include <unotools/resmgr.hxx> class SfxItemSet; class SfxPoolItem; @@ -125,9 +126,9 @@ protected: protected: SdrUndoObj(SdrObject& rNewObj); - OUString ImpGetDescriptionStr(const char* pStrCacheID, bool bRepeat = false) const; + OUString ImpGetDescriptionStr(TranslateId pStrCacheID, bool bRepeat = false) const; - [[nodiscard]] static OUString GetDescriptionStringForObject( const SdrObject& _rForObject, const char* pStrCacheID, bool bRepeat = false ); + [[nodiscard]] static OUString GetDescriptionStringForObject( const SdrObject& _rForObject, TranslateId pStrCacheID, bool bRepeat = false ); // #94278# new method for evtl. PageChange at UNDO/REDO void ImpShowPageOfThisObject(); @@ -526,7 +527,7 @@ protected: SdrUndoPage(SdrPage& rNewPg); ~SdrUndoPage(); - static OUString ImpGetDescriptionStr(const char* pStrCacheID); + static OUString ImpGetDescriptionStr(TranslateId pStrCacheID); }; /** diff --git a/include/svx/svxitems.hrc b/include/svx/svxitems.hrc index 3ea7f12581ab..2e5d5cf8b8e2 100644 --- a/include/svx/svxitems.hrc +++ b/include/svx/svxitems.hrc @@ -26,9 +26,9 @@ #include <editeng/editids.hrc> #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> RID_ATTR_NAMES[] = +const std::pair<TranslateId, sal_uInt16> RID_ATTR_NAMES[] = { { NC_("RID_ATTR_NAMES", "Scale") , SID_ATTR_ZOOM }, { NC_("RID_ATTR_NAMES", "Brush") , SID_ATTR_BRUSH }, diff --git a/include/svx/xit.hxx b/include/svx/xit.hxx index 1333a4ef1066..db8f666197c5 100644 --- a/include/svx/xit.hxx +++ b/include/svx/xit.hxx @@ -23,6 +23,7 @@ #include <svl/stritem.hxx> #include <svx/xtable.hxx> #include <svx/svxdllapi.h> +#include <unotools/resmgr.hxx> /************************************************************************/ @@ -59,7 +60,7 @@ public: Argument pPool2 can be null. If returned string equals NameOrIndex->GetName(), the name was already unique. */ - static OUString CheckNamedItem( const NameOrIndex* pCheckItem, const sal_uInt16 nWhich, const SfxItemPool* pPool1, SvxCompareValueFunc pCompareValueFunc, const char* pPrefixResId, const XPropertyListRef &pDefaults ); + static OUString CheckNamedItem( const NameOrIndex* pCheckItem, const sal_uInt16 nWhich, const SfxItemPool* pPool1, SvxCompareValueFunc pCompareValueFunc, TranslateId pPrefixResId, const XPropertyListRef &pDefaults ); void dumpAsXml(xmlTextWriterPtr pWriter) const override; }; diff --git a/include/unotools/resmgr.hxx b/include/unotools/resmgr.hxx index 0795c3f16704..80e3a23eb57d 100644 --- a/include/unotools/resmgr.hxx +++ b/include/unotools/resmgr.hxx @@ -33,15 +33,15 @@ struct UNOTOOLS_DLLPUBLIC TranslateId const char* mpContext; const char* mpId; - TranslateId() + inline TranslateId() : mpContext(nullptr), mpId(nullptr) {} - TranslateId(const char* pContext, const char* pId) + inline TranslateId(const char* pContext, const char* pId) : mpContext(pContext), mpId(pId) {} - operator bool() const { return mpId != nullptr; } + inline operator bool() const { return mpId != nullptr; } bool operator==(const TranslateId& other) const; - bool operator!=(const TranslateId& other) const { return !operator==(other); } + inline bool operator!=(const TranslateId& other) const { return !operator==(other); } }; struct UNOTOOLS_DLLPUBLIC TranslateNId @@ -50,22 +50,20 @@ struct UNOTOOLS_DLLPUBLIC TranslateNId const char* mpSingular; const char* mpPlural; - TranslateNId() + inline TranslateNId() : mpContext(nullptr), mpSingular(nullptr), mpPlural(nullptr) {} - TranslateNId(const char* pContext, const char* pSingular, const char* pPlural) + inline TranslateNId(const char* pContext, const char* pSingular, const char* pPlural) : mpContext(pContext), mpSingular(pSingular), mpPlural(pPlural) {} - operator bool() const { return mpContext != nullptr; } + inline operator bool() const { return mpContext != nullptr; } bool operator==(const TranslateNId& other) const; - bool operator!=(const TranslateNId& other) const { return !operator==(other); } + inline bool operator!=(const TranslateNId& other) const { return !operator==(other); } }; namespace Translate { UNOTOOLS_DLLPUBLIC std::locale Create(std::string_view aPrefixName, const LanguageTag& rLocale = SvtSysLocale().GetUILanguageTag()); - UNOTOOLS_DLLPUBLIC OUString get(std::string_view aId, const std::locale &loc); - UNOTOOLS_DLLPUBLIC OUString nget(std::string_view aId, int n, const std::locale &loc); UNOTOOLS_DLLPUBLIC OUString get(TranslateId sContextAndId, const std::locale &loc); UNOTOOLS_DLLPUBLIC OUString nget(TranslateNId aContextSingularPlural, int n, const std::locale &loc); UNOTOOLS_DLLPUBLIC void SetReadStringHook( ResHookProc pProc ); |