dbaccess/source/core/dataaccess/databasedocument.cxx | 19 +--- dbaccess/source/core/dataaccess/databasedocument.hxx | 6 - dbaccess/source/core/dataaccess/documentevents.cxx | 73 ++++++++----------- 3 files changed, 42 insertions(+), 56 deletions(-)
New commits: commit d1f3e9af6a71150da95b48dbcd81451806332812 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue May 7 14:19:25 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat May 11 09:22:40 2024 +0200 replace createFromAscii with OUString literals in DocumentEvents Change-Id: I5cf5401afafc1c6d2d72445e898903c95288531b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167494 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins 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 commit 589d35da30e6640413f272d617337e9febb127fe Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue May 7 14:08:05 2024 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat May 11 09:22:32 2024 +0200 replace createFromAscii with OUString literals in ODatabaseDocument Change-Id: I57f1de3781ee413ad987222b8b960a266ef21e5a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167492 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/dbaccess/source/core/dataaccess/databasedocument.cxx b/dbaccess/source/core/dataaccess/databasedocument.cxx index 413b53a0f763..117e49300c7d 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.cxx +++ b/dbaccess/source/core/dataaccess/databasedocument.cxx @@ -1542,15 +1542,11 @@ Reference< XNameAccess > SAL_CALL ODatabaseDocument::getReportDocuments( ) return impl_getDocumentContainer_throw( ODatabaseModelImpl::ObjectType::Report ); } -void ODatabaseDocument::WriteThroughComponent( const Reference< XComponent >& xComponent, const char* pStreamName, - const char* pServiceName, const Sequence< Any >& _rArguments, const Sequence< PropertyValue >& rMediaDesc, +void ODatabaseDocument::WriteThroughComponent( const Reference< XComponent >& xComponent, const OUString& sStreamName, + const OUString & rServiceName, const Sequence< Any >& _rArguments, const Sequence< PropertyValue >& rMediaDesc, const Reference<XStorage>& _xStorageToSaveTo ) const { - OSL_ENSURE( pStreamName, "Need stream name!" ); - OSL_ENSURE( pServiceName, "Need service name!" ); - // open stream - OUString sStreamName = OUString::createFromAscii( pStreamName ); Reference< XStream > xStream = _xStorageToSaveTo->openStreamElement( sStreamName, ElementModes::READWRITE | ElementModes::TRUNCATE ); if ( !xStream.is() ) return; @@ -1569,16 +1565,15 @@ void ODatabaseDocument::WriteThroughComponent( const Reference< XComponent >& xC xStreamProp->setPropertyValue( u"Compressed"_ustr, Any( true ) ); // write the stuff - WriteThroughComponent( xOutputStream, xComponent, pServiceName, _rArguments, rMediaDesc ); + WriteThroughComponent( xOutputStream, xComponent, rServiceName, _rArguments, rMediaDesc ); } void ODatabaseDocument::WriteThroughComponent( const Reference< XOutputStream >& xOutputStream, - const Reference< XComponent >& xComponent, const char* pServiceName, const Sequence< Any >& _rArguments, + const Reference< XComponent >& xComponent, const OUString& rServiceName, const Sequence< Any >& _rArguments, const Sequence< PropertyValue >& rMediaDesc ) const { OSL_ENSURE( xOutputStream.is(), "I really need an output stream!" ); OSL_ENSURE( xComponent.is(), "Need component!" ); - OSL_ENSURE( nullptr != pServiceName, "Need component name!" ); // get component Reference< XWriter > xSaxWriter = xml::sax::Writer::create( m_pImpl->m_aContext ); @@ -1594,7 +1589,7 @@ void ODatabaseDocument::WriteThroughComponent( const Reference< XOutputStream >& pArgs[ i+1 ] = _rArguments[i]; // get filter component - Reference< XExporter > xExporter( m_pImpl->m_aContext->getServiceManager()->createInstanceWithArgumentsAndContext(OUString::createFromAscii(pServiceName), aArgs, m_pImpl->m_aContext), UNO_QUERY_THROW ); + Reference< XExporter > xExporter( m_pImpl->m_aContext->getServiceManager()->createInstanceWithArgumentsAndContext(rServiceName, aArgs, m_pImpl->m_aContext), UNO_QUERY_THROW ); // connect model and filter xExporter->setSourceDocument( xComponent ); @@ -1677,11 +1672,11 @@ void ODatabaseDocument::impl_writeStorage_throw( const Reference< XStorage >& _r _rMediaDescriptor >>= aMediaDescriptor; xInfoSet->setPropertyValue(u"StreamName"_ustr, uno::Any(u"settings.xml"_ustr)); - WriteThroughComponent( xComponent, "settings.xml", "com.sun.star.comp.sdb.XMLSettingsExporter", + WriteThroughComponent( xComponent, u"settings.xml"_ustr, u"com.sun.star.comp.sdb.XMLSettingsExporter"_ustr, aDelegatorArguments, aMediaDescriptor, _rxTargetStorage ); xInfoSet->setPropertyValue(u"StreamName"_ustr, uno::Any(u"content.xml"_ustr)); - WriteThroughComponent( xComponent, "content.xml", "com.sun.star.comp.sdb.DBExportFilter", + WriteThroughComponent( xComponent, u"content.xml"_ustr, u"com.sun.star.comp.sdb.DBExportFilter"_ustr, aDelegatorArguments, aMediaDescriptor, _rxTargetStorage ); if ( _rxTargetStorage->hasByName ( sPictures ) ) diff --git a/dbaccess/source/core/dataaccess/databasedocument.hxx b/dbaccess/source/core/dataaccess/databasedocument.hxx index 6278aa039a63..545ae9f92164 100644 --- a/dbaccess/source/core/dataaccess/databasedocument.hxx +++ b/dbaccess/source/core/dataaccess/databasedocument.hxx @@ -233,8 +233,8 @@ class ODatabaseDocument :public ModelDependentComponent // ModelDepe /// write a single XML stream into the package void WriteThroughComponent( const css::uno::Reference< css::lang::XComponent > & xComponent, /// the component we export - const char* pStreamName, /// the stream name - const char* pServiceName, /// service name of the component + const OUString& rStreamName, /// the stream name + const OUString& rServiceName, /// service name of the component const css::uno::Sequence< css::uno::Any> & rArguments, /// the argument (XInitialization) const css::uno::Sequence< css::beans::PropertyValue> & rMediaDesc,/// output descriptor const css::uno::Reference< css::embed::XStorage >& _xStorageToSaveTo @@ -245,7 +245,7 @@ class ODatabaseDocument :public ModelDependentComponent // ModelDepe void WriteThroughComponent( const css::uno::Reference< css::io::XOutputStream >& xOutputStream, const css::uno::Reference< css::lang::XComponent >& xComponent, - const char* pServiceName, + const OUString& rServiceName, const css::uno::Sequence< css::uno::Any >& rArguments, const css::uno::Sequence< css::beans::PropertyValue> & rMediaDesc ) const;