summaryrefslogtreecommitdiff
path: root/forms
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 /forms
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 'forms')
-rw-r--r--forms/inc/strings.hrc4
-rw-r--r--forms/source/inc/frm_resource.hxx4
-rw-r--r--forms/source/resource/frm_resource.cxx3
-rw-r--r--forms/source/runtime/formoperations.cxx4
-rw-r--r--forms/source/runtime/formoperations.hxx3
-rw-r--r--forms/source/solar/control/navtoolbar.cxx2
-rw-r--r--forms/source/xforms/datatypes.cxx46
-rw-r--r--forms/source/xforms/datatypes.hxx23
-rw-r--r--forms/source/xforms/resourcehelper.cxx8
-rw-r--r--forms/source/xforms/resourcehelper.hxx11
10 files changed, 55 insertions, 53 deletions
diff --git a/forms/inc/strings.hrc b/forms/inc/strings.hrc
index c3b7447fbc84..8ff5d91dc8b3 100644
--- a/forms/inc/strings.hrc
+++ b/forms/inc/strings.hrc
@@ -19,7 +19,9 @@
#pragma once
-#define NC_(Context, String) reinterpret_cast<char const *>(Context "\004" u8##String)
+#include <unotools/resmgr.hxx>
+
+#define NC_(Context, String) TranslateId(Context, reinterpret_cast<char const *>(u8##String))
#define RID_BASELISTBOX_ERROR_FILLLIST NC_("RID_BASELISTBOX_ERROR_FILLLIST", "The contents of a combo box or list field could not be determined.")
#define RID_STR_IMPORT_GRAPHIC NC_("RID_STR_IMPORT_GRAPHIC", "Insert Image" )
diff --git a/forms/source/inc/frm_resource.hxx b/forms/source/inc/frm_resource.hxx
index 5766af787f2c..ea629440bbce 100644
--- a/forms/source/inc/frm_resource.hxx
+++ b/forms/source/inc/frm_resource.hxx
@@ -20,7 +20,7 @@
#pragma once
#include <rtl/ustring.hxx>
-#include <string_view>
+#include <unotools/resmgr.hxx>
namespace frm
{
@@ -32,7 +32,7 @@ namespace frm
{
/** loads the string with the specified resource id from the FormLayer mo file
*/
- OUString loadString(std::string_view aResId);
+ OUString loadString(TranslateId aResId);
};
}
diff --git a/forms/source/resource/frm_resource.cxx b/forms/source/resource/frm_resource.cxx
index 00c6bd5c5b22..ee29836643db 100644
--- a/forms/source/resource/frm_resource.cxx
+++ b/forms/source/resource/frm_resource.cxx
@@ -18,11 +18,10 @@
*/
#include <frm_resource.hxx>
-#include <unotools/resmgr.hxx>
namespace frm::ResourceManager
{
- OUString loadString(std::string_view aResId)
+ OUString loadString(TranslateId aResId)
{
return Translate::get(aResId, Translate::Create("frm"));
}
diff --git a/forms/source/runtime/formoperations.cxx b/forms/source/runtime/formoperations.cxx
index 4aa12bc91233..fa8e092ab5cb 100644
--- a/forms/source/runtime/formoperations.cxx
+++ b/forms/source/runtime/formoperations.cxx
@@ -775,7 +775,7 @@ namespace frm
default:
{
- const char* pErrorResourceId = RID_STR_FEATURE_UNKNOWN;
+ TranslateId pErrorResourceId = RID_STR_FEATURE_UNKNOWN;
if ( lcl_requiresArguments( _nFeature ) )
pErrorResourceId = RID_STR_FEATURE_REQUIRES_PARAMETERS;
else if ( !lcl_isExecutableFeature( _nFeature ) )
@@ -1733,7 +1733,7 @@ namespace frm
template < typename FunctObj >
- void FormOperations::impl_doActionInSQLContext_throw( FunctObj f, const char* pErrorResourceId ) const
+ void FormOperations::impl_doActionInSQLContext_throw( FunctObj f, TranslateId pErrorResourceId ) const
{
try
{
diff --git a/forms/source/runtime/formoperations.hxx b/forms/source/runtime/formoperations.hxx
index bd092edd2a48..182b0a7e0958 100644
--- a/forms/source/runtime/formoperations.hxx
+++ b/forms/source/runtime/formoperations.hxx
@@ -35,6 +35,7 @@
#include <cppuhelper/compbase.hxx>
#include <connectivity/dbtools.hxx>
#include <tools/long.hxx>
+#include <unotools/resmgr.hxx>
namespace frm
{
@@ -293,7 +294,7 @@ namespace frm
the id of the resources string to use as error message
*/
template < typename FunctObj >
- void impl_doActionInSQLContext_throw( FunctObj f, const char* pErrorResourceId ) const;
+ void impl_doActionInSQLContext_throw( FunctObj f, TranslateId pErrorResourceId ) const;
// functionoid to call appendOrderByColumn
class impl_appendOrderByColumn_throw
diff --git a/forms/source/solar/control/navtoolbar.cxx b/forms/source/solar/control/navtoolbar.cxx
index 475038b8391d..909c5d044502 100644
--- a/forms/source/solar/control/navtoolbar.cxx
+++ b/forms/source/solar/control/navtoolbar.cxx
@@ -56,7 +56,7 @@ namespace frm
|| ( _nFeatureId == LID_RECORD_FILLER );
}
- OUString getLabelString(const char* pResId)
+ OUString getLabelString(TranslateId pResId)
{
OUString sLabel( " " + FRM_RES_STRING(pResId) + " " );
return sLabel;
diff --git a/forms/source/xforms/datatypes.cxx b/forms/source/xforms/datatypes.cxx
index c4ce2d941bb4..464b1c1adbbf 100644
--- a/forms/source/xforms/datatypes.cxx
+++ b/forms/source/xforms/datatypes.cxx
@@ -158,14 +158,14 @@ namespace xforms
sal_Bool OXSDDataType::validate( const OUString& sValue )
{
- return ( _validate( sValue ) == nullptr );
+ return bool(_validate( sValue ));
}
OUString OXSDDataType::explainInvalid( const OUString& sValue )
{
// get reason
- const char* pReason = _validate( sValue );
+ TranslateId pReason = _validate( sValue );
// get resource and return localized string
return (!pReason)
@@ -174,7 +174,7 @@ namespace xforms
_explainInvalid( pReason ) );
}
- OUString OXSDDataType::_explainInvalid(const OString& rReason)
+ OUString OXSDDataType::_explainInvalid(TranslateId rReason)
{
if ( RID_STR_XFORMS_PATTERN_DOESNT_MATCH == rReason )
{
@@ -212,7 +212,7 @@ namespace xforms
}
}
- const char* OXSDDataType::_validate( const OUString& _rValue )
+ TranslateId OXSDDataType::_validate( const OUString& _rValue )
{
// care for the regular expression
if ( !m_sPattern.isEmpty() )
@@ -229,7 +229,7 @@ namespace xforms
return RID_STR_XFORMS_PATTERN_DOESNT_MATCH;
}
- return nullptr;
+ return {};
}
@@ -418,9 +418,9 @@ namespace xforms
return bReturn;
}
- const char* OValueLimitedType_Base::_validate( const OUString& rValue )
+ TranslateId OValueLimitedType_Base::_validate( const OUString& rValue )
{
- const char* pReason = OXSDDataType::_validate( rValue );
+ TranslateId pReason = OXSDDataType::_validate( rValue );
if (!pReason)
{
@@ -442,7 +442,7 @@ namespace xforms
return pReason;
}
- OUString OValueLimitedType_Base::_explainInvalid(const OString& rReason)
+ OUString OValueLimitedType_Base::_explainInvalid(TranslateId rReason)
{
OUStringBuffer sInfo;
if (rReason == RID_STR_XFORMS_VALUE_IS_NOT_A)
@@ -511,10 +511,10 @@ namespace xforms
}
- const char* OStringType::_validate( const OUString& rValue )
+ TranslateId OStringType::_validate( const OUString& rValue )
{
// check regexp, whitespace etc. in parent class
- const char* pReason = OStringType_Base::_validate( rValue );
+ TranslateId pReason = OStringType_Base::_validate( rValue );
if (!pReason)
{
@@ -537,7 +537,7 @@ namespace xforms
return pReason;
}
- OUString OStringType::_explainInvalid(const OString& rReason)
+ OUString OStringType::_explainInvalid(TranslateId rReason)
{
sal_Int32 nValue = 0;
OUStringBuffer sInfo;
@@ -556,7 +556,7 @@ namespace xforms
if( m_aMinLength >>= nValue )
sInfo.append( nValue );
}
- else if (!rReason.isEmpty())
+ else if (rReason)
{
sInfo.append(OStringType_Base::_explainInvalid(rReason));
}
@@ -578,19 +578,19 @@ namespace xforms
OBooleanType_Base::initializeClone( _rCloneSource );
}
- const char* OBooleanType::_validate( const OUString& sValue )
+ TranslateId OBooleanType::_validate( const OUString& sValue )
{
- const char* pInvalidityReason = OBooleanType_Base::_validate( sValue );
+ TranslateId pInvalidityReason = OBooleanType_Base::_validate( sValue );
if ( pInvalidityReason )
return pInvalidityReason;
bool bValid = sValue == "0" || sValue == "1" || sValue == "true" || sValue == "false";
- return bValid ? nullptr : RID_STR_XFORMS_INVALID_VALUE;
+ return bValid ? TranslateId() : RID_STR_XFORMS_INVALID_VALUE;
}
- OUString OBooleanType::_explainInvalid(const OString& rReason)
+ OUString OBooleanType::_explainInvalid(TranslateId rReason)
{
- return rReason.isEmpty() ? OUString() : getName();
+ return !rReason ? OUString() : getName();
}
ODecimalType::ODecimalType( const OUString& _rName, sal_Int16 _nTypeClass )
@@ -620,9 +620,9 @@ namespace xforms
// validate decimals and return code for which facets failed
// to be used by: ODecimalType::validate and ODecimalType::explainInvalid
- const char* ODecimalType::_validate( const OUString& rValue )
+ TranslateId ODecimalType::_validate( const OUString& rValue )
{
- const char* pReason = ODecimalType_Base::_validate( rValue );
+ TranslateId pReason = ODecimalType_Base::_validate( rValue );
// check digits (if no other cause is available so far)
if (!pReason)
@@ -653,7 +653,7 @@ namespace xforms
return pReason;
}
- OUString ODecimalType::_explainInvalid(const OString& rReason)
+ OUString ODecimalType::_explainInvalid(TranslateId rReason)
{
sal_Int32 nValue = 0;
OUStringBuffer sInfo;
@@ -712,7 +712,7 @@ namespace xforms
DEFAULT_IMPLEMNENT_SUBTYPE( ODateType, DATE )
- const char* ODateType::_validate( const OUString& _rValue )
+ TranslateId ODateType::_validate( const OUString& _rValue )
{
return ODateType_Base::_validate( _rValue );
}
@@ -754,7 +754,7 @@ namespace xforms
DEFAULT_IMPLEMNENT_SUBTYPE( OTimeType, TIME )
- const char* OTimeType::_validate( const OUString& _rValue )
+ TranslateId OTimeType::_validate( const OUString& _rValue )
{
return OTimeType_Base::_validate( _rValue );
}
@@ -802,7 +802,7 @@ namespace xforms
DEFAULT_IMPLEMNENT_SUBTYPE( ODateTimeType, DATETIME )
- const char* ODateTimeType::_validate( const OUString& _rValue )
+ TranslateId ODateTimeType::_validate( const OUString& _rValue )
{
return ODateTimeType_Base::_validate( _rValue );
}
diff --git a/forms/source/xforms/datatypes.hxx b/forms/source/xforms/datatypes.hxx
index 860d1901b553..84ca5cfe9bdd 100644
--- a/forms/source/xforms/datatypes.hxx
+++ b/forms/source/xforms/datatypes.hxx
@@ -30,6 +30,7 @@
#include <comphelper/proparrhlp.hxx>
#include <comphelper/broadcasthelper.hxx>
#include <rtl/ref.hxx>
+#include <unotools/resmgr.hxx>
#include <unicode/regex.h>
@@ -117,8 +118,8 @@ namespace xforms
virtual void initializeClone( const OXSDDataType& _rCloneSource );
// helper method for validate and explainInvalid
- virtual const char* _validate( const OUString& value );
- virtual OUString _explainInvalid( const OString& rReason );
+ virtual TranslateId _validate( const OUString& value );
+ virtual OUString _explainInvalid( TranslateId rReason );
// helper method for checking properties values which are to be set
virtual bool checkPropertySanity( sal_Int32 _nHandle, const css::uno::Any& _rNewValue, OUString& _rErrorMessage );
@@ -176,8 +177,8 @@ namespace xforms
// OXSDDataType overridables
virtual bool _getValue( const OUString& value, double& fValue );
- virtual const char* _validate( const OUString& value ) override;
- virtual OUString _explainInvalid( const OString& rReason ) override;
+ virtual TranslateId _validate( const OUString& value ) override;
+ virtual OUString _explainInvalid( TranslateId rReason ) override;
// own overridables
/** translate a given value into a human-readable string
@@ -248,8 +249,8 @@ namespace xforms
DECLARE_DEFAULT_CLONING( OBooleanType )
// OXSDDataType overridables
- virtual const char* _validate( const OUString& value ) override;
- virtual OUString _explainInvalid( const OString& rReason ) override;
+ virtual TranslateId _validate( const OUString& value ) override;
+ virtual OUString _explainInvalid( TranslateId rReason ) override;
};
class OStringType;
@@ -270,8 +271,8 @@ namespace xforms
void initializeTypedClone( const OStringType& _rCloneSource );
// OXSDDataType overridables
- virtual const char* _validate( const OUString& value ) override;
- virtual OUString _explainInvalid( const OString& rReason ) override;
+ virtual TranslateId _validate( const OUString& value ) override;
+ virtual OUString _explainInvalid( TranslateId rReason ) override;
virtual bool checkPropertySanity( sal_Int32 _nHandle, const css::uno::Any& _rNewValue, OUString& _rErrorMessage ) override;
virtual void registerProperties() override;
};
@@ -291,8 +292,8 @@ namespace xforms
void initializeTypedClone( const ODecimalType& _rCloneSource );
// OXSDDataType overridables
- virtual const char* _validate( const OUString& value ) override;
- virtual OUString _explainInvalid( const OString& rReason ) override;
+ virtual TranslateId _validate( const OUString& value ) override;
+ virtual OUString _explainInvalid( TranslateId rReason ) override;
virtual void registerProperties() override;
// OValueLimitedType overridables
@@ -318,7 +319,7 @@ namespace xforms
DECLARE_DEFAULT_CLONING( classname ) \
\
/* OXSDDataType overridables */ \
- virtual const char* _validate( const OUString& value ) override; \
+ virtual TranslateId _validate( const OUString& value ) override; \
virtual bool _getValue( const OUString& value, double& fValue ) override; \
\
/* OValueLimitedType overridables */ \
diff --git a/forms/source/xforms/resourcehelper.cxx b/forms/source/xforms/resourcehelper.cxx
index 17c168d980ae..011d806f598d 100644
--- a/forms/source/xforms/resourcehelper.cxx
+++ b/forms/source/xforms/resourcehelper.cxx
@@ -28,25 +28,25 @@
namespace xforms
{
-OUString getResource(const char* pResourceId)
+OUString getResource(TranslateId pResourceId)
{
return getResource(pResourceId, {}, {}, {});
}
-OUString getResource(const char* pResourceId,
+OUString getResource(TranslateId pResourceId,
std::u16string_view rInfo1)
{
return getResource(pResourceId, rInfo1, {}, {});
}
-OUString getResource(const char* pResourceId,
+OUString getResource(TranslateId pResourceId,
std::u16string_view rInfo1,
std::u16string_view rInfo2)
{
return getResource(pResourceId, rInfo1, rInfo2, {});
}
-OUString getResource(const char* pResourceId,
+OUString getResource(TranslateId pResourceId,
std::u16string_view rInfo1,
std::u16string_view rInfo2,
std::u16string_view rInfo3)
diff --git a/forms/source/xforms/resourcehelper.hxx b/forms/source/xforms/resourcehelper.hxx
index 9f200fdc87c0..1453a7e4ca04 100644
--- a/forms/source/xforms/resourcehelper.hxx
+++ b/forms/source/xforms/resourcehelper.hxx
@@ -20,20 +20,19 @@
#include <sal/config.h>
-#include <string_view>
-
#include <rtl/ustring.hxx>
+#include <unotools/resmgr.hxx>
namespace xforms
{
/// get a resource string for the current language
- OUString getResource(const char*);
+ OUString getResource(TranslateId);
// overloaded: get a resource string, and substitute parameters
- OUString getResource(const char*, std::u16string_view);
- OUString getResource(const char*, std::u16string_view,
+ OUString getResource(TranslateId, std::u16string_view);
+ OUString getResource(TranslateId, std::u16string_view,
std::u16string_view);
- OUString getResource(const char*, std::u16string_view,
+ OUString getResource(TranslateId, std::u16string_view,
std::u16string_view,
std::u16string_view);