summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolan.mcnamara@collabora.com>2025-01-15 20:18:13 +0000
committerCaolán McNamara <caolan.mcnamara@collabora.com>2025-01-16 21:16:34 +0100
commit29c73c128443bf2d63327346821be570b3fea5e0 (patch)
tree47a0dcdcfa3c29d4b439c7f996e7c8b28957b38f
parent384c21f8937b5b38c52178e051d929408eea6606 (diff)
defer creating std::locale until it is needed
(if ever, seeing as it's only required if there is an error) Change-Id: Id8ba5ff495dfd2048401231023a09abba9bbf785 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180347 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
-rw-r--r--cui/source/options/optdict.cxx4
-rw-r--r--include/svtools/ehdl.hxx10
-rw-r--r--include/svx/ehdl.hxx24
-rw-r--r--sd/source/ui/func/futhes.cxx4
-rw-r--r--svtools/source/misc/ehdl.cxx17
-rw-r--r--svx/Library_svx.mk1
-rw-r--r--svx/source/items/ehdl.cxx21
-rw-r--r--sw/source/uibase/uiview/viewling.cxx8
8 files changed, 69 insertions, 20 deletions
diff --git a/cui/source/options/optdict.cxx b/cui/source/options/optdict.cxx
index 04dbd2ff801b..0b24752691f3 100644
--- a/cui/source/options/optdict.cxx
+++ b/cui/source/options/optdict.cxx
@@ -20,6 +20,7 @@
#include <editeng/unolingu.hxx>
#include <o3tl/safeint.hxx>
#include <svx/dialmgr.hxx>
+#include <svx/ehdl.hxx>
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/linguistic2/XDictionary.hpp>
#include <com/sun/star/linguistic2/XSearchableDictionaryList.hpp>
@@ -183,8 +184,7 @@ IMPL_LINK_NOARG(SvxNewDictionaryDialog, OKHdl_Impl, weld::Button&, void)
{
m_xNewDic = nullptr;
// error: couldn't create new dictionary
- SfxErrorContext aContext( ERRCTX_SVX_LINGU_DICTIONARY, OUString(),
- m_xDialog.get(), RID_SVXERRCTX, SvxResLocale() );
+ SvxErrorContext aContext(ERRCTX_SVX_LINGU_DICTIONARY, OUString(), m_xDialog.get());
ErrorHandler::HandleError( ErrCodeMsg(
ERRCODE_SVX_LINGU_DICT_NOTWRITEABLE, sDict ) );
m_xDialog->response(RET_CANCEL);
diff --git a/include/svtools/ehdl.hxx b/include/svtools/ehdl.hxx
index 1e70ee1ca55e..a8e7481e8c92 100644
--- a/include/svtools/ehdl.hxx
+++ b/include/svtools/ehdl.hxx
@@ -29,21 +29,21 @@ SVT_DLLPUBLIC extern const ErrMsgCode RID_ERRCTX[];
namespace weld { class Window; }
-class SVT_DLLPUBLIC SfxErrorContext final : private ErrorContext
+class SVT_DLLPUBLIC SfxErrorContext : private ErrorContext
{
public:
SfxErrorContext(
sal_uInt16 nCtxIdP, weld::Window *pWin=nullptr,
- const ErrMsgCode* pIds = nullptr, const std::locale& rResLocaleP = SvtResLocale());
+ const ErrMsgCode* pIds = nullptr);
SfxErrorContext(
sal_uInt16 nCtxIdP, OUString aArg1, weld::Window *pWin=nullptr,
- const ErrMsgCode* pIds = nullptr, const std::locale& rResLocaleP = SvtResLocale());
+ const ErrMsgCode* pIds = nullptr);
bool GetString(const ErrCodeMsg& nErrId, OUString &rStr) override;
-
+private:
+ virtual OUString Translate(TranslateId aId) const;
private:
sal_uInt16 nCtxId;
const ErrMsgCode* pIds;
- std::locale aResLocale;
OUString aArg1;
};
diff --git a/include/svx/ehdl.hxx b/include/svx/ehdl.hxx
new file mode 100644
index 000000000000..553f8420396f
--- /dev/null
+++ b/include/svx/ehdl.hxx
@@ -0,0 +1,24 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#pragma once
+
+#include <svx/svxdllapi.h>
+#include <svtools/ehdl.hxx>
+
+class SVX_DLLPUBLIC SvxErrorContext : public SfxErrorContext
+{
+public:
+ SvxErrorContext(sal_uInt16 nCtxIdP, OUString aArg1, weld::Window* pWin);
+
+private:
+ virtual OUString Translate(TranslateId aId) const;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sd/source/ui/func/futhes.cxx b/sd/source/ui/func/futhes.cxx
index 4c5cfedca69c..b77921830b51 100644
--- a/sd/source/ui/func/futhes.cxx
+++ b/sd/source/ui/func/futhes.cxx
@@ -21,6 +21,7 @@
#include <editeng/outliner.hxx>
#include <sfx2/request.hxx>
+#include <svx/ehdl.hxx>
#include <svx/svdobj.hxx>
#include <svx/svdotext.hxx>
#include <editeng/eeitem.hxx>
@@ -62,8 +63,7 @@ rtl::Reference<FuPoor> FuThesaurus::Create( ViewShell* pViewSh, ::sd::Window* pW
void FuThesaurus::DoExecute(SfxRequest& rReq)
{
- SfxErrorContext aContext(ERRCTX_SVX_LINGU_THESAURUS, OUString(),
- mpWindow->GetFrameWeld(), RID_SVXERRCTX, SvxResLocale());
+ SvxErrorContext aContext(ERRCTX_SVX_LINGU_THESAURUS, OUString(), mpWindow->GetFrameWeld());
if (dynamic_cast< DrawViewShell *>( mpViewShell ))
{
diff --git a/svtools/source/misc/ehdl.cxx b/svtools/source/misc/ehdl.cxx
index e740055a65df..f84ae9dfcc37 100644
--- a/svtools/source/misc/ehdl.cxx
+++ b/svtools/source/misc/ehdl.cxx
@@ -230,8 +230,8 @@ bool SfxErrorHandler::GetErrorString(ErrCode lErrId, OUString &rStr) const
}
SfxErrorContext::SfxErrorContext(
- sal_uInt16 nCtxIdP, weld::Window *pWindow, const ErrMsgCode* pIdsP, const std::locale& rResLocaleP)
-: ErrorContext(pWindow), nCtxId(nCtxIdP), pIds(pIdsP), aResLocale(rResLocaleP)
+ sal_uInt16 nCtxIdP, weld::Window *pWindow, const ErrMsgCode* pIdsP)
+: ErrorContext(pWindow), nCtxId(nCtxIdP), pIds(pIdsP)
{
if (!pIds)
pIds = RID_ERRCTX;
@@ -240,14 +240,19 @@ SfxErrorContext::SfxErrorContext(
SfxErrorContext::SfxErrorContext(
sal_uInt16 nCtxIdP, OUString aArg1P, weld::Window *pWindow,
- const ErrMsgCode* pIdsP, const std::locale& rResLocaleP)
-: ErrorContext(pWindow), nCtxId(nCtxIdP), pIds(pIdsP), aResLocale(rResLocaleP),
+ const ErrMsgCode* pIdsP)
+: ErrorContext(pWindow), nCtxId(nCtxIdP), pIds(pIdsP),
aArg1(std::move(aArg1P))
{
if (!pIds)
pIds = RID_ERRCTX;
}
+OUString SfxErrorContext::Translate(TranslateId aId) const
+{
+ return SvtResId(aId);
+}
+
bool SfxErrorContext::GetString(const ErrCodeMsg& nErr, OUString &rStr)
/* [Description]
@@ -261,7 +266,7 @@ bool SfxErrorContext::GetString(const ErrCodeMsg& nErr, OUString &rStr)
{
if (sal_uInt32(pItem->second) == nCtxId)
{
- rStr = Translate::get(pItem->first, aResLocale);
+ rStr = Translate(pItem->first);
rStr = rStr.replaceAll("$(ARG1)", aArg1);
bRet = true;
break;
@@ -277,7 +282,7 @@ bool SfxErrorContext::GetString(const ErrCodeMsg& nErr, OUString &rStr)
{
if (sal_uInt32(pItem->second) == nId)
{
- rStr = rStr.replaceAll("$(ERR)", Translate::get(pItem->first, aResLocale));
+ rStr = rStr.replaceAll("$(ERR)", Translate(pItem->first));
break;
}
}
diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk
index cddde28842eb..4dd372c5bda4 100644
--- a/svx/Library_svx.mk
+++ b/svx/Library_svx.mk
@@ -197,6 +197,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\
svx/source/form/tbxform \
svx/source/items/algitem \
svx/source/items/autoformathelper \
+ svx/source/items/ehdl \
svx/source/items/hlnkitem \
svx/source/items/numfmtsh \
svx/source/items/legacyitem \
diff --git a/svx/source/items/ehdl.cxx b/svx/source/items/ehdl.cxx
new file mode 100644
index 000000000000..1dbb53e58735
--- /dev/null
+++ b/svx/source/items/ehdl.cxx
@@ -0,0 +1,21 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <svx/dialmgr.hxx>
+#include <svx/ehdl.hxx>
+#include <svx/svxerr.hxx>
+
+SvxErrorContext::SvxErrorContext(sal_uInt16 nCtxIdP, OUString aArgOne, weld::Window* pWin)
+ : SfxErrorContext(nCtxIdP, std::move(aArgOne), pWin, RID_SVXERRCTX)
+{
+}
+
+OUString SvxErrorContext::Translate(TranslateId aId) const { return SvxResId(aId); }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/sw/source/uibase/uiview/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx
index 0a237988fed0..34a579b21fcd 100644
--- a/sw/source/uibase/uiview/viewling.cxx
+++ b/sw/source/uibase/uiview/viewling.cxx
@@ -31,11 +31,11 @@
#include <comphelper/scopeguard.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/weld.hxx>
-#include <svtools/ehdl.hxx>
#include <sfx2/dispatch.hxx>
#include <sfx2/viewfrm.hxx>
#include <sfx2/request.hxx>
#include <svx/dialmgr.hxx>
+#include <svx/ehdl.hxx>
#include <svx/svxerr.hxx>
#include <svx/svxdlg.hxx>
#include <osl/diagnose.h>
@@ -409,8 +409,7 @@ void SwView::HyphenateDocument()
return;
}
- SfxErrorContext aContext( ERRCTX_SVX_LINGU_HYPHENATION, OUString(), m_pEditWin->GetFrameWeld(),
- RID_SVXERRCTX, SvxResLocale() );
+ SvxErrorContext aContext(ERRCTX_SVX_LINGU_HYPHENATION, OUString(), m_pEditWin->GetFrameWeld());
Reference< XHyphenator > xHyph( ::GetHyphenator() );
if (!xHyph.is())
@@ -533,8 +532,7 @@ void SwView::StartThesaurus()
if (!IsValidSelectionForThesaurus())
return;
- SfxErrorContext aContext( ERRCTX_SVX_LINGU_THESAURUS, OUString(), m_pEditWin->GetFrameWeld(),
- RID_SVXERRCTX, SvxResLocale() );
+ SvxErrorContext aContext(ERRCTX_SVX_LINGU_THESAURUS, OUString(), m_pEditWin->GetFrameWeld());
// Determine language
LanguageType eLang = m_pWrtShell->GetCurLang();