diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-05-07 14:19:25 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-05-11 09:22:40 +0200 |
commit | d1f3e9af6a71150da95b48dbcd81451806332812 (patch) | |
tree | 617f69f12a98189c908d16fc92ae40afa55279db /dbaccess | |
parent | 589d35da30e6640413f272d617337e9febb127fe (diff) |
replace createFromAscii with OUString literals in DocumentEvents
Change-Id: I5cf5401afafc1c6d2d72445e898903c95288531b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167494
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/core/dataaccess/documentevents.cxx | 73 |
1 files changed, 32 insertions, 41 deletions
diff --git a/dbaccess/source/core/dataaccess/documentevents.cxx b/dbaccess/source/core/dataaccess/documentevents.cxx index c7070fa58c72..35d54727e31b 100644 --- a/dbaccess/source/core/dataaccess/documentevents.cxx +++ b/dbaccess/source/core/dataaccess/documentevents.cxx @@ -41,55 +41,48 @@ namespace dbaccess // helper struct DocumentEventData { - const char* pAsciiEventName; + OUString aAsciiEventName; bool bNeedsSyncNotify; }; - const DocumentEventData* lcl_getDocumentEventData() - { - static const DocumentEventData s_aData[] = { - { "OnCreate", true }, - { "OnLoadFinished", true }, - { "OnNew", false }, // compatibility, see https://bz.apache.org/ooo/show_bug.cgi?id=46484 - { "OnLoad", false }, // compatibility, see https://bz.apache.org/ooo/show_bug.cgi?id=46484 - { "OnSaveAs", true }, - { "OnSaveAsDone", false }, - { "OnSaveAsFailed", false }, - { "OnSave", true }, - { "OnSaveDone", false }, - { "OnSaveFailed", false }, - { "OnSaveTo", true }, - { "OnSaveToDone", false }, - { "OnSaveToFailed", false }, - { "OnPrepareUnload", true }, - { "OnUnload", true }, - { "OnFocus", false }, - { "OnUnfocus", false }, - { "OnModifyChanged", false }, - { "OnViewCreated", false }, - { "OnPrepareViewClosing", true }, - { "OnViewClosed", false }, - { "OnTitleChanged", false }, - { "OnSubComponentOpened", false }, - { "OnSubComponentClosed", false }, - { nullptr, false } - }; - return s_aData; - } + constexpr DocumentEventData s_DocumentEventData[] { + { u"OnCreate"_ustr, true }, + { u"OnLoadFinished"_ustr, true }, + { u"OnNew"_ustr, false }, // compatibility, see https://bz.apache.org/ooo/show_bug.cgi?id=46484 + { u"OnLoad"_ustr, false }, // compatibility, see https://bz.apache.org/ooo/show_bug.cgi?id=46484 + { u"OnSaveAs"_ustr, true }, + { u"OnSaveAsDone"_ustr, false }, + { u"OnSaveAsFailed"_ustr, false }, + { u"OnSave"_ustr, true }, + { u"OnSaveDone"_ustr, false }, + { u"OnSaveFailed"_ustr, false }, + { u"OnSaveTo"_ustr, true }, + { u"OnSaveToDone"_ustr, false }, + { u"OnSaveToFailed"_ustr, false }, + { u"OnPrepareUnload"_ustr, true }, + { u"OnUnload"_ustr, true }, + { u"OnFocus"_ustr, false }, + { u"OnUnfocus"_ustr, false }, + { u"OnModifyChanged"_ustr, false }, + { u"OnViewCreated"_ustr, false }, + { u"OnPrepareViewClosing"_ustr, true }, + { u"OnViewClosed"_ustr, false }, + { u"OnTitleChanged"_ustr, false }, + { u"OnSubComponentOpened"_ustr, false }, + { u"OnSubComponentClosed"_ustr, false }, + }; } // DocumentEvents DocumentEvents::DocumentEvents( ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex, DocumentEventsData& _rEventsData ) :mrParent(_rParent), mrMutex(_rMutex), mrEventsData(_rEventsData) { - const DocumentEventData* pEventData = lcl_getDocumentEventData(); - while ( pEventData->pAsciiEventName ) + for (const auto & rEventData : s_DocumentEventData) { - OUString sEventName = OUString::createFromAscii( pEventData->pAsciiEventName ); + OUString sEventName = rEventData.aAsciiEventName; DocumentEventsData::const_iterator existingPos = mrEventsData.find( sEventName ); if ( existingPos == mrEventsData.end() ) mrEventsData[ sEventName ] = Sequence< PropertyValue >(); - ++pEventData; } } @@ -109,12 +102,10 @@ namespace dbaccess bool DocumentEvents::needsSynchronousNotification( std::u16string_view _rEventName ) { - const DocumentEventData* pEventData = lcl_getDocumentEventData(); - while ( pEventData->pAsciiEventName ) + for (const auto & rEventData : s_DocumentEventData) { - if ( o3tl::equalsAscii( _rEventName, pEventData->pAsciiEventName ) ) - return pEventData->bNeedsSyncNotify; - ++pEventData; + if ( _rEventName == rEventData.aAsciiEventName ) + return rEventData.bNeedsSyncNotify; } // this is an unknown event ... assume async notification |