include/sfx2/docfile.hxx | 3 ++- sc/source/ui/docshell/docsh.cxx | 17 +++-------------- sfx2/source/doc/docfile.cxx | 12 +++++------- sfx2/source/doc/objmisc.cxx | 3 +-- sfx2/source/doc/objstor.cxx | 8 +++----- sw/source/filter/html/swhtml.cxx | 2 +- sw/source/filter/html/wrthtml.cxx | 2 +- sw/source/uibase/app/docsh.cxx | 17 ++++------------- 8 files changed, 20 insertions(+), 44 deletions(-)
New commits: commit 30c1bb2ebf0b68712aece482ac54b500bbdba6c1 Author: Mike Kaganski <[email protected]> AuthorDate: Sat Dec 6 13:18:49 2025 +0500 Commit: Mike Kaganski <[email protected]> CommitDate: Sat Dec 6 19:45:27 2025 +0100 Let SfxMedium::GetArgs return comphelper::SequenceAsHashMap It is already used in SfxMedium::SetArgs; so let it be stored in SfxMedium_Impl::m_aArgs. Makes its usage simpler, since most of the users convert it to comphelper::SequenceAsHashMap anyway. Change-Id: I44ac0479156e661890e682b27dfde7d60370b6d3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/195164 Tested-by: Jenkins Reviewed-by: Mike Kaganski <[email protected]> diff --git a/include/sfx2/docfile.hxx b/include/sfx2/docfile.hxx index 0e1c70a66364..016b29608b13 100644 --- a/include/sfx2/docfile.hxx +++ b/include/sfx2/docfile.hxx @@ -52,6 +52,7 @@ class XModel; } namespace ucbhelper { class Content; } namespace svl::crypto { class SigningContext; } +namespace comphelper { class SequenceAsHashMap; } class SvKeyValueIterator; class SfxFilter; @@ -133,7 +134,7 @@ public: SfxItemSet& GetItemSet() const; void SetArgs(const css::uno::Sequence<css::beans::PropertyValue>& rArgs); - const css::uno::Sequence<css::beans::PropertyValue> & GetArgs() const; + const comphelper::SequenceAsHashMap& GetArgs() const; void Close(bool bInDestruction = false); void CloseAndRelease(); void ReOpen(); diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 4b2ce461c2d2..8313e7ada576 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -1925,10 +1925,7 @@ bool ScDocShell::SaveAs( SfxMedium& rMedium ) if (pViewShell && bNeedsRehash) { - bool bAutoSaveEvent = false; - comphelper::SequenceAsHashMap lArgs(rMedium.GetArgs()); - lArgs[utl::MediaDescriptor::PROP_AUTOSAVEEVENT] >>= bAutoSaveEvent; - if (bAutoSaveEvent) + if (rMedium.GetArgs().getValue(utl::MediaDescriptor::PROP_AUTOSAVEEVENT) == true) { // skip saving recovery file instead of showing re-type password dialog window SAL_WARN("sc.filter", @@ -2562,16 +2559,8 @@ bool ScDocShell::ConvertTo( SfxMedium &rMed ) // Verbose only from command line, not UI (in case we actually // implement that) nor macro filter options. - bool bVerbose = false; - const css::uno::Sequence<css::beans::PropertyValue> & rArgs = rMed.GetArgs(); - const auto pProp = std::find_if( rArgs.begin(), rArgs.end(), - [](const css::beans::PropertyValue& rProp) { return rProp.Name == "ConversionRequestOrigin"; }); - if (pProp != rArgs.end()) - { - OUString aOrigin; - pProp->Value >>= aOrigin; - bVerbose = (aOrigin == "CommandLine"); - } + bool bVerbose + = rMed.GetArgs().getValue(u"ConversionRequestOrigin"_ustr) == u"CommandLine"_ustr; SCTAB nStartTab; SCTAB nCount = m_pDocument->GetTableCount(); diff --git a/sfx2/source/doc/docfile.cxx b/sfx2/source/doc/docfile.cxx index ba9cf0e9c2d3..d28eeb51983b 100644 --- a/sfx2/source/doc/docfile.cxx +++ b/sfx2/source/doc/docfile.cxx @@ -475,7 +475,7 @@ public: util::DateTime m_aDateTime; - uno::Sequence<beans::PropertyValue> m_aArgs; + comphelper::SequenceAsHashMap m_aArgs; explicit SfxMedium_Impl(); ~SfxMedium_Impl(); @@ -3689,14 +3689,12 @@ SfxMedium::SfxMedium( const uno::Sequence<beans::PropertyValue>& aArgs ) : void SfxMedium::SetArgs(const uno::Sequence<beans::PropertyValue>& rArgs) { - comphelper::SequenceAsHashMap aArgsMap(rArgs); - aArgsMap.erase(u"Stream"_ustr); - aArgsMap.erase(u"InputStream"_ustr); - - pImpl->m_aArgs = aArgsMap.getAsConstPropertyValueList(); + pImpl->m_aArgs << rArgs; + pImpl->m_aArgs.erase(u"Stream"_ustr); + pImpl->m_aArgs.erase(u"InputStream"_ustr); } -const uno::Sequence<beans::PropertyValue> & SfxMedium::GetArgs() const { return pImpl->m_aArgs; } +const comphelper::SequenceAsHashMap& SfxMedium::GetArgs() const { return pImpl->m_aArgs; } SfxMedium::SfxMedium( const uno::Reference < embed::XStorage >& rStor, const OUString& rBaseURL, const std::shared_ptr<SfxItemSet>& p ) : pImpl(new SfxMedium_Impl) diff --git a/sfx2/source/doc/objmisc.cxx b/sfx2/source/doc/objmisc.cxx index bf3d6f945641..90d0645793b7 100644 --- a/sfx2/source/doc/objmisc.cxx +++ b/sfx2/source/doc/objmisc.cxx @@ -1978,8 +1978,7 @@ bool SfxObjectShell::IsContinueImportOnFilterExceptions() return false; } - if (comphelper::SequenceAsHashMap desc(pMedium->GetArgs()); - !desc.getUnpackedValueOrDefault(u"RepairAllowed"_ustr, true)) + if (!pMedium->GetArgs().getUnpackedValueOrDefault(u"RepairAllowed"_ustr, true)) { mbContinueImportOnFilterExceptions = no; return false; diff --git a/sfx2/source/doc/objstor.cxx b/sfx2/source/doc/objstor.cxx index 8d09fe433f63..cd7072328f5e 100644 --- a/sfx2/source/doc/objstor.cxx +++ b/sfx2/source/doc/objstor.cxx @@ -2786,7 +2786,7 @@ bool SfxObjectShell::ExportTo( SfxMedium& rMedium ) // put in the REAL file name, and copy all PropertyValues comphelper::SequenceAsHashMap aNewArgs = TransformItems(SID_SAVEASDOC, rItems); - comphelper::SequenceAsHashMap aMediumArgs(rMedium.GetArgs()); + const comphelper::SequenceAsHashMap& aMediumArgs(rMedium.GetArgs()); if (aNewArgs.contains(u"FileName"_ustr)) aNewArgs[u"FileName"_ustr] <<= rMedium.GetName(); @@ -2795,7 +2795,7 @@ bool SfxObjectShell::ExportTo( SfxMedium& rMedium ) aNewArgs[u"IsPreview"_ustr] <<= true; if (aMediumArgs.contains(u"ConversionRequestOrigin"_ustr)) - aNewArgs[u"ConversionRequestOrigin"_ustr] = aMediumArgs[u"ConversionRequestOrigin"_ustr]; + aNewArgs[u"ConversionRequestOrigin"_ustr] = aMediumArgs.getValue(u"ConversionRequestOrigin"_ustr); // FIXME: Handle this inside TransformItems() if (rItems.GetItemState(SID_IS_REDACT_MODE) == SfxItemState::SET) @@ -3637,9 +3637,7 @@ bool SfxObjectShell::SaveAsChildren( SfxMedium& rMedium ) return true; } - bool AutoSaveEvent = false; - comphelper::SequenceAsHashMap lArgs(rMedium.GetArgs()); - lArgs[utl::MediaDescriptor::PROP_AUTOSAVEEVENT] >>= AutoSaveEvent; + bool AutoSaveEvent = rMedium.GetArgs().getUnpackedValueOrDefault(utl::MediaDescriptor::PROP_AUTOSAVEEVENT, false); if ( pImpl->mxObjectContainer ) { diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx index 9b3c37a3b808..b885d4a21685 100644 --- a/sw/source/filter/html/swhtml.cxx +++ b/sw/source/filter/html/swhtml.cxx @@ -453,7 +453,7 @@ SwHTMLParser::SwHTMLParser( SwDoc* pD, SwPaM& rCursor, SvStream& rIn, return; } - comphelper::SequenceAsHashMap aLoadMap(pMed->GetArgs()); + const comphelper::SequenceAsHashMap& aLoadMap(pMed->GetArgs()); auto it = aLoadMap.find(u"AllowedRTFOLEMimeTypes"_ustr); if (it == aLoadMap.end()) { diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx index aaf5c41f2e0a..99b9487de551 100644 --- a/sw/source/filter/html/wrthtml.cxx +++ b/sw/source/filter/html/wrthtml.cxx @@ -183,7 +183,7 @@ std::unique_ptr<SwHTMLNumRuleInfo> SwHTMLWriter::ReleaseNextNumInfo() void SwHTMLWriter::SetupFilterOptions(SfxMedium& rMedium) { - uno::Sequence<beans::PropertyValue> aArgs = rMedium.GetArgs(); + uno::Sequence<beans::PropertyValue> aArgs = rMedium.GetArgs().getAsConstPropertyValueList(); if (const SfxStringItem* pItem = rMedium.GetItemSet().GetItemIfSet( SID_FILE_FILTEROPTIONS )) { const OUString sFilterOptions = pItem->GetValue(); diff --git a/sw/source/uibase/app/docsh.cxx b/sw/source/uibase/app/docsh.cxx index b24ecbd58464..e0f6898294a2 100644 --- a/sw/source/uibase/app/docsh.cxx +++ b/sw/source/uibase/app/docsh.cxx @@ -42,6 +42,7 @@ #include <editeng/flstitem.hxx> #include <comphelper/lok.hxx> #include <comphelper/classids.hxx> +#include <comphelper/sequenceashashmap.hxx> #include <basic/sbmod.hxx> #include <osl/diagnose.h> #include <node.hxx> @@ -438,11 +439,7 @@ bool SwDocShell::SaveAs( SfxMedium& rMedium ) { // No old URL - is this a new document created from a template with embedded DS? // Try to get the template URL to reconstruct the embedded data source URL - const css::beans::PropertyValues& rArgs = GetMedium()->GetArgs(); - const auto aURLIter = std::find_if(rArgs.begin(), rArgs.end(), - [](const auto& v) { return v.Name == "URL"; }); - if (aURLIter != rArgs.end()) - aURLIter->Value >>= aURL; + aURL = GetMedium()->GetArgs().getUnpackedValueOrDefault(u"URL"_ustr, aURL); } if (!aURL.isEmpty()) @@ -1217,14 +1214,8 @@ void SwDocShell::LoadingFinished() auto const args{GetBaseModel()->getArgs2({u"YrsConnect"_ustr})}; #endif // when loading, it is only available from SfxMedium, not SfxBaseModel - for (auto const& rArg : GetMedium()->GetArgs()) - { - if (rArg.Name == "YrsConnect") - { - m_xDoc->getIDocumentState().YrsInitConnector(rArg.Value); - break; - } - } + if (css::uno::Any any = GetMedium()->GetArgs().getValue(u"YrsConnect"_ustr); any.hasValue()) + m_xDoc->getIDocumentState().YrsInitConnector(any); #endif FinishedLoading();
